Bug 1303497 - Fix failure in test_window_management.py for new window checks. draft
authorHenrik Skupin <mail@hskupin.info>
Thu, 22 Sep 2016 18:22:08 +0200
changeset 416631 351e2bbe10ae5677bc605fcf76a19da9ab669f6d
parent 416562 f0e6cc6360213ba21fd98c887b55fce5c680df68
child 531899 d8c71574a7231e387ab1bf4849da2554c390d655
push id30193
push userbmo:hskupin@gmail.com
push dateThu, 22 Sep 2016 16:24:18 +0000
bugs1303497
milestone52.0a1
Bug 1303497 - Fix failure in test_window_management.py for new window checks. MozReview-Commit-ID: DbkRrRQvlTb
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
@@ -32,35 +32,38 @@ if (win != null)
   win.close();
 """)
         self.marionette.set_context("content")
 
     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
+        # 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
+        # assert we can find the new window
         Wait(self.marionette).until(
-            lambda _: len(now_available) == len(orig_available) + 1,
+            lambda _: len(self.marionette.window_handles) == 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)
+        # assert that our window is there
+        now_available = self.marionette.window_handles
+        self.assertIn(orig_win, now_available)
         new_win = None
         for win in now_available:
             if win != orig_win:
-                new_win = orig_win
-        #switch to another window
+                new_win = win
+        # switch to another window
         self.marionette.switch_to_window(new_win)
         self.assertEqual(self.marionette.current_window_handle, new_win)
-        #switch back
+        self.assertNotEqual(self.marionette.current_window_handle, orig_win)
+        # switch back
         self.marionette.switch_to_window(orig_win)
+        self.assertEqual(self.marionette.current_window_handle, orig_win)
         self.close_new_window()
+        self.assertNotIn(new_win, self.marionette.window_handles)
         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