зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1290966 - Remove callback function argument from sync scripts; r=automatedtester
MozReview-Commit-ID: CaDSYA5PNFp --HG-- extra : rebase_source : 1d85bd860359d511c58b546d19037a989196a43e
This commit is contained in:
Родитель
a925942b81
Коммит
7bc1cc3ef5
|
@ -102,6 +102,7 @@ evaluate.sandbox = function(sb, script, args = [], opts = {}) {
|
|||
let timeoutId, timeoutHandler, unloadHandler;
|
||||
|
||||
let promise = new Promise((resolve, reject) => {
|
||||
let src = "";
|
||||
sb[COMPLETE] = resolve;
|
||||
timeoutHandler = () => reject(new ScriptTimeoutError("Timed out"));
|
||||
unloadHandler = () => reject(
|
||||
|
@ -109,14 +110,20 @@ evaluate.sandbox = function(sb, script, args = [], opts = {}) {
|
|||
|
||||
// wrap in function
|
||||
if (!opts.directInject) {
|
||||
if (opts.async) {
|
||||
sb[CALLBACK] = sb[COMPLETE];
|
||||
}
|
||||
sb[ARGUMENTS] = Cu.cloneInto(args, sb, {wrapReflectors: true});
|
||||
|
||||
// callback function made private
|
||||
// so that introspection is possible
|
||||
// on the arguments object
|
||||
script = `${ARGUMENTS}.push(rv => ${CALLBACK}(rv));` +
|
||||
`(function() { ${script} }).apply(null, ${ARGUMENTS})`;
|
||||
if (opts.async) {
|
||||
sb[CALLBACK] = sb[COMPLETE];
|
||||
src += `${ARGUMENTS}.push(rv => ${CALLBACK}(rv));`;
|
||||
}
|
||||
|
||||
src += `(function() { ${script} }).apply(null, ${ARGUMENTS})`;
|
||||
|
||||
// marionetteScriptFinished is not WebDriver conformant,
|
||||
// hence it is only exposed to immutable sandboxes
|
||||
|
@ -144,7 +151,7 @@ evaluate.sandbox = function(sb, script, args = [], opts = {}) {
|
|||
let res;
|
||||
try {
|
||||
res = Cu.evalInSandbox(
|
||||
script, sb, "1.8", opts.filename || "dummy file", 0);
|
||||
src, sb, "1.8", opts.filename || "dummy file", 0);
|
||||
} catch (e) {
|
||||
let err = new JavaScriptError(
|
||||
e,
|
||||
|
|
|
@ -233,6 +233,10 @@ class TestExecuteContent(MarionetteTestCase):
|
|||
self.assertTrue(
|
||||
send("return typeof window.wrappedJSObject == 'undefined'"))
|
||||
|
||||
def test_no_callback(self):
|
||||
self.assertTrue(self.marionette.execute_script(
|
||||
"return typeof arguments[0] == 'undefined'"))
|
||||
|
||||
|
||||
class TestExecuteChrome(TestExecuteContent):
|
||||
def setUp(self):
|
||||
|
|
Загрузка…
Ссылка в новой задаче