Bug 1322383 - Hardening screenshot tests by forcing about:blank to be loaded by default. draft
authorHenrik Skupin <mail@hskupin.info>
Wed, 22 Mar 2017 16:11:16 +0100
changeset 502990 270e688f21a0439329766cc1f71b574854af21ec
parent 501569 05bfa2831c0ba4a26fa72328ffe6a99aba9c356a
child 502991 b06f54ca5a3cf372b7ab86636bdb8b3978418a4b
push id50441
push userbmo:hskupin@gmail.com
push dateWed, 22 Mar 2017 15:51:36 +0000
bugs1322383
milestone55.0a1
Bug 1322383 - Hardening screenshot tests by forcing about:blank to be loaded by default. If no default page is set it can be that former tests loaded a page which still shows the load status at the lower left corner of Firefox. This can lead to intermittent test failures. MozReview-Commit-ID: 77MDIRtjA4j
testing/marionette/harness/marionette_harness/tests/unit/test_screenshot.py
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_screenshot.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_screenshot.py
@@ -35,16 +35,20 @@ svg = inline("""
 
 class ScreenCaptureTestCase(MarionetteTestCase):
 
     def setUp(self):
         super(ScreenCaptureTestCase, self).setUp()
 
         self._device_pixel_ratio = None
 
+        # Ensure that each screenshot test runs on a blank page to avoid left
+        # over elements or focus which could interfer with taking screenshots
+        self.marionette.navigate("about:blank")
+
     @property
     def device_pixel_ratio(self):
         if self._device_pixel_ratio is None:
             self._device_pixel_ratio = self.marionette.execute_script("""
                 return window.devicePixelRatio
                 """)
         return self._device_pixel_ratio