summaryrefslogtreecommitdiff
path: root/tests/test_tools/selenium/core/scripts/selenium-executionloop.js
diff options
context:
space:
mode:
authorxue <>2007-03-26 00:27:59 +0000
committerxue <>2007-03-26 00:27:59 +0000
commit0f00e85e311955b3f84dde559da6b5a2ab5c3cda (patch)
treeccb93c4e2d056c69209307fcb680fc23a9c57370 /tests/test_tools/selenium/core/scripts/selenium-executionloop.js
parentcbee2945d1858f7f256b44a3fbfe816dc0202f4d (diff)
merge from 3.0 branch till 1769.
Diffstat (limited to 'tests/test_tools/selenium/core/scripts/selenium-executionloop.js')
-rw-r--r--tests/test_tools/selenium/core/scripts/selenium-executionloop.js63
1 files changed, 27 insertions, 36 deletions
diff --git a/tests/test_tools/selenium/core/scripts/selenium-executionloop.js b/tests/test_tools/selenium/core/scripts/selenium-executionloop.js
index d59fc148..be54115e 100644
--- a/tests/test_tools/selenium/core/scripts/selenium-executionloop.js
+++ b/tests/test_tools/selenium/core/scripts/selenium-executionloop.js
@@ -64,7 +64,7 @@ TestLoop.prototype = {
// Pause: enable the "next/continue" button
this.pause();
} else {
- window.setTimeout(this.resume.bind(this), delay);
+ window.setTimeout(fnBind(this.resume, this), delay);
}
},
@@ -78,9 +78,11 @@ TestLoop.prototype = {
this._executeCurrentCommand();
this.continueTestWhenConditionIsTrue();
} catch (e) {
- this._handleCommandError(e);
- this._testComplete();
- return;
+ if (!this._handleCommandError(e)) {
+ this._testComplete();
+ } else {
+ this.continueTest();
+ }
}
},
@@ -107,11 +109,10 @@ TestLoop.prototype = {
command.target = selenium.preprocessParameter(command.target);
command.value = selenium.preprocessParameter(command.value);
LOG.debug("Command found, going to execute " + command.command);
- var result = handler.execute(selenium, command);
- LOG.debug("Command complete");
- this.commandComplete(result);
+ this.result = handler.execute(selenium, command);
+
- this.waitForCondition = result.terminationCondition;
+ this.waitForCondition = this.result.terminationCondition;
},
@@ -122,10 +123,10 @@ TestLoop.prototype = {
if (e.message) {
msg += " The error message is: " + e.message;
}
- this.commandError(msg);
+ return this.commandError(msg);
} else {
LOG.error(e.message);
- this.commandError(e.message);
+ return this.commandError(e.message);
}
},
@@ -135,23 +136,30 @@ TestLoop.prototype = {
* on with test. Fail the current test if there's a timeout or an
* exception.
*/
- LOG.debug("currentTest.continueTestWhenConditionIsTrue()");
+ //LOG.debug("currentTest.continueTestWhenConditionIsTrue()");
selenium.browserbot.runScheduledPollers();
try {
- if (this.waitForCondition == null || this.waitForCondition()) {
+ if (this.waitForCondition == null) {
+ LOG.debug("null condition; let's continueTest()");
+ LOG.debug("Command complete");
+ this.commandComplete(this.result);
+ this.continueTest();
+ } else if (this.waitForCondition()) {
LOG.debug("condition satisfied; let's continueTest()");
this.waitForCondition = null;
+ LOG.debug("Command complete");
+ this.commandComplete(this.result);
this.continueTest();
} else {
- LOG.debug("waitForCondition was false; keep waiting!");
- window.setTimeout(this.continueTestWhenConditionIsTrue.bind(this), 100);
+ //LOG.debug("waitForCondition was false; keep waiting!");
+ window.setTimeout(fnBind(this.continueTestWhenConditionIsTrue, this), 10);
}
} catch (e) {
- var lastResult = {};
- lastResult.failed = true;
- lastResult.failureMessage = e.message;
- this.commandComplete(lastResult);
- this.testComplete();
+ this.result = {};
+ this.result.failed = true;
+ this.result.failureMessage = extractExceptionMessage(e);
+ this.commandComplete(this.result);
+ this.continueTest();
}
},
@@ -167,20 +175,3 @@ TestLoop.prototype = {
}
}
-
-function decorateFunctionWithTimeout(f, timeout) {
- if (f == null) {
- return null;
- }
- if (isNaN(timeout)) {
- throw new SeleniumError("Timeout is not a number: " + timeout);
- }
- var now = new Date().getTime();
- var timeoutTime = now + timeout;
- return function() {
- if (new Date().getTime() > timeoutTime) {
- throw new SeleniumError("Timed out after " + timeout + "ms");
- }
- return f();
- };
-}