Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#16388 closed enhancement (fixed)

allow return of dojo/Deferred from DOH tests

Reported by: bill Owned by: bill
Priority: undecided Milestone: 1.9
Component: TestFramework Version: 1.8.1
Keywords: Cc:
Blocked By: Blocking:


#12463 allowed DOH tests to return a dojo/_base/Deferred, but it doesn't support dojo/Deferred because that doesn't have the old-style methods like addCallback() and callback().

Conversely doh.Deferred() doesn't have the new-style methods like then() and resolve().

Update doh.Deferred() to have the new method names (in addition to the old ones), and then update the rest of DOH to use the new names, so that it can handle dojo/Deferred.

Change History (3)

comment:1 Changed 10 years ago by bill

Milestone: tbd1.9
Owner: set to bill
Status: newassigned

comment:2 Changed 10 years ago by bill

Resolution: fixed
Status: assignedclosed

In [30054]:

Support returning a dojo/promise/Promise or dojo/Deferred from a test fixture. Before, you could only return a doh.Deferred or a dojo/_base/Deferred. Besides the function name changes, I had to stop DOH from trying to modify the returned value by calling errback().

Update doh.Deferred to support the basic dojo/promise/Promise API methods: then(), always(), otherwise(), resolve(), reject(). isFulfilled(), isResolved(), isRejected(). It still supports the old method names too, but they should be removed for 2.0.

Update dojo/_base/Deferred to have working isFulfilled(), isResolved(), isRejected() methods; previously (new dojoBaseDeferred()).promise.isFulfilled() was defined but threw an exception, which is sort-of false advertising. Originally I needed this in the DOH code, but ended up not using it, so this change is optional.

Also updated a few modules to return a Promise rather than a Deferred. A dojo/_base/Deferred.promise seems to be backwards compatible with the dojo/_base/Deferred, having addCallback() etc. methods. Except of course that it doesn't have callback() and errback(), but users shouldn't be calling those anyway. Again, originally I needed this in the DOH code, but ended up not using it, so this change is optional.

This check possibly fixes some tests that were already assuming a test fixture could return a dojo/Deferred.

For 2.0 maybe we should restrict the value returned from a test fixture to a Promise, rather than a Deferred. Right now DOH looks for a promise attribute (available in dojo/Deferred and dojo/_base/Deferred, but not doh.Deferred), and uses it if available.

Fixes #16388 !strict.

comment:3 Changed 10 years ago by bill

In [30089]:

IE sporadically fires the timer even though we cleared it; seems to be related to the killRobot() at the end. Refs #16388 !strict. (There was similar code there originally which I removed as part of this ticket, but turns out it needs to be there.)

Note: See TracTickets for help on using tickets.