Unreviewed. Update W3C WebDriver imported tests.
[WebKit-https.git] / WebDriverTests / imported / w3c / tools / wptrunner / wptrunner / executors / executormarionette.py
index c76616b..faf087b 100644 (file)
@@ -131,13 +131,14 @@ class MarionetteProtocol(Protocol):
         self.logger.debug("Loading %s" % url)
         self.runner_handle = self.marionette.current_window_handle
         try:
-            self.marionette.navigate(url)
+            self.dismiss_alert(lambda: self.marionette.navigate(url))
         except Exception as e:
             self.logger.critical(
                 "Loading initial page %s failed. Ensure that the "
                 "there are no other programs bound to this port and "
                 "that your firewall rules or network setup does not "
                 "prevent access.\e%s" % (url, traceback.format_exc(e)))
+            raise
         self.marionette.execute_script(
             "document.title = '%s'" % threading.current_thread().name.replace("'", '"'))
 
@@ -157,6 +158,7 @@ class MarionetteProtocol(Protocol):
 
         for handle in handles:
             try:
+                self.dismiss_alert(lambda: self.marionette.switch_to_window(handle))
                 self.marionette.switch_to_window(handle)
                 self.marionette.close()
             except errors.NoSuchWindowException:
@@ -168,6 +170,19 @@ class MarionetteProtocol(Protocol):
         if runner_handle != self.runner_handle:
             self.load_runner(protocol)
 
+    def dismiss_alert(self, f):
+        while True:
+            try:
+                f()
+            except errors.UnexpectedAlertOpen:
+                alert = self.marionette.switch_to_alert()
+                try:
+                    alert.dismiss()
+                except errors.NoAlertPresentException:
+                    pass
+            else:
+                break
+
     def wait(self):
         try:
             socket_timeout = self.marionette.client.socket_timeout