Bug 1336022 - Fix test_window_handles_after_opening_new_tab by waiting for the page loaded in the new tab. r=whimboo
MozReview-Commit-ID: ExmUG2vApbl
--- 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
@@ -1,13 +1,13 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-from marionette_driver import By
+from marionette_driver import By, Wait
from marionette_harness import MarionetteTestCase, WindowManagerMixin
class TestWindowHandles(WindowManagerMixin, MarionetteTestCase):
def setUp(self):
super(TestWindowHandles, self).setUp()
@@ -27,17 +27,19 @@ class TestWindowHandles(WindowManagerMix
link.click()
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)
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, timeout=self.marionette.timeout.page_load).until(
+ lambda mn: mn.get_url() == self.empty_page,
+ message="{} did not load after opening a new tab".format(self.empty_page))
self.marionette.switch_to_window(self.start_tab)
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
self.assertEqual(self.marionette.get_url(), self.test_page)
self.marionette.switch_to_window(new_tab)
self.marionette.close()
self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs))