Bug 1391016 - "proxyAutoconfigUrl" is required for proxyType "pac". draft
authorHenrik Skupin <mail@hskupin.info>
Wed, 16 Aug 2017 21:58:55 +0200
changeset 648071 75465c320d199659680ed2b680d046b2bc139f24
parent 647689 fc8f6eeb54b92855eb3725e20eee84562344c005
child 726689 23a76f123b6d9c99ca3612ded07fce97ec305937
push id74608
push userbmo:hskupin@gmail.com
push dateThu, 17 Aug 2017 06:17:39 +0000
bugs1391016
milestone57.0a1
Bug 1391016 - "proxyAutoconfigUrl" is required for proxyType "pac". MozReview-Commit-ID: DC43PmCAWBn
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
@@ -125,16 +125,24 @@ class TestCapabilityMatching(MarionetteT
 
     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_pac_invalid_url(self):
+        with self.assertRaises(SessionNotCreatedException):
+            self.marionette.start_session({"proxy": {"proxyType": "pac"}})
+
+        with self.assertRaises(SessionNotCreatedException):
+            self.marionette.start_session({"proxy": {"proxyType": "pac",
+                                                     "proxyAutoconfigUrl": 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
@@ -208,41 +208,45 @@ session.Proxy = class {
       return p;
     }
 
     assert.object(json);
 
     assert.in("proxyType", json);
     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);
-      }
+    switch (p.proxyType) {
+      case "manual":
+        if (typeof json.httpProxy != "undefined") {
+          p.httpProxy = assert.string(json.httpProxy);
+          p.httpProxyPort = assert.positiveInteger(json.httpProxyPort);
+        }
 
-      if (typeof json.sslProxy != "undefined") {
-        p.sslProxy = assert.string(json.sslProxy);
-        p.sslProxyPort = assert.positiveInteger(json.sslProxyPort);
-      }
+        if (typeof json.sslProxy != "undefined") {
+          p.sslProxy = assert.string(json.sslProxy);
+          p.sslProxyPort = assert.positiveInteger(json.sslProxyPort);
+        }
 
-      if (typeof json.ftpProxy != "undefined") {
-        p.ftpProxy = assert.string(json.ftpProxy);
-        p.ftpProxyPort = assert.positiveInteger(json.ftpProxyPort);
-      }
+        if (typeof json.ftpProxy != "undefined") {
+          p.ftpProxy = assert.string(json.ftpProxy);
+          p.ftpProxyPort = assert.positiveInteger(json.ftpProxyPort);
+        }
 
-      if (typeof json.socksProxy != "undefined") {
-        p.socksProxy = assert.string(json.socksProxy);
-        p.socksProxyPort = assert.positiveInteger(json.socksProxyPort);
-        p.socksProxyVersion = assert.positiveInteger(json.socksProxyVersion);
-      }
-    }
+        if (typeof json.socksProxy != "undefined") {
+          p.socksProxy = assert.string(json.socksProxy);
+          p.socksProxyPort = assert.positiveInteger(json.socksProxyPort);
+          p.socksProxyVersion = assert.positiveInteger(
+              json.socksProxyVersion);
+        }
 
-    if (typeof json.proxyAutoconfigUrl != "undefined") {
-      p.proxyAutoconfigUrl = assert.string(json.proxyAutoconfigUrl);
+        break;
+
+      case "pac":
+        p.proxyAutoconfigUrl = assert.string(json.proxyAutoconfigUrl);
+        break;
     }
 
     return p;
   }
 };
 
 /** WebDriver session capabilities representation. */
 session.Capabilities = class extends Map {