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 521589 0cc7b558b836
parent 521588 24b03e0b300b
child 521590 5b73beb33ff1
push id10867
push userdvarga@mozilla.com
push dateThu, 14 Mar 2019 15:20:45 +0000
treeherdermozilla-beta@abad13547875 [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: "",