Class webdriver.promise.Frame_
code »webdriver.promise.Promise.<(T|null)>
└ webdriver.promise.Deferred
└ webdriver.promise.Node_
└ webdriver.promise.Frame_
An execution frame within a webdriver.promise.ControlFlow
. Each
frame represents the execution context for either a
webdriver.promise.Task_
or a callback on a
webdriver.promise.Deferred
.
Each frame may contain sub-frames. If child N is a sub-frame, then the items queued within it are given priority over child N+1.
Constructor
Parameters |
---|
|
Instance Methods
Defined in webdriver.promise.Frame_
Adds a new node to this frame.
Parameters |
---|
|
code »cancelRemainingTasks ( error )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
Parameters |
---|
|
Returns |
---|
|
Returns |
---|
|
code »removeChild ( child )Removes a child from this frame.
Parameters |
---|
|
code »setPendingTask ( task )
Parameters |
---|
|
Defined in webdriver.promise.Node_
Returns |
---|
|
Returns |
---|
|
Parameters |
---|
|
Defined in webdriver.promise.Deferred
Defined in webdriver.promise.Promise.<(T|null)>
Registers listeners for when this instance is resolved. This function most
overridden by subtypes.
Parameters |
---|
|
Returns |
|
Registers a listener for when this promise is rejected. This is synonymous
with the catch
clause in a synchronous API:
// Synchronous API:
try {
doSynchronousWork();
} catch (ex) {
console.error(ex);
}
// Asynchronous promise API:
doAsynchronousWork().thenCatch(function(ex) {
console.error(ex);
});
catch
clause in a synchronous API:
// Synchronous API:
try {
doSynchronousWork();
} catch (ex) {
console.error(ex);
}
// Asynchronous promise API:
doAsynchronousWork().thenCatch(function(ex) {
console.error(ex);
});
Parameters |
---|
|
Returns |
|
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:
// Synchronous API:
try {
doSynchronousWork();
} finally {
cleanUp();
}
// Asynchronous promise API:
doAsynchronousWork().thenFinally(cleanUp);
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:
try {
throw Error('one');
} finally {
throw Error('two'); // Hides Error: one
}
webdriver.promise.rejected(Error('one'))
.thenFinally(function() {
throw Error('two'); // Hides Error: one
});
finally
clause in a synchronous API:
// Synchronous API:
try {
doSynchronousWork();
} finally {
cleanUp();
}
// Asynchronous promise API:
doAsynchronousWork().thenFinally(cleanUp);
try {
throw Error('one');
} finally {
throw Error('two'); // Hides Error: one
}
webdriver.promise.rejected(Error('one'))
.thenFinally(function() {
throw Error('two'); // Hides Error: one
});
Parameters |
---|
|
Returns |
|
Instance Properties
Defined in webdriver.promise.Frame_
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);
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.
active
, any new frames which are
added represent callbacks on a webdriver.promise.Deferred
, whose
tasks must be given priority over previously scheduled tasks.A reference to the last node inserted in this frame.
The task currently being executed within this frame.
Defined in webdriver.promise.Node_
This node's parent.
Defined in webdriver.promise.Deferred
code »webdriver.promise.Deferred.prototype.promise : webdriver.promise.Promise.
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.
webdriver.promise.Promise.