Bug 807478 - fix timeout argument to waitFor(), r=cjones

This commit is contained in:
Chris Jones 2012-10-31 23:51:30 -07:00
parent 60abcfab6e
commit f83afe286c
3 changed files with 14 additions and 9 deletions

View File

@ -689,7 +689,9 @@ MarionetteDriverActor.prototype = {
}
let curWindow = this.getCurrentWindow();
let marionette = new Marionette(this, curWindow, "chrome", this.marionetteLog, this.marionettePerf);
let marionette = new Marionette(this, curWindow, "chrome",
this.marionetteLog, this.marionettePerf,
this.scriptTimeout);
let _chromeSandbox = this.createExecuteSandbox(curWindow, marionette, aRequest.args, aRequest.specialPowers);
if (!_chromeSandbox)
return;
@ -799,7 +801,8 @@ MarionetteDriverActor.prototype = {
let original_onerror = curWindow.onerror;
let that = this;
let marionette = new Marionette(this, curWindow, "chrome",
this.marionetteLog, this.marionettePerf);
this.marionetteLog, this.marionettePerf,
this.scriptTimeout);
marionette.command_id = this.command_id;
function chromeAsyncReturnFunc(value, status) {

View File

@ -264,7 +264,9 @@ function createExecuteContentSandbox(aWindow) {
sandbox.__proto__ = sandbox.window;
sandbox.testUtils = utils;
let marionette = new Marionette(this, aWindow, "content", marionetteLogObj, marionettePerf);
let marionette = new Marionette(this, aWindow, "content",
marionetteLogObj, marionettePerf,
marionetteTimeout);
sandbox.marionette = marionette;
marionette.exports.forEach(function(fn) {
try {
@ -445,7 +447,6 @@ function executeWithCallback(msg, timeout) {
asyncTestTimeoutId = curWindow.setTimeout(function() {
sandbox.asyncComplete('timed out', 28);
}, marionetteTimeout);
sandbox.marionette.timeout = marionetteTimeout;
curWindow.addEventListener('error', function win__onerror(evt) {
curWindow.removeEventListener('error', win__onerror, true);

View File

@ -5,14 +5,14 @@
* The Marionette object, passed to the script context.
*/
function Marionette(scope, window, context, logObj, perfData) {
function Marionette(scope, window, context, logObj, perfData, timeout) {
this.scope = scope;
this.window = window;
this.tests = [];
this.logObj = logObj;
this.perfData = perfData;
this.context = context;
this.timeout = 0;
this.timeout = timeout;
this.TEST_UNEXPECTED_FAIL = "TEST-UNEXPECTED-FAIL";
this.TEST_PASS = "TEST-PASS";
this.TEST_KNOWN_FAIL = "TEST-KNOWN-FAIL";
@ -144,14 +144,15 @@ Marionette.prototype = {
callback();
return;
}
timeout = timeout || Date.now();
if (Date.now() - timeout > this.timeout) {
var now = Date.now();
var deadline = now + (typeof(timeout) == "undefined" ? this.timeout : timeout);
if (deadline <= now) {
dump("waitFor timeout: " + test.toString() + "\n");
// the script will timeout here, so no need to raise a separate
// timeout exception
return;
}
this.window.setTimeout(this.waitFor.bind(this), 100, callback, test, timeout);
this.window.setTimeout(this.waitFor.bind(this), 100, callback, test, deadline - now);
},
runEmulatorCmd: function runEmulatorCmd(cmd, callback) {