Bug 1439995 - [marionette] Add user prompt checks for script execution commands.
WebDriver:{ExecuteScript,ExecuteAsyncScript} were missing user
prompt checks.
MozReview-Commit-ID: KL8gTBfSTrU
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -982,16 +982,17 @@ GeckoDriver.prototype.execute_ = async f
async = false,
} = {}) {
if (typeof timeout == "undefined" || timeout === null) {
timeout = this.timeouts.script;
}
assert.open(this.getCurrentWindow());
+ this._handleUserPrompts();
assert.string(script, pprint`Expected "script" to be a string: ${script}`);
assert.array(args, pprint`Expected script args to be an array: ${args}`);
assert.positiveInteger(timeout, pprint`Expected script timeout to be a positive integer: ${timeout}`);
if (sandboxName !== null) {
assert.string(sandboxName, pprint`Expected sandbox name to be a string: ${sandboxName}`);
}
assert.boolean(newSandbox, pprint`Expected newSandbox to be boolean: ${newSandbox}`);
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_unhandled_prompt_behavior.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_unhandled_prompt_behavior.py
@@ -49,19 +49,25 @@ class TestUnhandledPromptBehavior(Marion
self.marionette.title
# Bug 1469752 - WebDriverError misses optional data property
# self.assertEqual(ex.data.text, text)
else:
self.marionette.title
self.assertEqual(self.alert_present, not expected_close)
- prompt_result = self.marionette.execute_script(
- "return window.return_value", new_sandbox=False)
- self.assertEqual(prompt_result, expected_result)
+ # Close an expected left-over user prompt
+ if not expected_close:
+ alert = self.marionette.switch_to_alert()
+ alert.dismiss()
+
+ else:
+ prompt_result = self.marionette.execute_script(
+ "return window.return_value", new_sandbox=False)
+ self.assertEqual(prompt_result, expected_result)
@parameterized("alert", "alert", None)
@parameterized("confirm", "confirm", True)
@parameterized("prompt", "prompt", "")
def test_accept(self, prompt_type, result):
self.marionette.start_session({"unhandledPromptBehavior": "accept"})
self.perform_user_prompt_check(prompt_type, "foo {}".format(prompt_type), result,
expected_notify=False)