Namespace: webdriver.promise
View Source

# class Frame_

    webdriver.EventEmitter
      └ 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.Promise`.

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.

## new Frame_(flow)

Parameters

flow`webdriver.promise.ControlFlow`

  The flow this instance belongs to.

## Instance Methods

### abort(error)code »

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

Parameters

error`*`

  The error that triggered this abortion.

### addChild(node)code »

Adds a new node to this frame.

Parameters

node`(webdriver.promise.Frame_|webdriver.promise.Task_)`

  The node to insert.

### cancelRemainingTasks(reason)code »

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;
    promise.createFlow(function(flow) {
      someResult = flow.execute(function() {});
      throw Error();
    }).thenCatch(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`webdriver.promise.CancellationError`

  The cancellation reason.

### getFirstChild()code »

Returns

`(webdriver.promise.Frame_|webdriver.promise.Task_)`

  This frame's fist child.

### getParent()code »

Returns

`webdriver.promise.Frame_`

  This frame's parent, if any.

### getPendingTask()code »

Returns

`webdriver.promise.Task_`

  The task currently executing within this frame, if any.

### getRoot()code »

Returns

`webdriver.promise.Frame_`

  The root of this frame's tree.

### isEmpty()code »

Returns

`boolean`

  Whether this frame is empty (has no scheduled tasks or pending callback frames).

### removeChild(child)code »

Removes a child from this frame.

Parameters

child`(webdriver.promise.Frame_|webdriver.promise.Task_)`

  The child to remove.

### setParent(parent)code »

Parameters

parent`webdriver.promise.Frame_`

  This frame's new parent.

### setPendingTask(task)code »

Parameters

task`webdriver.promise.Task_`

  The task currently executing within this frame, if any.

### toString()code »

Returns

`string`

## Static Properties

Frame_.CLOSE_EVENT `string`
  No description.

Frame_.ERROR_EVENT `string`
  No description.