Bug 1487121 - Allow proxy.settings.set calls without an explicit proxyType property. r=mixedpuppy
authorLuca Greco <lgreco@mozilla.com>
Thu, 30 Aug 2018 13:48:36 +0000
changeset 482493 f4ca43d3fc1b14fc56a13a3be6ce877873196ed4
parent 482492 c14b6edd88634fe65402dbf3d5b404ed1c83fc4c
child 482494 0cdebe3c53f883266962a601a78baaa08cd62d0f
push id232
push userfmarier@mozilla.com
push dateWed, 05 Sep 2018 20:45:54 +0000
reviewersmixedpuppy
bugs1487121
milestone63.0a1
Bug 1487121 - Allow proxy.settings.set calls without an explicit proxyType property. r=mixedpuppy Differential Revision: https://phabricator.services.mozilla.com/D4562
toolkit/components/extensions/parent/ext-proxy.js
toolkit/components/extensions/test/xpcshell/test_ext_proxy_config.js
--- a/toolkit/components/extensions/parent/ext-proxy.js
+++ b/toolkit/components/extensions/parent/ext-proxy.js
@@ -223,16 +223,21 @@ this.proxy = class extends ExtensionAPI 
 
               if (!Services.policies.isAllowed("changeProxySettings")) {
                 throw new ExtensionError(
                   "Proxy settings are being managed by the Policies manager.");
               }
 
               let value = details.value;
 
+              // proxyType is optional and it should default to "system" when missing.
+              if (value.proxyType == null) {
+                value.proxyType = "system";
+              }
+
               if (!PROXY_TYPES_MAP.has(value.proxyType)) {
                 throw new ExtensionError(
                   `${value.proxyType} is not a valid value for proxyType.`);
               }
 
               if (value.httpProxyAll) {
                 // Match what about:preferences does with proxy settings
                 // since the proxy service does not check the value
--- a/toolkit/components/extensions/test/xpcshell/test_ext_proxy_config.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_proxy_config.js
@@ -100,16 +100,19 @@ add_task(async function test_browser_set
       httpProxyAll: false,
       socksVersion: 5,
       passthrough: "localhost, 127.0.0.1",
       http: "",
       ftp: "",
       ssl: "",
       socks: "",
     };
+
+    expectedConfig.proxyType = expectedConfig.proxyType || "system";
+
     return testSetting(
       config, expectedPrefs, Object.assign(proxyConfig, expectedConfig)
     );
   }
 
   await testProxy(
     {proxyType: "none"},
     {"network.proxy.type": proxySvc.PROXYCONFIG_DIRECT},
@@ -136,16 +139,29 @@ add_task(async function test_browser_set
     },
     {
       "network.proxy.type": proxySvc.PROXYCONFIG_SYSTEM,
       "signon.autologin.proxy": false,
       "network.proxy.socks_remote_dns": false,
     },
   );
 
+  // Verify that proxyType is optional and it defaults to "system".
+  await testProxy(
+    {
+      autoLogin: false,
+      proxyDNS: false,
+    },
+    {
+      "network.proxy.type": proxySvc.PROXYCONFIG_SYSTEM,
+      "signon.autologin.proxy": false,
+      "network.proxy.socks_remote_dns": false,
+    },
+  );
+
   await testProxy(
     {
       proxyType: "autoConfig",
       autoConfigUrl: "http://mozilla.org",
     },
     {
       "network.proxy.type": proxySvc.PROXYCONFIG_PAC,
       "network.proxy.autoconfig_url": "http://mozilla.org",