Bug 1352132 - Navigation unit tests have to wait for the page loaded in the newly opened tab. r=ato, a=test-only
authorHenrik Skupin <mail@hskupin.info>
Mon, 08 May 2017 21:18:24 +0200
changeset 396223 6c83cdd103e1e2d7900698f4038fa75512dc1b34
parent 396222 c8bf3336431b1faea494fc582854e1e295f411f2
child 396224 ecca51aa18de76d4475b4bf9faf5f845e22c7891
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato, test-only
bugs1352132
milestone54.0
Bug 1352132 - Navigation unit tests have to wait for the page loaded in the newly opened tab. r=ato, a=test-only There is a race condition for all navigation tests inside the setUp method of the BaseNavigationTestCase class. The assert for history items can already happen if the page hasn't been fully loaded yet. As such a failure is thrown. To fix this we have to wait for the page being loaded. MozReview-Commit-ID: 9LbArVT9WqA
testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
@@ -39,17 +39,19 @@ class BaseNavigationTestCase(WindowManag
         def open_with_link():
             link = self.marionette.find_element(By.ID, "new-blank-tab")
             link.click()
 
         # Always use a blank new tab for an empty history
         self.marionette.navigate(self.marionette.absolute_url("windowHandles.html"))
         self.new_tab = self.open_tab(open_with_link)
         self.marionette.switch_to_window(self.new_tab)
-        self.assertEqual(self.history_length, 1)
+        Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
+            lambda _: self.history_length == 1,
+            message="The newly opened tab doesn't have a browser history length of 1")
 
     def tearDown(self):
         self.marionette.timeout.reset()
         self.marionette.switch_to_parent_frame()
 
         self.close_all_tabs()
 
         super(BaseNavigationTestCase, self).tearDown()