Bug 990299: correct and enable window management test in Marionette; r=mdas
authorDavid Burns <dburns@mozilla.com>
Thu, 17 Apr 2014 20:48:27 +0100
changeset 179488 656d5a4f110ea7c58c2aa4bcbeec10d91615e9f2
parent 179487 12d543cfa1677371da8753fd847c5cc5d07433b3
child 179489 ce8248d046d1fc53011e3fe63ebc0c2e9fb2d6e3
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersmdas
bugs990299
milestone31.0a1
Bug 990299: correct and enable window management test in Marionette; r=mdas
testing/marionette/client/marionette/tests/unit/test_window_management.py
testing/marionette/client/marionette/tests/unit/unit-tests.ini
--- a/testing/marionette/client/marionette/tests/unit/test_window_management.py
+++ b/testing/marionette/client/marionette/tests/unit/test_window_management.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/.
 
-import os
+import time
 from marionette_test import MarionetteTestCase
 
 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"]
@@ -55,19 +55,27 @@ if (win != null)
         self.assertEqual(self.marionette.current_window_handle, orig_win)
         self.assertEqual(len(self.marionette.window_handles), len(orig_available))
 
     def testShouldLoadAWindowAndThenCloseIt(self):
         test_html = self.marionette.absolute_url("test_windows.html")
         self.marionette.navigate(test_html)
         current = self.marionette.current_window_handle
 
-        self.marionette.find_element('link text',"Open new window").click()
-        window_handles = self.marionette.window_handles
-        window_handles.remove(current)
+        self.marionette.find_element('link text', "Open new window").click()
+        count = 0
+        while True:
+            window_handles = self.marionette.window_handles
+            window_handles.remove(current)
+            if len(window_handles) > 0:
+                break
+            elif count > 10:
+                self.fail("There were no windows that appeared when we clicked earlier")
+            else:
+                time.sleep(1)
 
         self.marionette.switch_to_window(window_handles[0])
         self.assertEqual(self.marionette.title, "We Arrive Here")
 
         handle = self.marionette.current_window_handle
 
         self.assertEqual(self.marionette.current_window_handle, handle)
         self.assertEqual(2, len(self.marionette.window_handles))
--- a/testing/marionette/client/marionette/tests/unit/unit-tests.ini
+++ b/testing/marionette/client/marionette/tests/unit/unit-tests.ini
@@ -87,17 +87,16 @@ browser = false
 [test_switch_remote_frame.py]
 
 [test_pagesource.py]
 
 [test_visibility.py]
 [test_window_switching.py]
 b2g = false
 [test_window_management.py]
-disabled = "Bug 990299"
 b2g = false
 
 [test_appcache.py]
 [test_screenshot.py]
 [test_cookies.py]
 b2g = false
 [test_window_title.py]
 [test_window_type.py]