Bug 1303497 - Fix failure in test_window_management.py for new window checks. r=maja_zf, a=test-only
authorHenrik Skupin <mail@hskupin.info>
Thu, 22 Sep 2016 18:22:08 +0200
changeset 355710 b57b64179109580af8cad33124c49ddc81ab4c5f
parent 355709 061867df5aabf908aa3d444d2b9a7527fe4d9195
child 355711 d531a9166e20c44d9665db419d9e75457be82155
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf, test-only
bugs1303497
milestone51.0a2
Bug 1303497 - Fix failure in test_window_management.py for new window checks. r=maja_zf, a=test-only 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