Bug 1294456 - Regression test. r?automatedtester draft
authorMike Conley <mconley@mozilla.com>
Thu, 25 Aug 2016 15:48:44 -0400
changeset 406300 a6469411ed3f6e0cd0ccb9a77aadcd0768b0d286
parent 406299 b2e797f26a55240b60ed811e5fa2d2aaeb67a985
child 529620 1983ed415db1110665c370573bf84976b0ac16ab
push id27683
push usermconley@mozilla.com
push dateFri, 26 Aug 2016 21:22:37 +0000
reviewersautomatedtester
bugs1294456
milestone51.0a1
Bug 1294456 - Regression test. r?automatedtester The test is testing the case where Marionette attempts to send a command to a window handle when the browser has opened and selected a new tab. See the documentation in the test for more details. MozReview-Commit-ID: McDqG5kCIj
testing/marionette/harness/marionette/tests/unit/test_window_handles.py
--- a/testing/marionette/harness/marionette/tests/unit/test_window_handles.py
+++ b/testing/marionette/harness/marionette/tests/unit/test_window_handles.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/.
 
 from marionette import MarionetteTestCase
 from marionette_driver.keys import Keys
-from marionette_driver.by import By
+from marionette_driver import By
 
 
 class TestWindowHandles(MarionetteTestCase):
 
     def test_new_tab_window_handles(self):
 
         keys = []
         if self.marionette.session_capabilities['platformName'] == 'darwin':
@@ -30,16 +30,46 @@ class TestWindowHandles(MarionetteTestCa
         new_tab = handles.pop()
         self.marionette.switch_to_window(new_tab)
         self.assertEqual(self.marionette.get_url(), "about:newtab")
         self.marionette.close()
 
         self.marionette.switch_to_window(origin_win)
         self.assertEqual(self.marionette.get_url(), "about:blank")
 
+    def test_new_tab_window_handles_no_switch(self):
+        """Regression test for bug 1294456.
+        This test is testing the case where Marionette attempts to send a
+        command to a window handle when the browser has opened and selected
+        a new tab. Before bug 1294456 landed, the Marionette driver was getting
+        confused about which window handle the client cared about, and assumed
+        it was the window handle for the newly opened and selected tab.
+
+        This caused Marionette to think that the browser needed to do a remoteness
+        flip in the e10s case, since the tab opened by menu_newNavigatorTab is
+        about:newtab (which is currently non-remote). This meant that commands
+        sent to what should have been the original window handle would be
+        queued and never sent, since the remoteness flip in the new tab was
+        never going to happen.
+        """
+
+        with self.marionette.using_context("chrome"):
+            menu_new_tab = self.marionette.find_element(By.ID, 'menu_newNavigatorTab')
+            menu_new_tab.click()
+
+        self.wait_for_condition(lambda mn: len(mn.window_handles) == 2)
+
+        # We still have the default tab set as our window handle. This
+        # get_url command should be sent immediately, and not be forever-queued.
+        self.assertEqual(self.marionette.get_url(), "about:blank")
+
+        self.marionette.switch_to_window(self.marionette.window_handles[1])
+        self.marionette.close()
+        self.marionette.switch_to_window(self.marionette.window_handles[0])
+
     def test_link_opened_tab_window_handles(self):
         tab_testpage = self.marionette.absolute_url("windowHandles.html")
         self.marionette.navigate(tab_testpage)
         start_win = self.marionette.current_window_handle
         link = self.marionette.find_element(By.ID, "new-tab")
         link.click()
         self.wait_for_condition(lambda mn: len(mn.window_handles) == 2)