diff --git a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executormarionette.py b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executormarionette.py index f7645fbea9df..959d9062b5cf 100644 --- a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executormarionette.py +++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executormarionette.py @@ -157,10 +157,9 @@ class MarionetteTestharnessProtocolPart(TestharnessProtocolPart): for handle in handles: try: - self.dismiss_alert(lambda: self.marionette.switch_to_window(handle)) - self.marionette.switch_to_window(handle) self.logger.info("Closing window %s" % handle) - self.marionette.close() + self.marionette.switch_to_window(handle) + self.dismiss_alert(lambda: self.marionette.close()) except errors.NoSuchWindowException: # We might have raced with the previous test to close this # window, skip it.