Bug 1566884 - Do not replace "direct" proxy info result from proxy.onRequest with a null default proxy info, r=mixedpuppy a=RyanVM
authorHonza Bambas <honzab.moz@firemni.cz>
Wed, 17 Jul 2019 20:47:35 +0300
changeset 541480 50dcd65bee401205c50299cbe6fa5cc8dc67a5fa
parent 541479 43030692b97baac6e41b94f3a59829209fdd3aaa
child 541481 6aa4c38274c43f00b98eeb974c7ee067dfc4e8e4
push id11620
push userrmaries@mozilla.com
push dateMon, 22 Jul 2019 19:45:05 +0000
treeherdermozilla-beta@50dcd65bee40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy, RyanVM
bugs1566884
milestone69.0
Bug 1566884 - Do not replace "direct" proxy info result from proxy.onRequest with a null default proxy info, r=mixedpuppy a=RyanVM Differential Revision: https://phabricator.services.mozilla.com//D38364
toolkit/components/extensions/ProxyScriptContext.jsm
toolkit/components/extensions/test/xpcshell/test_proxy_listener.js
--- a/toolkit/components/extensions/ProxyScriptContext.jsm
+++ b/toolkit/components/extensions/ProxyScriptContext.jsm
@@ -230,17 +230,17 @@ const ProxyInfoData = {
       port,
       username,
       password,
       proxyDNS,
       failoverTimeout,
       proxyAuthorizationHeader,
       connectionIsolationKey,
     } = ProxyInfoData.validate(proxyData);
-    if (type === PROXY_TYPES.DIRECT) {
+    if (type === PROXY_TYPES.DIRECT && defaultProxyInfo) {
       return defaultProxyInfo;
     }
     let failoverProxy = this.createProxyInfoFromData(
       proxyDataList,
       defaultProxyInfo,
       proxyDataListIndex + 1
     );
 
--- a/toolkit/components/extensions/test/xpcshell/test_proxy_listener.js
+++ b/toolkit/components/extensions/test/xpcshell/test_proxy_listener.js
@@ -59,16 +59,17 @@ const testData = [
       {
         type: "socks",
         host: "192.168.1.3",
         port: 1999,
         proxyDNS: true,
         username: "mungosantamaria",
         password: "foobar",
       },
+      { type: "direct" },
     ],
     expected: {
       proxyInfo: {
         type: "socks",
         host: "foo.bar",
         port: 1080,
         proxyDNS: true,
         username: "johnsmith",
@@ -169,17 +170,17 @@ add_task(async function test_proxy_liste
           host,
           port,
           username,
           password,
           proxyDNS,
           failoverTimeout,
         } = expectedProxyInfo;
         equal(proxyUsed.host, host, `Expected proxy host to be ${host}`);
-        equal(proxyUsed.port, port, `Expected proxy port to be ${port}`);
+        equal(proxyUsed.port, port || -1, `Expected proxy port to be ${port}`);
         equal(proxyUsed.type, type, `Expected proxy type to be ${type}`);
         // May be null or undefined depending on use of newProxyInfoWithAuth or newProxyInfo
         equal(
           proxyUsed.username || "",
           username || "",
           `Expected proxy username to be ${username}`
         );
         equal(
@@ -195,16 +196,17 @@ add_task(async function test_proxy_liste
         // Default timeout is 10
         equal(
           proxyUsed.failoverTimeout,
           failoverTimeout || 10,
           `Expected failoverTimeout to be ${failoverTimeout}`
         );
         expectedProxyInfo = expectedProxyInfo.failoverProxy;
       }
+      ok(!expectedProxyInfo, "no left over failoverProxy");
     }
   }
 
   await extension.unload();
 });
 
 async function getExtension(expectedProxyInfo) {
   function background(proxyInfo) {