Bug 1391016 - Make sure that proxyType is required and a string. draft
authorHenrik Skupin <mail@hskupin.info>
Wed, 16 Aug 2017 21:45:09 +0200
changeset 647689 fc8f6eeb54b92855eb3725e20eee84562344c005
parent 647355 9ab2470a3210324bc11320531b15d195aaf05051
child 647690 160141534196c7d4126423a013bb4ed9dfca6171
child 648071 75465c320d199659680ed2b680d046b2bc139f24
push id74508
push userbmo:hskupin@gmail.com
push dateWed, 16 Aug 2017 19:59:24 +0000
bugs1391016
milestone57.0a1
Bug 1391016 - Make sure that proxyType is required and a string. The webdriver spec declares the "proxyType" as required, and of type string. MozReview-Commit-ID: FXUhdYfOwWI
testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py
testing/marionette/session.js
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py
@@ -118,16 +118,23 @@ class TestCapabilityMatching(MarionetteT
             print("invalid strategy {}".format(value))
             with self.assertRaisesRegexp(SessionNotCreatedException, "InvalidArgumentError"):
                 self.marionette.start_session({"pageLoadStrategy": value})
 
     def test_proxy_none_by_default(self):
         self.marionette.start_session()
         self.assertNotIn("proxy", self.marionette.session_capabilities)
 
+    def test_invalid_proxy_type(self):
+        with self.assertRaises(SessionNotCreatedException):
+            self.marionette.start_session({"proxy": {"proxyAutoconfigUrl": None}})
+
+        with self.assertRaises(SessionNotCreatedException):
+            self.marionette.start_session({"proxy": {"proxyType": None}})
+
     def test_proxy_type_direct(self):
         self.marionette.start_session({"proxy": {"proxyType": "direct"}})
         self.assertIn("proxy", self.marionette.session_capabilities)
         self.assertEqual(self.marionette.session_capabilities["proxy"]["proxyType"], "direct")
         self.assertEqual(self.marionette.get_pref("network.proxy.type"), 0)
 
     def test_proxy_type_manual(self):
         self.marionette.start_session({"proxy": {"proxyType": "manual"}})
--- a/testing/marionette/session.js
+++ b/testing/marionette/session.js
@@ -206,17 +206,17 @@ session.Proxy = class {
     let p = new session.Proxy();
     if (typeof json == "undefined" || json === null) {
       return p;
     }
 
     assert.object(json);
 
     assert.in("proxyType", json);
-    p.proxyType = json.proxyType;
+    p.proxyType = assert.string(json.proxyType);
 
     if (json.proxyType == "manual") {
       if (typeof json.httpProxy != "undefined") {
         p.httpProxy = assert.string(json.httpProxy);
         p.httpProxyPort = assert.positiveInteger(json.httpProxyPort);
       }
 
       if (typeof json.sslProxy != "undefined") {