Bug 1352132 - Navigation unit tests have to wait for the page loaded in the newly opened tab. draft
authorHenrik Skupin <mail@hskupin.info>
Mon, 08 May 2017 21:18:24 +0200
changeset 574420 aac089f2262dbf3dbd4a432d745ed2eb7210f2da
parent 574259 38f862749aed4e9a874182a9019e0671289088b0
child 627592 eb52ff8ae8bfcdc460ad07021786954e5520dbfb
push id57706
push userbmo:hskupin@gmail.com
push dateMon, 08 May 2017 21:04:59 +0000
bugs1352132
milestone55.0a1
Bug 1352132 - Navigation unit tests have to wait for the page loaded in the newly opened tab. 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()