Bug 1090962 - Skip steps of gather_debug when marionette session does not exist. r=davehunt
authorZac Campbell <zcampbell@mozilla.com>
Mon, 03 Nov 2014 14:02:23 +0000
changeset 213818 83312696fd68280d139ef2fb362c45c46bfb95da
parent 213817 fd0146aeb963cad2f3229f3afabdfea4c0e83eb0
child 213819 53d51e7fbb9e234e7931875afb3ec7612ca7198f
push id51336
push usercbook@mozilla.com
push dateTue, 04 Nov 2014 07:38:25 +0000
treeherdermozilla-inbound@53d51e7fbb9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdavehunt
bugs1090962
milestone36.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 1090962 - Skip steps of gather_debug when marionette session does not exist. r=davehunt
testing/marionette/client/marionette/runner/base.py
testing/marionette/client/marionette/runner/mixins/reporting.py
--- a/testing/marionette/client/marionette/runner/base.py
+++ b/testing/marionette/client/marionette/runner/base.py
@@ -493,24 +493,27 @@ class BaseMarionetteTestRunner(object):
         self.mixin_run_tests = []
         self.manifest_skipped_tests = []
         self.tests = []
         self.result_callbacks = result_callbacks if result_callbacks is not None else []
 
         def gather_debug(test, status):
             rv = {}
             marionette = test._marionette_weakref()
-            try:
-                marionette.set_context(marionette.CONTEXT_CHROME)
-                rv['screenshot'] = marionette.screenshot()
-                marionette.set_context(marionette.CONTEXT_CONTENT)
-                rv['source'] = marionette.page_source
-            except:
-                logger = get_default_logger()
-                logger.warning('Failed to gather test failure debug.', exc_info=True)
+
+            # In the event we're gathering debug without starting a session, skip marionette commands
+            if marionette.session is not None:
+                try:
+                    marionette.set_context(marionette.CONTEXT_CHROME)
+                    rv['screenshot'] = marionette.screenshot()
+                    marionette.set_context(marionette.CONTEXT_CONTENT)
+                    rv['source'] = marionette.page_source
+                except:
+                    logger = get_default_logger()
+                    logger.warning('Failed to gather test failure debug.', exc_info=True)
             return rv
 
         self.result_callbacks.append(gather_debug)
 
         if testvars:
             if not os.path.exists(testvars):
                 raise IOError('--testvars file does not exist')
 
--- a/testing/marionette/client/marionette/runner/mixins/reporting.py
+++ b/testing/marionette/client/marionette/runner/mixins/reporting.py
@@ -242,26 +242,28 @@ class HTMLReportingTestResultMixin(objec
     def html_modifier(self, test, result_expected, result_actual, output, context):
         test.debug = None
         if result_actual is not 'PASS':
             test.debug = self.gather_debug()
         return result_expected, result_actual, output, context
 
     def gather_debug(self):
         debug = {}
-        try:
-            self.marionette.set_context(self.marionette.CONTEXT_CHROME)
-            debug['screenshot'] = self.marionette.screenshot()
-            self.marionette.set_context(self.marionette.CONTEXT_CONTENT)
-            debug['source'] = self.marionette.page_source
-            self.marionette.switch_to_frame()
-            debug['settings'] = json.dumps(self.marionette.execute_async_script("""
+        # In the event we're gathering debug without starting a session, skip marionette commands
+        if self.marionette.session is not None:
+            try:
+                self.marionette.set_context(self.marionette.CONTEXT_CHROME)
+                debug['screenshot'] = self.marionette.screenshot()
+                self.marionette.set_context(self.marionette.CONTEXT_CONTENT)
+                debug['source'] = self.marionette.page_source
+                self.marionette.switch_to_frame()
+                debug['settings'] = json.dumps(self.marionette.execute_async_script("""
 SpecialPowers.addPermission('settings-read', true, document);
 SpecialPowers.addPermission('settings-api-read', true, document);
 var req = window.navigator.mozSettings.createLock().get('*');
 req.onsuccess = function() {
   marionetteScriptFinished(req.result);
 }""", special_powers=True), sort_keys=True, indent=4, separators=(',', ': '))
-        except:
-            logger = get_default_logger()
-            logger.warning('Failed to gather test failure debug.', exc_info=True)
+            except:
+                logger = get_default_logger()
+                logger.warning('Failed to gather test failure debug.', exc_info=True)
         return debug