Bug 1370871 - Remove "global" global from evaluate script context; r?automatedtester
Marionette exposes a global called "global" to scripts that are
evaluated in sandboxes. This is no longer needed after the rewrite of
the testing/marionette/evaluate.js module.
MozReview-Commit-ID: BobdwilaCy0
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -879,17 +879,16 @@ GeckoDriver.prototype.execute_ = functio
return this.listener.executeInSandbox(script, args, timeout, opts)
.then(evaluate.toJSON);
}
case Context.CHROME:
let sb = this.sandboxes.get(opts.sandboxName, opts.newSandbox);
if (opts.sandboxName) {
sb = sandbox.augment(sb, new logging.Adapter(this.marionetteLog));
- sb = sandbox.augment(sb, {global: sb});
}
opts.timeout = timeout;
let wargs = evaluate.fromJSON(args, this.curBrowser.seenEls, sb.window);
return evaluate.sandbox(sb, script, wargs, opts)
.then(res => evaluate.toJSON(res, this.curBrowser.seenEls));
}
};
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_execute_async_script.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_execute_async_script.py
@@ -88,36 +88,24 @@ marionetteScriptFinished(4);
def test_sandbox_reuse(self):
# Sandboxes between `execute_script()` invocations are shared.
self.marionette.execute_async_script("this.foobar = [23, 42];"
"marionetteScriptFinished();")
self.assertEqual(self.marionette.execute_async_script(
"marionetteScriptFinished(this.foobar);", new_sandbox=False), [23, 42])
- self.marionette.execute_async_script("global.barfoo = [42, 23];"
- "marionetteScriptFinished();")
- self.assertEqual(self.marionette.execute_async_script(
- "marionetteScriptFinished(global.barfoo);", new_sandbox=False), [42, 23])
-
def test_sandbox_refresh_arguments(self):
self.marionette.execute_async_script("this.foobar = [arguments[0], arguments[1]];"
"marionetteScriptFinished();",
script_args=[23, 42])
self.assertEqual(self.marionette.execute_async_script(
"marionetteScriptFinished(this.foobar);", new_sandbox=False),
[23, 42])
- self.marionette.execute_async_script("global.barfoo = [arguments[0], arguments[1]];"
- "marionetteScriptFinished()",
- script_args=[42, 23], new_sandbox=False)
- self.assertEqual(self.marionette.execute_async_script(
- "marionetteScriptFinished(global.barfoo);", new_sandbox=False),
- [42, 23])
-
# Functions defined in higher privilege scopes, such as the privileged
# content frame script listener.js runs in, cannot be accessed from
# content. This tests that it is possible to introspect the objects on
# `arguments` without getting permission defined errors. This is made
# possible because the last argument is always the callback/complete
# function.
#
# See bug 1290966.
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_execute_script.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_execute_script.py
@@ -202,20 +202,16 @@ class TestExecuteContent(MarionetteTestC
self.assertEqual(expected, actual)
def test_sandbox_reuse(self):
# Sandboxes between `execute_script()` invocations are shared.
self.marionette.execute_script("this.foobar = [23, 42];")
self.assertEqual(self.marionette.execute_script(
"return this.foobar;", new_sandbox=False), [23, 42])
- self.marionette.execute_script("global.barfoo = [42, 23];")
- self.assertEqual(self.marionette.execute_script(
- "return global.barfoo;", new_sandbox=False), [42, 23])
-
def test_sandbox_refresh_arguments(self):
self.marionette.execute_script(
"this.foobar = [arguments[0], arguments[1]]", [23, 42])
self.assertEqual(self.marionette.execute_script(
"return this.foobar", new_sandbox=False), [23, 42])
def test_mutable_sandbox_wrappedjsobject(self):
self.assert_is_defined("window.wrappedJSObject")
--- a/testing/marionette/listener.js
+++ b/testing/marionette/listener.js
@@ -735,17 +735,16 @@ function* execute(script, args, timeout,
return evaluate.toJSON(res, seenEls);
}
function* executeInSandbox(script, args, timeout, opts) {
opts.timeout = timeout;
let sb = sandboxes.get(opts.sandboxName, opts.newSandbox);
if (opts.sandboxName) {
- sb = sandbox.augment(sb, {global: sb});
sb = sandbox.augment(sb, new logging.Adapter(contentLog));
}
let wargs = evaluate.fromJSON(
args, seenEls, curContainer.frame, curContainer.shadowRoot);
let evaluatePromise = evaluate.sandbox(sb, script, wargs, opts);
let res = yield evaluatePromise;