Bug 1290806 - Fix TestSwitchWindow.test_windows by waiting for the newly opened window. r=maja_zf
authorHenrik Skupin <mail@hskupin.info>
Thu, 08 Sep 2016 18:00:36 +0200
changeset 313902 f282dae81f23849a2fec001df6970fcbd2ff7093
parent 313901 79bebd89f7ecab920912b83204abe5efc39570d4
child 313903 18f34131ce3064d10281630d9b185cd057f54c92
push id30701
push usercbook@mozilla.com
push dateThu, 15 Sep 2016 09:57:28 +0000
treeherdermozilla-central@3b3e87b91108 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf
bugs1290806
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1290806 - Fix TestSwitchWindow.test_windows by waiting for the newly opened window. r=maja_zf MozReview-Commit-ID: 750cIdl27CZ
testing/marionette/harness/marionette/tests/unit/test_window_management.py
--- a/testing/marionette/harness/marionette/tests/unit/test_window_management.py
+++ b/testing/marionette/harness/marionette/tests/unit/test_window_management.py
@@ -1,15 +1,15 @@
 # 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/.
 
 import time
 from marionette import MarionetteTestCase
-from marionette_driver.by import By
+from marionette_driver import By, Wait
 
 
 class TestSwitchWindow(MarionetteTestCase):
     def open_new_window(self):
         self.marionette.set_context("chrome")
         self.marionette.set_script_timeout(5000)
         self.marionette.execute_async_script("""
 var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
@@ -36,17 +36,19 @@ if (win != null)
     def test_windows(self):
         orig_win = self.marionette.current_window_handle
         orig_available = self.marionette.window_handles
         self.open_new_window()
         #assert we're still in the original window
         self.assertEqual(self.marionette.current_window_handle, orig_win)
         now_available = self.marionette.window_handles
         #assert we can find the new window
-        self.assertEqual(len(now_available), len(orig_available) + 1)
+        Wait(self.marionette).until(
+            lambda _: len(now_available) == len(orig_available) + 1,
+            message="The new window has not been opened.")
         #assert that our window is there
         self.assertTrue(orig_win in now_available)
         new_win = None
         for win in now_available:
             if win != orig_win:
                 new_win = orig_win
         #switch to another window
         self.marionette.switch_to_window(new_win)