# Class webdriver.promise.Frame_

code »

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

webdriver.promise.Frame_ ( flow )

Parameters
flow: `!webdriver.promise.ControlFlow` The flow this instance belongs to.

Show:Public Protected Private

## Instance Methods

code »abort ( error )

Aborts the execution of this frame, cancelling all outstanding tasks scheduled within this frame.

Parameters
error: `*` The error that triggered this abortion.

code »addChild ( node )

Adds a new node to this frame.

Parameters
node: `!(webdriver.promise.Frame_|webdriver.promise.Task_)` The node to insert.

code »cancelRemainingTasks ( reason )

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! CancelledTaskError: Task discarded due to a previous // task failure: Error: boom

Parameters
reason: `string` The cancellation reason.

code »close ( )

Signals that this frame has successfully finished executing.

code »getFirstChild ( ) ⇒ `(webdriver.promise.Frame_|webdriver.promise.Task_)`

Returns
This frame's fist child.

code »getParent ( ) ⇒ `webdriver.promise.Frame_`

Returns
This frame's parent, if any.

code »getPendingTask ( ) ⇒ `webdriver.promise.Task_`

Returns
The task currently executing within this frame, if any.

code »getRoot ( ) ⇒ `!webdriver.promise.Frame_`

Returns
The root of this frame's tree.

code »notify_ ( fn, opt_error )

Parameters
fn: `?(function(*)|function())` The function to notify. opt_error: `*=` Value to pass to the notified function, if any.

code »removeChild ( child )

Removes a child from this frame.

Parameters
child: `!(webdriver.promise.Frame_|webdriver.promise.Task_)` The child to remove.

code »setParent ( parent )

Parameters
parent: `webdriver.promise.Frame_` This frame's new parent.

code »setPendingTask ( task )

Parameters
task: `webdriver.promise.Task_` The task currently executing within this frame, if any.

code »toString ( ) ⇒ `string`

## Instance Properties

code »children_ : `!Array`
code »flow_ : `!webdriver.promise.ControlFlow`
code »isLocked_ : `boolean`

Whether this frame is currently locked. A locked frame represents an executed function that has scheduled all of its tasks.

Once a frame becomes locked, any new frames which are added as children represent interrupts (such as a `webdriver.promise.Promise` callback) whose tasks must be given priority over those already scheduled within this frame. For example: ``

       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);

code »isWaiting : `boolean`
code »lastInsertedChild_ : `(webdriver.promise.Frame_|webdriver.promise.Task_)`
code »onAbort : `?function(*)`

The function to notify if this frame is aborted with an error.

code »onComplete : `?function()`

The function to notify if this frame executes without error.

code »parent_ : `webdriver.promise.Frame_`
code »pendingTask_ : `webdriver.promise.Task_`

The task currently being executed within this frame.