Bug 1290806 - Fix TestSwitchWindow.test_windows by waiting for the newly opened window. r=maja_zf, a=test-only
authorHenrik Skupin <mail@hskupin.info>
Thu, 08 Sep 2016 18:00:36 +0200
changeset 350249 6b9c6e4a05773b239076134671b282f277549204
parent 350248 0ef7c87780c6ffd6f758fed8588c46a82af8311c
child 350250 e595d844f05d603bf1b069241b2ac52774ae8a6b
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf, test-only
Bug 1290806 - Fix TestSwitchWindow.test_windows by waiting for the newly opened window. r=maja_zf, a=test-only MozReview-Commit-ID: 750cIdl27CZ
--- 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):
 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
         #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