Bug 1294456 - Regression test. r=automatedtester a=testonly
authorMike Conley <mconley@mozilla.com>
Thu, 25 Aug 2016 15:48:44 -0400
changeset 350001 d6b420b13a6a605ae6718ae8dd918fb967c38de4
parent 350000 52ce999aa5949dfce9992f5c7d6e4c1ea27fc793
child 350002 285149724c552472e5c8f146ed39b49fab62253a
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)
reviewersautomatedtester, testonly
bugs1294456
milestone50.0a2
Bug 1294456 - Regression test. r=automatedtester a=testonly 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)