Backout 1819a9cc6d27 for bustage,
bug 816246, CLOSED TREE
--- a/testing/marionette/client/marionette/marionette.py
+++ b/testing/marionette/client/marionette/marionette.py
@@ -416,54 +416,51 @@ class Marionette(object):
unwrapped = HTMLElement(self, value[key])
else:
unwrapped[key] = self.unwrapValue(value[key])
else:
unwrapped = value
return unwrapped
- def execute_js_script(self, script, script_args=None, async=True, new_sandbox=True, special_powers=False, script_timeout=None):
+ def execute_js_script(self, script, script_args=None, async=True, new_sandbox=True, special_powers=False):
if script_args is None:
script_args = []
args = self.wrapArguments(script_args)
response = self._send_message('executeJSScript',
'value',
value=script,
args=args,
async=async,
newSandbox=new_sandbox,
- specialPowers=special_powers,
- scriptTimeout=script_timeout)
+ specialPowers=special_powers)
return self.unwrapValue(response)
- def execute_script(self, script, script_args=None, new_sandbox=True, special_powers=False, script_timeout=None):
+ def execute_script(self, script, script_args=None, new_sandbox=True, special_powers=False):
if script_args is None:
script_args = []
args = self.wrapArguments(script_args)
response = self._send_message('executeScript',
'value',
value=script,
args=args,
newSandbox=new_sandbox,
- specialPowers=special_powers,
- scriptTimeout=script_timeout)
+ specialPowers=special_powers)
return self.unwrapValue(response)
- def execute_async_script(self, script, script_args=None, new_sandbox=True, special_powers=False, script_timeout=None):
+ def execute_async_script(self, script, script_args=None, new_sandbox=True, special_powers=False):
if script_args is None:
script_args = []
args = self.wrapArguments(script_args)
response = self._send_message('executeAsyncScript',
'value',
value=script,
args=args,
newSandbox=new_sandbox,
- specialPowers=special_powers,
- scriptTimeout=script_timeout)
+ specialPowers=special_powers)
return self.unwrapValue(response)
def find_element(self, method, target, id=None):
kwargs = { 'value': target, 'using': method }
if id:
kwargs['element'] = id
response = self._send_message('findElement', 'value', **kwargs)
element = HTMLElement(self, response)
--- a/testing/marionette/client/marionette/tests/unit/test_execute_async_script.py
+++ b/testing/marionette/client/marionette/tests/unit/test_execute_async_script.py
@@ -14,20 +14,16 @@ class TestExecuteAsyncContent(Marionette
self.assertEqual(1, self.marionette.execute_async_script("arguments[arguments.length-1](1);"))
def test_execute_async_ours(self):
self.assertEqual(1, self.marionette.execute_async_script("marionetteScriptFinished(1);"))
def test_execute_async_timeout(self):
self.assertRaises(ScriptTimeoutException, self.marionette.execute_async_script, "var x = 1;")
- def test_execute_async_unique_timeout(self):
- self.assertEqual(1, self.marionette.execute_async_script("setTimeout(function() {marionetteScriptFinished(1);}, 2000);", script_timeout=5000))
- self.assertRaises(ScriptTimeoutException, self.marionette.execute_async_script, "setTimeout(function() {marionetteScriptFinished(1);}, 2000);")
-
def test_no_timeout(self):
self.marionette.set_script_timeout(10000)
self.assertTrue(self.marionette.execute_async_script("""
var callback = arguments[arguments.length - 1];
setTimeout(function() { callback(true); }, 500);
"""))
@skip_if_b2g
@@ -103,8 +99,9 @@ class TestExecuteAsyncChrome(TestExecute
def test_execute_permission(self):
self.assertEqual(1, self.marionette.execute_async_script("""
var c = Components.classes;
marionetteScriptFinished(1);
"""))
def test_sandbox_reuse(self):
pass
+
--- a/testing/marionette/marionette-actors.js
+++ b/testing/marionette/marionette-actors.js
@@ -664,20 +664,20 @@ MarionetteDriverActor.prototype = {
* @param boolean directInject
* If true, then the script will be run as is,
* and not as a function body (as you would
* do using the WebDriver spec)
* @param boolean async
* True if the script is asynchronous
*/
executeScriptInSandbox: function MDA_executeScriptInSandbox(sandbox, script,
- directInject, async, command_id, timeout) {
+ directInject, async, command_id) {
if (directInject && async &&
- (timeout == null || timeout == 0)) {
+ (this.scriptTimeout == null || this.scriptTimeout == 0)) {
this.sendError("Please set a timeout", 21, null, command_id);
return;
}
if (this.importedScripts.exists()) {
let stream = Cc["@mozilla.org/network/file-input-stream;1"].
createInstance(Ci.nsIFileInputStream);
stream.init(this.importedScripts, -1, 0, 0);
@@ -706,37 +706,36 @@ MarionetteDriverActor.prototype = {
* @param object aRequest
* 'value' member is the script to run
* 'args' member holds the arguments to the script
* @param boolean directInject
* if true, it will be run directly and not as a
* function body
*/
execute: function MDA_execute(aRequest, directInject) {
- let timeout = aRequest.scriptTimeout ? aRequest.scriptTimeout : this.scriptTimeout;
let command_id = this.command_id = this.getCommandId();
this.logRequest("execute", aRequest);
if (aRequest.newSandbox == undefined) {
//if client does not send a value in newSandbox,
//then they expect the same behaviour as webdriver
aRequest.newSandbox = true;
}
if (this.context == "content") {
this.sendAsync("executeScript", {value: aRequest.value,
args: aRequest.args,
newSandbox: aRequest.newSandbox,
- timeout: timeout,
+ timeout: this.scriptTimeout,
command_id: command_id});
return;
}
let curWindow = this.getCurrentWindow();
let marionette = new Marionette(this, curWindow, "chrome",
this.marionetteLog, this.marionettePerf,
- timeout, this.testName);
+ this.scriptTimeout, this.testName);
let _chromeSandbox = this.createExecuteSandbox(curWindow,
marionette,
aRequest.args,
aRequest.specialPowers);
if (!_chromeSandbox)
return;
try {
@@ -750,17 +749,17 @@ MarionetteDriverActor.prototype = {
}
else {
script = "let func = function() {" +
aRequest.value +
"};" +
"func.apply(null, __marionetteParams);";
}
this.executeScriptInSandbox(_chromeSandbox, script, directInject,
- false, command_id, timeout);
+ false, command_id);
}
catch (e) {
this.sendError(e.name + ': ' + e.message, 17, e.stack, command_id);
}
},
/**
* Set the timeout for asynchronous script execution
@@ -784,17 +783,16 @@ MarionetteDriverActor.prototype = {
* execute pure JS script. Used to execute 'mochitest'-style Marionette tests.
*
* @param object aRequest
* 'value' member holds the script to execute
* 'args' member holds the arguments to the script
* 'timeout' member will be used as the script timeout if it is given
*/
executeJSScript: function MDA_executeJSScript(aRequest) {
- let timeout = aRequest.scriptTimeout ? aRequest.scriptTimeout : this.scriptTimeout;
let command_id = this.command_id = this.getCommandId();
//all pure JS scripts will need to call Marionette.finish() to complete the test.
if (aRequest.newSandbox == undefined) {
//if client does not send a value in newSandbox,
//then they expect the same behaviour as webdriver
aRequest.newSandbox = true;
}
if (this.context == "chrome") {
@@ -805,17 +803,17 @@ MarionetteDriverActor.prototype = {
this.execute(aRequest, true);
}
}
else {
this.sendAsync("executeJSScript", { value: aRequest.value,
args: aRequest.args,
newSandbox: aRequest.newSandbox,
async: aRequest.async,
- timeout: timeout,
+ timeout: this.scriptTimeout,
command_id: command_id });
}
},
/**
* This function is used by executeAsync and executeJSScript to execute a script
* in a sandbox.
*
@@ -826,41 +824,39 @@ MarionetteDriverActor.prototype = {
* @param object aRequest
* 'value' member holds the script to execute
* 'args' member holds the arguments for the script
* @param boolean directInject
* if true, it will be run directly and not as a
* function body
*/
executeWithCallback: function MDA_executeWithCallback(aRequest, directInject) {
- let timeout = aRequest.scriptTimeout ? aRequest.scriptTimeout : this.scriptTimeout;
let command_id = this.command_id = this.getCommandId();
if (aRequest.newSandbox == undefined) {
//if client does not send a value in newSandbox,
//then they expect the same behaviour as webdriver
aRequest.newSandbox = true;
}
if (this.context == "content") {
this.sendAsync("executeAsyncScript", {value: aRequest.value,
args: aRequest.args,
id: this.command_id,
newSandbox: aRequest.newSandbox,
- timeout: timeout,
+ timeout: this.scriptTimeout,
command_id: command_id});
return;
}
let curWindow = this.getCurrentWindow();
let original_onerror = curWindow.onerror;
let that = this;
- that.timeout = timeout;
let marionette = new Marionette(this, curWindow, "chrome",
this.marionetteLog, this.marionettePerf,
- timeout, this.testName);
+ this.scriptTimeout, this.testName);
marionette.command_id = this.command_id;
function chromeAsyncReturnFunc(value, status) {
if (that._emu_cbs && Object.keys(that._emu_cbs).length) {
value = "Emulator callback still pending when finish() called";
status = 500;
that._emu_cbs = null;
}
@@ -901,17 +897,17 @@ MarionetteDriverActor.prototype = {
return;
try {
this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
if (this.timer != null) {
this.timer.initWithCallback(function() {
chromeAsyncReturnFunc("timed out", 28);
- }, that.timeout, Ci.nsITimer.TYPE_ONESHOT);
+ }, that.scriptTimeout, Ci.nsITimer.TYPE_ONESHOT);
}
_chromeSandbox.returnFunc = chromeAsyncReturnFunc;
_chromeSandbox.finish = chromeAsyncFinish;
let script;
if (directInject) {
script = aRequest.value;
@@ -919,17 +915,17 @@ MarionetteDriverActor.prototype = {
else {
script = '__marionetteParams.push(returnFunc);'
+ 'let marionetteScriptFinished = returnFunc;'
+ 'let __marionetteFunc = function() {' + aRequest.value + '};'
+ '__marionetteFunc.apply(null, __marionetteParams);';
}
this.executeScriptInSandbox(_chromeSandbox, script, directInject,
- true, command_id, timeout);
+ true, command_id);
} catch (e) {
chromeAsyncReturnFunc(e.name + ": " + e.message, 17);
}
},
/**
* Navigates to given url
*