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
--- 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)