Bug 1511764 - Ensure that marionette has a session when we try to use it during teardown, r=whimboo
authorJames Graham <james@hoppipolla.co.uk>
Tue, 12 Feb 2019 14:32:16 +0000
changeset 458744 f754cb84d092
parent 458743 0bdbfacae180
child 458745 4cf8e31cb261
push id35548
push useropoprus@mozilla.com
push dateWed, 13 Feb 2019 09:48:26 +0000
treeherdermozilla-central@93e37c529818 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswhimboo
bugs1511764
milestone67.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 1511764 - Ensure that marionette has a session when we try to use it during teardown, r=whimboo In the case that startup failed we may not have a marionette session during teardown Depends on D19486 Differential Revision: https://phabricator.services.mozilla.com/D19487
testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executormarionette.py
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executormarionette.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executormarionette.py
@@ -506,22 +506,23 @@ class MarionetteProtocol(Protocol):
         self.logger.debug("Starting Marionette session")
         self.marionette.start_session(self.capabilities)
         self.logger.debug("Marionette session started")
 
     def after_connect(self):
         pass
 
     def teardown(self):
-        try:
-            self.marionette._request_in_app_shutdown()
-            self.marionette.delete_session(send_request=False)
-        except Exception:
-            # This is typically because the session never started
-            pass
+        if self.marionette and self.marionette.session_id:
+            try:
+                self.marionette._request_in_app_shutdown()
+                self.marionette.delete_session(send_request=False)
+            except Exception:
+                # This is typically because the session never started
+                pass
         if self.marionette is not None:
             del self.marionette
         super(MarionetteProtocol, self).teardown()
 
     @property
     def is_alive(self):
         try:
             self.marionette.current_window_handle
@@ -764,19 +765,20 @@ class MarionetteRefTestExecutor(RefTestE
 
     def setup(self, runner):
         super(self.__class__, self).setup(runner)
         self.implementation.setup(**self.implementation_kwargs)
 
     def teardown(self):
         try:
             self.implementation.teardown()
-            handles = self.protocol.marionette.window_handles
-            if handles:
-                self.protocol.marionette.switch_to_window(handles[0])
+            if self.protocol.marionette and self.protocol.marionette.session_id:
+                handles = self.protocol.marionette.window_handles
+                if handles:
+                    self.protocol.marionette.switch_to_window(handles[0])
             super(self.__class__, self).teardown()
         except Exception as e:
             # Ignore errors during teardown
             self.logger.warning("Exception during reftest teardown:\n%s" %
                                 traceback.format_exc(e))
 
     def is_alive(self):
         return self.protocol.is_alive
@@ -872,18 +874,19 @@ class InternalRefTestImplementation(obje
     def get_references(self, node):
         rv = []
         for item, relation in node.references:
             rv.append([self.executor.test_url(item), self.get_references(item), relation])
         return rv
 
     def teardown(self):
         try:
-            self.executor.protocol.marionette._send_message("reftest:teardown", {})
-            self.executor.protocol.marionette.set_context(self.executor.protocol.marionette.CONTEXT_CONTENT)
+            if self.executor.protocol.marionette and self.executor.protocol.marionette.session_id:
+                self.executor.protocol.marionette._send_message("reftest:teardown", {})
+                self.executor.protocol.marionette.set_context(self.executor.protocol.marionette.CONTEXT_CONTENT)
         except Exception as e:
             # Ignore errors during teardown
             self.logger.warning(traceback.format_exc(e))
 
 
 
 class GeckoDriverProtocol(WebDriverProtocol):
     server_cls = GeckoDriverServer