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
--- 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()