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
bugs1290806
milestone50.0a2
Bug 1290806 - Fix TestSwitchWindow.test_windows by waiting for the newly opened window. r=maja_zf, a=test-only 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)