Bug 1439995 - [marionette] Add user prompt checks for script execution commands. r=ato
authorHenrik Skupin <mail@hskupin.info>
Thu, 26 Jul 2018 22:04:56 +0200
changeset 428704 5fcc35eafe56492b9fe0687a988330c3cce2da6c
parent 428703 156f576151ebdd20ce8dd251d4b25d5433fa8120
child 428705 910af1264f68e4d65e8e55d1605ba2e88196bb10
push id34340
push userdvarga@mozilla.com
push dateFri, 27 Jul 2018 17:37:02 +0000
treeherdermozilla-central@d353b80fd66c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1439995
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1439995 - [marionette] Add user prompt checks for script execution commands. r=ato WebDriver:{ExecuteScript,ExecuteAsyncScript} were missing user prompt checks. MozReview-Commit-ID: KL8gTBfSTrU
testing/marionette/driver.js
testing/marionette/harness/marionette_harness/tests/unit/test_unhandled_prompt_behavior.py
--- 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)