Skip to content

Commit

Permalink
Remove a redundant variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyba committed Sep 18, 2014
1 parent 27aec01 commit 70157d7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 36 deletions.
36 changes: 9 additions & 27 deletions javascript/webdriver/promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,7 @@ webdriver.promise.ControlFlow.prototype.runInNewFrame_ = function(
webdriver.promise.popFlow_();
this.schedulingFrame_ = null;
}
newFrame.lockFrame();
newFrame.isLocked_ = true;

// If there was nothing scheduled in the new frame we can discard the
// frame and return immediately.
Expand Down Expand Up @@ -1833,13 +1833,13 @@ webdriver.promise.Frame_ = function(flow) {
this.pendingTask_ = null;

/**
* Whether this frame is active. A frame is considered active once one of its
* descendants has been removed for execution.
* Whether this frame is currently locked. A locked frame represents an
* executed function that has scheduled all of its tasks.
*
* Adding a sub-frame as a child to an active frame is an indication that
* a callback to a {@link webdriver.promise.Deferred} is being invoked and any
* tasks scheduled within it should have priority over previously scheduled
* tasks:
* <p>Once a frame becomes locked, any new frames which are added as children
* represent interrupts (such as a {@link webdriver.promise.Promise}
* callback) whose tasks must be given priority over those already scheduled
* within this frame. For example:
* <code><pre>
* var flow = webdriver.promise.controlFlow();
* flow.execute('start here', goog.nullFunction).then(function() {
Expand All @@ -1850,18 +1850,6 @@ webdriver.promise.Frame_ = function(flow) {
*
* @private {boolean}
*/
this.isActive_ = false;

/**
* 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.
*
* <p>Once a frame becomes {@link #isActive_ active}, any new frames which are
* added represent callbacks on a {@link webdriver.promise.Deferred}, whose
* tasks must be given priority over previously scheduled tasks.
*
* @private {boolean}
*/
this.isLocked_ = false;
};
goog.inherits(webdriver.promise.Frame_, webdriver.promise.Node_);
Expand Down Expand Up @@ -1925,12 +1913,6 @@ webdriver.promise.Frame_.prototype.setPendingTask = function(task) {
};


/** Locks this frame. */
webdriver.promise.Frame_.prototype.lockFrame = function() {
this.isLocked_ = true;
};


/**
* Adds a new node to this frame.
* @param {!(webdriver.promise.Frame_|webdriver.promise.Task_)} node
Expand All @@ -1946,7 +1928,7 @@ webdriver.promise.Frame_.prototype.addChild = function(node) {

node.setParent(this);

if (this.isActive_ && node instanceof webdriver.promise.Frame_) {
if (this.isLocked_ && node instanceof webdriver.promise.Frame_) {
var index = 0;
if (this.lastInsertedChild_ instanceof
webdriver.promise.Frame_) {
Expand All @@ -1967,7 +1949,7 @@ webdriver.promise.Frame_.prototype.addChild = function(node) {
* fist child.
*/
webdriver.promise.Frame_.prototype.getFirstChild = function() {
this.isActive_ = true;
this.isLocked_ = true;
this.lastInsertedChild_ = null;
return this.children_[0];
};
Expand Down
18 changes: 9 additions & 9 deletions javascript/webdriver/test/promise_flow_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function testAddChild_withSubframes() {
assertArrayEquals([task1, frame1], root.children_);
assertArrayEquals([task2, task3], frame1.children_);

frame1.lockFrame();
frame1.isLocked_ = true;
var task4 = createTask('task4'), task5 = createTask('task5');
root.addChild(task4);
root.addChild(task5);
Expand All @@ -199,9 +199,9 @@ function testAddChild_withSubframes() {
root.addChild(frame2);
root.addChild(frame3);
root.addChild(task6);
frame3.lockFrame();
frame3.isLocked_ = true;
root.addChild(task7);
frame2.lockFrame();
frame2.isLocked_ = true;
root.addChild(task8);

assertArrayEquals([task1, frame1, task4, task5, frame2, task8],
Expand All @@ -218,11 +218,11 @@ function testAddChild_insertingFramesIntoAnActiveFrame() {
task1 = createTask('task1');

root.addChild(task1);
root.isActive_ = true;
root.isLocked_ = true;
root.addChild(frame2);
frame2.lockFrame();
frame2.isLocked_ = true;
root.addChild(frame3);
frame3.lockFrame();
frame3.isLocked_ = true;

assertArrayEquals([frame2, frame3, task1], root.children_);
}
Expand Down Expand Up @@ -314,7 +314,7 @@ function testGetNextTask() {
assertArrayEquals([task1, frame1], root.children_);
assertArrayEquals([task2, task3], frame1.children_);

frame1.lockFrame();
frame1.isLocked_ = true;
root.addChild(task4);
root.addChild(task5);
assertArrayEquals([task1, frame1, task4, task5], root.children_);
Expand All @@ -324,9 +324,9 @@ function testGetNextTask() {
root.addChild(frame2);
root.addChild(frame3);
root.addChild(task6);
frame3.lockFrame();
frame3.isLocked_ = true;
root.addChild(task7);
frame2.lockFrame();
frame2.isLocked_ = true;
root.addChild(task8);

assertArrayEquals([task1, frame1, task4, task5, frame2, task8],
Expand Down

0 comments on commit 70157d7

Please sign in to comment.