Bug 1532990 handle default port better for proxy.settings r=zombie
authorShane Caraveo <scaraveo@mozilla.com>
Tue, 12 Mar 2019 19:08:44 +0000
changeset 524587 0cc7b558b836c8f36e53bf6941f7425e134383a9
parent 524586 24b03e0b300bd37d185a94e9eb6d526e65e55741
child 524588 5b73beb33ff14ddd5e197cee1bf1dc9c0ca71cff
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerszombie
bugs1532990
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1532990 handle default port better for proxy.settings r=zombie Differential Revision: https://phabricator.services.mozilla.com/D22297
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
@@ -68,17 +68,19 @@ ExtensionPreferencesManager.addSetting("
       "network.proxy.socks_version": value.socksVersion,
       "network.proxy.no_proxies_on": value.passthrough,
     };
 
     for (let prop of ["http", "ftp", "ssl", "socks"]) {
       if (value[prop]) {
         let url = new URL(`http://${value[prop]}`);
         prefs[`network.proxy.${prop}`] = url.hostname;
-        let port = parseInt(url.port, 10) || DEFAULT_PORTS.get(prop);
+        // Only fall back to defaults if no port provided.
+        let [, rawPort] = value[prop].split(":");
+        let port = parseInt(rawPort, 10) || DEFAULT_PORTS.get(prop);
         prefs[`network.proxy.${prop}_port`] = port;
       } else {
         prefs[`network.proxy.${prop}`] = undefined;
         prefs[`network.proxy.${prop}_port`] = undefined;
       }
     }
 
     return prefs;
--- a/toolkit/components/extensions/test/xpcshell/test_ext_proxy_config.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_proxy_config.js
@@ -277,17 +277,16 @@ add_task(async function test_browser_set
       ftp: "www.mozilla.org:21",
       ssl: "www.mozilla.org:443",
       socks: "mozilla.org:1080",
       socksVersion: 4,
       passthrough: ".mozilla.org",
     }
   );
 
-
   await testProxy(
     {
       proxyType: "manual",
       http: "http://www.mozilla.org:80",
       ftp: "ftp://www.mozilla.org:21",
       ssl: "https://www.mozilla.org:443",
       socks: "mozilla.org:1080",
       socksVersion: 4,
@@ -314,16 +313,53 @@ add_task(async function test_browser_set
       ftp: "www.mozilla.org:21",
       ssl: "www.mozilla.org:443",
       socks: "mozilla.org:1080",
       socksVersion: 4,
       passthrough: ".mozilla.org",
     }
   );
 
+
+  await testProxy(
+    {
+      proxyType: "manual",
+      http: "http://www.mozilla.org:80",
+      ftp: "ftp://www.mozilla.org:80",
+      ssl: "https://www.mozilla.org:80",
+      socks: "mozilla.org:80",
+      socksVersion: 4,
+      passthrough: ".mozilla.org",
+    },
+    {
+      "network.proxy.type": proxySvc.PROXYCONFIG_MANUAL,
+      "network.proxy.http": "www.mozilla.org",
+      "network.proxy.http_port": 80,
+      "network.proxy.share_proxy_settings": false,
+      "network.proxy.ftp": "www.mozilla.org",
+      "network.proxy.ftp_port": 80,
+      "network.proxy.ssl": "www.mozilla.org",
+      "network.proxy.ssl_port": 80,
+      "network.proxy.socks": "mozilla.org",
+      "network.proxy.socks_port": 80,
+      "network.proxy.socks_version": 4,
+      "network.proxy.no_proxies_on": ".mozilla.org",
+    },
+    {
+      proxyType: "manual",
+      http: "www.mozilla.org:80",
+      httpProxyAll: false,
+      ftp: "www.mozilla.org:80",
+      ssl: "www.mozilla.org:80",
+      socks: "mozilla.org:80",
+      socksVersion: 4,
+      passthrough: ".mozilla.org",
+    }
+  );
+
   // Test resetting values.
   await testProxy(
     {
       proxyType: "none",
       http: "",
       ftp: "",
       ssl: "",
       socks: "",