Bug 1452597 - Remove debug_script functionality for injected scripts. r=maja_zf

The WebDriver:ExecuteScript and WebDriver:ExecuteAsyncScript commands
accepts a "debug_script" parameter that attaches an error handler
on the WindowProxy in the sandbox.

This used to be necessary because the error handler used to be
attached to the content window instead of the sandbox.

MozReview-Commit-ID: ImRVkC5T75O

--HG--
extra : rebase_source : c13c33b4d708879f66bd906f431157720842690c
This commit is contained in:
Andreas Tolfsen 2018-04-09 13:13:18 +01:00
Родитель 470c2e1592
Коммит 3e389d5b45
4 изменённых файлов: 3 добавлений и 38 удалений

Просмотреть файл

@ -1718,8 +1718,7 @@ class Marionette(object):
return self._from_json(rv)
def execute_async_script(self, script, script_args=(), new_sandbox=True,
sandbox="default", script_timeout=None,
debug_script=False):
sandbox="default", script_timeout=None):
"""Executes an asynchronous JavaScript script, and returns the
result (or None if the script does return a value).
@ -1736,8 +1735,6 @@ class Marionette(object):
:param new_sandbox: If False, preserve global variables from
the last execute_*script call. This is True by default,
in which case no globals are preserved.
:param debug_script: Capture javascript exceptions when in
`CONTEXT_CHROME` context.
Usage example:
@ -1762,11 +1759,9 @@ class Marionette(object):
"sandbox": sandbox,
"scriptTimeout": script_timeout,
"line": int(frame[1]),
"filename": filename,
"debug_script": debug_script}
"filename": filename}
rv = self._send_message("WebDriver:ExecuteAsyncScript",
body, key="value")
rv = self._send_message("WebDriver:ExecuteAsyncScript", body, key="value")
return self._from_json(rv)
def find_element(self, method, target, id=None):

Просмотреть файл

@ -854,9 +854,6 @@ GeckoDriver.prototype.getContext = function() {
* Filename of the client's program where this script is evaluated.
* @param {number=} line
* Line in the client's program where this script is evaluated.
* @param {boolean=} debug_script
* Attach an <code>onerror</code> event handler on the {@link Window}
* object. It does not differentiate content errors from chrome errors.
*
* @return {(string|boolean|number|object|WebElement)}
* Return value from the script, or null which signifies either the
@ -878,7 +875,6 @@ GeckoDriver.prototype.executeScript = async function(cmd, resp) {
newSandbox: cmd.parameters.newSandbox,
file: cmd.parameters.filename,
line: cmd.parameters.line,
debug: cmd.parameters.debug_script,
};
resp.body.value = await this.execute_(script, args, opts);
};
@ -926,9 +922,6 @@ GeckoDriver.prototype.executeScript = async function(cmd, resp) {
* Filename of the client's program where this script is evaluated.
* @param {number=} line
* Line in the client's program where this script is evaluated.
* @param {boolean=} debug_script
* Attach an <code>onerror</code> event handler on the {@link Window}
* object. It does not differentiate content errors from chrome errors.
*
* @return {(string|boolean|number|object|WebElement)}
* Return value from the script, or null which signifies either the
@ -950,7 +943,6 @@ GeckoDriver.prototype.executeAsyncScript = async function(cmd, resp) {
newSandbox: cmd.parameters.newSandbox,
file: cmd.parameters.filename,
line: cmd.parameters.line,
debug: cmd.parameters.debug_script,
async: true,
};
resp.body.value = await this.execute_(script, args, opts);
@ -965,7 +957,6 @@ GeckoDriver.prototype.execute_ = async function(
newSandbox = false,
file = "",
line = 0,
debug = false,
async = false,
} = {}) {
@ -984,7 +975,6 @@ GeckoDriver.prototype.execute_ = async function(
assert.boolean(newSandbox, pprint`Expected newSandbox to be boolean: ${newSandbox}`);
assert.string(file, pprint`Expected file to be a string: ${file}`);
assert.number(line, pprint`Expected line to be a number: ${line}`);
assert.boolean(debug, pprint`Expected debug_script to be boolean: ${debug}`);
let opts = {
timeout,
@ -992,7 +982,6 @@ GeckoDriver.prototype.execute_ = async function(
newSandbox,
file,
line,
debug,
async,
};

Просмотреть файл

@ -69,8 +69,6 @@ this.evaluate = {};
* @param {boolean=} [async=false] async
* Indicates if the script should return immediately or wait for
* the callback to be invoked before returning.
* @param {boolean=} [debug=false] debug
* Attaches an <code>onerror</code> event listener.
* @param {string=} [file="dummy file"] file
* File location of the program in the client.
* @param {number=} [line=0] line
@ -94,7 +92,6 @@ this.evaluate = {};
evaluate.sandbox = function(sb, script, args = [],
{
async = false,
debug = false,
file = "dummy file",
line = 0,
sandboxName = null,
@ -131,17 +128,6 @@ evaluate.sandbox = function(sb, script, args = [],
sb[MARIONETTE_SCRIPT_FINISHED] = sb[CALLBACK];
}
// onerror is not hooked on by default because of the inability to
// differentiate content errors from chrome errors.
//
// see bug 1128760 for more details
if (debug) {
sb.window.onerror = (msg, url, line) => {
let err = new JavaScriptError(`${msg} at ${url}:${line}`);
reject(err);
};
}
// timeout and unload handlers
scriptTimeoutID = setTimeout(timeoutHandler, timeout);
sb.window.onunload = unloadHandler;

Просмотреть файл

@ -142,8 +142,3 @@ marionetteScriptFinished(5);
var callback = arguments[arguments.length - 1];
setTimeout("callback(foo())", 50);
""")
self.assertRaises(JavascriptException,
self.marionette.execute_async_script, """
var callback = arguments[arguments.length - 1];
setTimeout("callback(foo())", 50);
""", debug_script=True)