Bug 937659 - Fix deserializing of page load strategy. r=ato

The patch aligns the steps for deserializing the page load strategy with
the webdriver specification.

MozReview-Commit-ID: GnVTnhVQVkG

--HG--
extra : rebase_source : c7796817fa6d0397b4821445dc3bd87853e0e509
This commit is contained in:
Henrik Skupin 2017-04-19 12:32:20 +02:00
parent b777047482
commit cfdbf9979c
2 changed files with 17 additions and 5 deletions

View file

@ -223,9 +223,14 @@ class TestCapabilityMatching(MarionetteTestCase):
self.marionette.start_session({"desiredCapabilities": {"pageLoadStrategy": strategy}})
self.assertEqual(self.marionette.session_capabilities["pageLoadStrategy"], strategy)
# A null value should be treatend as "normal"
self.delete_session()
self.marionette.start_session({"desiredCapabilities": {"pageLoadStrategy": None}})
self.assertEqual(self.marionette.session_capabilities["pageLoadStrategy"], "normal")
for value in ["", "EAGER", True, 42, {}, []]:
print("invalid strategy {}".format(value))
with self.assertRaises(SessionNotCreatedException):
with self.assertRaisesRegexp(SessionNotCreatedException, "InvalidArgumentError"):
self.marionette.start_session({"desiredCapabilities": {"pageLoadStrategy": value}})
def test_proxy_default(self):

View file

@ -245,7 +245,7 @@ session.Capabilities = class extends Map {
throw new TypeError();
}
return super.set(key, value);
return super.set(key, value);
}
toString() { return "[object session.Capabilities]"; }
@ -357,11 +357,18 @@ session.Capabilities = class extends Map {
break;
case "pageLoadStrategy":
if (Object.values(session.PageLoadStrategy).includes(v)) {
matched.set("pageLoadStrategy", v);
if (v === null) {
matched.set("pageLoadStrategy", session.PageLoadStrategy.Normal);
} else {
throw new TypeError("Unknown page load strategy: " + v);
assert.string(v);
if (Object.values(session.PageLoadStrategy).includes(v)) {
matched.set("pageLoadStrategy", v);
} else {
throw new InvalidArgumentError("Unknown page load strategy: " + v);
}
}
break;
case "proxy":