Bug 1381858 - Ensure we have a valid window handle before trying to wait, r=ato
If we switched to a window that is now closed (possible in a reftest
run, for example), we might end up calling execute_async_script
without a valid current window. The runner window is always supposed
to be open (and if it isn't then waiting won't make much sense
anyway), so switch to that before executing script in wait().
MozReview-Commit-ID: ERoN4sz5SuH
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executormarionette.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executormarionette.py
@@ -171,16 +171,17 @@ class MarionetteProtocol(Protocol):
if runner_handle != self.runner_handle:
self.load_runner(protocol)
def wait(self):
socket_timeout = self.marionette.client.sock.gettimeout()
if socket_timeout:
self.marionette.timeout.script = socket_timeout / 2
+ self.marionette.switch_to_window(self.runner_handle)
while True:
try:
self.marionette.execute_async_script("")
except errors.ScriptTimeoutException:
self.logger.debug("Script timed out")
pass
except (socket.timeout, IOError):
self.logger.debug("Socket closed")