--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -939,32 +939,32 @@ GeckoDriver.prototype.getContext = funct
* JavaScript notion of null or undefined.
*
* @throws {ScriptTimeoutError}
* If the script was interrupted due to reaching the
* <var>scriptTimeout</var> or default timeout.
* @throws {JavaScriptError}
* If an {@link Error} was thrown whilst evaluating the script.
*/
-GeckoDriver.prototype.executeScript = function*(cmd, resp) {
+GeckoDriver.prototype.executeScript = async function(cmd, resp) {
assert.window(this.getCurrentWindow());
let {script, args, scriptTimeout} = cmd.parameters;
scriptTimeout = scriptTimeout || this.timeouts.script;
let opts = {
sandboxName: cmd.parameters.sandbox,
newSandbox: !!(typeof cmd.parameters.newSandbox == "undefined") ||
cmd.parameters.newSandbox,
file: cmd.parameters.filename,
line: cmd.parameters.line,
debug: cmd.parameters.debug_script,
};
- resp.body.value = yield this.execute_(script, args, scriptTimeout, opts);
+ resp.body.value = await this.execute_(script, args, scriptTimeout, opts);
};
/**
* Executes a JavaScript function in the context of the current browsing
* context, if in content space, or in chrome space otherwise, and returns
* the object passed to the callback.
*
* The callback is always the last argument to the <var>arguments</var>
@@ -1016,58 +1016,66 @@ GeckoDriver.prototype.executeScript = fu
* JavaScript notion of null or undefined.
*
* @throws {ScriptTimeoutError}
* If the script was interrupted due to reaching the
* <var>scriptTimeout</var> or default timeout.
* @throws {JavaScriptError}
* If an Error was thrown whilst evaluating the script.
*/
-GeckoDriver.prototype.executeAsyncScript = function* (cmd, resp) {
+GeckoDriver.prototype.executeAsyncScript = async function(cmd, resp) {
assert.window(this.getCurrentWindow());
let {script, args, scriptTimeout} = cmd.parameters;
scriptTimeout = scriptTimeout || this.timeouts.script;
let opts = {
sandboxName: cmd.parameters.sandbox,
newSandbox: !!(typeof cmd.parameters.newSandbox == "undefined") ||
cmd.parameters.newSandbox,
file: cmd.parameters.filename,
line: cmd.parameters.line,
debug: cmd.parameters.debug_script,
async: true,
};
- resp.body.value = yield this.execute_(script, args, scriptTimeout, opts);
+ resp.body.value = await this.execute_(script, args, scriptTimeout, opts);
};
-GeckoDriver.prototype.execute_ = function(script, args, timeout, opts = {}) {
+GeckoDriver.prototype.execute_ = async function(
+ script, args, timeout, opts = {}) {
+ let res, els;
+
switch (this.context) {
case Context.CONTENT:
// evaluate in content with lasting side-effects
if (!opts.sandboxName) {
- return this.listener.execute(script, args, timeout, opts)
- .then(evaluate.toJSON);
- }
+ res = await this.listener.execute(script, args, timeout, opts);
// evaluate in content with sandbox
- return this.listener.executeInSandbox(script, args, timeout, opts)
- .then(evaluate.toJSON);
+ } else {
+ res = await this.listener.executeInSandbox(
+ script, args, timeout, opts);
+ }
+
+ break;
case Context.CHROME:
let sb = this.sandboxes.get(opts.sandboxName, opts.newSandbox);
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));
+ res = await evaluate.sandbox(sb, script, wargs, opts);
+ els = this.curBrowser.seenEls;
+ break;
default:
throw new TypeError(`Unknown context: ${this.context}`);
}
+
+ return evaluate.toJSON(res, els);
};
/**
* Navigate to given URL.
*
* Navigates the current browsing context to the given URL and waits for
* the document to load or the session's page timeout duration to elapse
* before returning.