Bug 1378191 - Use JSON to send capabilities in "Marionette:listenersAttached" r=automatedtester a=test-only
authorHenrik Skupin <mail@hskupin.info>
Tue, 04 Jul 2017 21:03:36 +0200
changeset 414179 82893ea5d603bdde7632741f4605fe6a271765a4
parent 414178 f67bf272f69e5515f8b670feeebb5d398bc28d7b
child 414180 6953478140f0f9e71503f751d401f448b18e0e23
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersautomatedtester, test-only
bugs1378191
milestone55.0
Bug 1378191 - Use JSON to send capabilities in "Marionette:listenersAttached" r=automatedtester a=test-only By not using the JSON format when sending the capabilities to the frame script, the values cannot be correctly decoded. As result the capabilities will be reset to their default values for the listener, and can cause various failures. MozReview-Commit-ID: KaryoJiyd30
testing/marionette/driver.js
testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -3140,17 +3140,17 @@ GeckoDriver.prototype.receiveMessage = f
       let rv = this.registerBrowser(wid, be);
       return rv;
 
     case "Marionette:listenersAttached":
       if (message.json.listenerId === this.curBrowser.curFrameId) {
         // If remoteness gets updated we need to call newSession. In the case
         // of desktop this just sets up a small amount of state that doesn't
         // change over the course of a session.
-        this.sendAsync("newSession", this.capabilities);
+        this.sendAsync("newSession", this.capabilities.toJSON());
         this.curBrowser.flushPendingCommands();
       }
       break;
   }
 };
 
 GeckoDriver.prototype.responseCompleted = function () {
   if (this.curBrowser !== null) {
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
@@ -608,36 +608,52 @@ class TestTLSNavigation(MarionetteTestCa
         print "with safe session again"
         with self.safe_session() as session:
             with self.assertRaises(errors.InsecureCertificateException):
                 session.navigate(invalid_cert_url)
 
 
 class TestPageLoadStrategy(BaseNavigationTestCase):
 
-    def setUp(self):
-        super(TestPageLoadStrategy, self).setUp()
+    def tearDown(self):
+        self.marionette.delete_session()
+        self.marionette.start_session()
 
-        if self.marionette.session is not None:
-            self.marionette.delete_session()
+        super(TestPageLoadStrategy, self).tearDown()
 
     def test_none(self):
+        self.marionette.delete_session()
         self.marionette.start_session({"desiredCapabilities": {"pageLoadStrategy": "none"}})
 
         # With a strategy of "none" there should be no wait for the page load, and the
         # current load state is unknown. So only test that the command executes successfully.
         self.marionette.navigate(self.test_page_slow_resource)
 
     def test_eager(self):
+        self.marionette.delete_session()
         self.marionette.start_session({"desiredCapabilities": {"pageLoadStrategy": "eager"}})
 
         self.marionette.navigate(self.test_page_slow_resource)
         self.assertEqual("interactive", self.ready_state)
         self.assertEqual(self.test_page_slow_resource, self.marionette.get_url())
         self.marionette.find_element(By.ID, "slow")
 
     def test_normal(self):
+        self.marionette.delete_session()
         self.marionette.start_session({"desiredCapabilities": {"pageLoadStrategy": "normal"}})
 
         self.marionette.navigate(self.test_page_slow_resource)
         self.assertEqual(self.test_page_slow_resource, self.marionette.get_url())
         self.assertEqual("complete", self.ready_state)
         self.marionette.find_element(By.ID, "slow")
+
+    @run_if_e10s("Requires e10s mode enabled")
+    def test_strategy_after_remoteness_change(self):
+        """Bug 1378191 - Reset of capabilities after listener reload"""
+        self.marionette.delete_session()
+        self.marionette.start_session({"desiredCapabilities": {"pageLoadStrategy": "eager"}})
+
+        # Trigger a remoteness change which will reload the listener script
+        self.assertTrue(self.is_remote_tab, "Initial tab doesn't have remoteness flag set")
+        self.marionette.navigate("about:robots")
+        self.assertFalse(self.is_remote_tab, "Tab has remoteness flag set")
+        self.marionette.navigate(self.test_page_slow_resource)
+        self.assertEqual("interactive", self.ready_state)