Bug 1344647 - Wait for the web page being loaded in a newly opened tab
MozReview-Commit-ID: 49qx8UZb8Jy
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_window_handles_content.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_window_handles_content.py
@@ -55,17 +55,19 @@ class TestWindowHandles(WindowManagerMix
# We open a new window but are actually interested in the new tab
new_tab = self.open_tab(trigger=open_with_link)
self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs) + 1)
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
# Check that the new tab has the correct page loaded
self.marionette.switch_to_window(new_tab)
self.assertEqual(self.marionette.current_window_handle, new_tab)
- self.assertEqual(self.marionette.get_url(), self.empty_page)
+ Wait(self.marionette, self.marionette.timeout.page_load).until(
+ lambda _: self.marionette.get_url() == self.empty_page,
+ message="The expected page '{}' has not been loaded".format(self.empty_page))
# Ensure navigate works in our current window
other_page = self.marionette.absolute_url("test.html")
self.marionette.navigate(other_page)
self.assertEqual(self.marionette.get_url(), other_page)
# Close the opened window and carry on in our original tab.
self.marionette.close()
@@ -84,9 +86,11 @@ class TestWindowHandles(WindowManagerMix
self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs) + 1)
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
self.marionette.close()
self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs))
self.marionette.switch_to_window(new_tab)
self.assertEqual(self.marionette.current_window_handle, new_tab)
- self.assertEqual(self.marionette.get_url(), self.empty_page)
+ Wait(self.marionette, self.marionette.timeout.page_load).until(
+ lambda _: self.marionette.get_url() == self.empty_page,
+ message="The expected page '{}' has not been loaded".format(self.empty_page))