Marks all of the tasks that are descendants of this frame in the execution
tree as cancelled. This is necessary for callbacks scheduled asynchronous.
For example:
var someResult;
webdriver.promise.createFlow(function(flow) {
someResult = flow.execute(function() {});
throw Error();
}).addErrback(function(err) {
console.log('flow failed: ' + err);
someResult.then(function() {
console.log('task succeeded!');
}, function(err) {
console.log('task failed! ' + err);
});
});
// flow failed: Error: boom
// task failed! CanceledTaskError: Task discarded due to a previous
// task failure: Error: boom
Resolves this promise with the given value. If the value is itself a
promise and not a reference to this deferred, this instance will wait for
it before resolving.
Registers a function to be invoked when this promise is either rejected or
resolved. This function is provided for backwards compatibility with the
Dojo Deferred API.
The function to call when this promise is
either resolved or rejected. The function should expect a single
argument: the resolved value or rejection error.
Registers a function to be invoked when this promise is successfully
resolved. This function is provided for backwards compatibility with the
Dojo Deferred API.
An alias for webdriver.promise.Promise.prototype.then that permits
the scope of the invoked function to be specified. This function is provided
for backwards compatibility with the Dojo Deferred API.
Registers a listener to invoke when this promise is resolved, regardless
of whether the promise's value was successfully computed. This function
is synonymous with the finally clause in a synchronous API:
Note: similar to the finally clause, if the registered
callback returns a rejected promise or throws an error, it will silently
replace the rejection error (if any) from this promise:
Whether this frame is active. A frame is considered active once one of its
descendants has been removed for execution.
Adding a sub-frame as a child to an active frame is an indication that
a callback to a webdriver.promise.Deferred is being invoked and any
tasks scheduled within it should have priority over previously scheduled
tasks:
var flow = webdriver.promise.controlFlow();
flow.execute('start here', goog.nullFunction).then(function() {
flow.execute('this should execute 2nd', goog.nullFunction);
});
flow.execute('this should execute last', goog.nullFunction);
Whether this frame is currently locked. A locked frame represents a callback
or task function which has run to completion and scheduled all of its tasks.
Once a frame becomes active, any new frames which are
added represent callbacks on a webdriver.promise.Deferred, whose
tasks must be given priority over previously scheduled tasks.
Represents the eventual value of a completed operation. Each promise may be
in one of three states: pending, resolved, or rejected. Each promise starts
in the pending state and may make a single transition to either a
fulfilled or failed state.
This class is based on the Promise/A proposal from CommonJS. Additional
functions are provided for API compatibility with Dojo Deferred objects.