Bug 1378191 - Use JSON to send capabilities in "Marionette:listenersAttached" draft
authorHenrik Skupin <mail@hskupin.info>
Tue, 04 Jul 2017 21:03:36 +0200
changeset 603821 46ebcf270cba5f0a90c216fd70f846f781c27192
parent 603394 e6a7a778ba132b87f346a5458b0879c45a3061b7
child 636020 de64e16883469eae491560fb2759d12b2dea3760
push id66882
push userbmo:hskupin@gmail.com
push dateTue, 04 Jul 2017 20:53:31 +0000
bugs1378191
milestone56.0a1
Bug 1378191 - Use JSON to send capabilities in "Marionette:listenersAttached" 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
@@ -3183,17 +3183,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;
   }
 };
 /* eslint-enable consistent-return */
 
 GeckoDriver.prototype.responseCompleted = function() {
--- 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)