Bug 1211567 - bypass port checking for local domain socket proxy; r=MattN draft
authorLiang-Heng Chen <xeonchen@mozilla.com>
Thu, 30 Jun 2016 16:25:23 +0800
changeset 399483 a609ced1ad7afe074004f2a12014c22a19166018
parent 399482 944384214d6029d8a0bbad85f2a578cac3a50e0b
child 527941 a0e570ef457deb9104ef787be068f5101b0376c3
push id25848
push userbmo:xeonchen@mozilla.com
push dateThu, 11 Aug 2016 07:00:13 +0000
reviewersMattN
bugs1211567
milestone51.0a1
Bug 1211567 - bypass port checking for local domain socket proxy; r=MattN MozReview-Commit-ID: B4Xge15WBdw
browser/components/preferences/connection.js
browser/components/preferences/in-content/tests/browser_connection_bug388287.js
--- a/browser/components/preferences/connection.js
+++ b/browser/components/preferences/connection.js
@@ -14,23 +14,25 @@ var gConnectionsDialog = {
 
     if (proxyTypePref.value != 1)
       return true;
 
     var httpProxyURLPref = document.getElementById("network.proxy.http");
     var httpProxyPortPref = document.getElementById("network.proxy.http_port");
     var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings");
 
-    // If the port is 0 and the proxy server is specified, focus on the port and cancel submission.
+    // If the port is 0 and the socket proxy server is specified, focus on the port
+    // and cancel submission unless the proxy server is domain-socket-based.
     for (let prefName of ["http","ssl","ftp","socks"]) {
       let proxyPortPref = document.getElementById("network.proxy." + prefName + "_port");
       let proxyPref = document.getElementById("network.proxy." + prefName);
       // Only worry about ports which are currently active. If the share option is on, then ignore
       // all ports except the HTTP port
       if (proxyPref.value != "" && proxyPortPref.value == 0 &&
+            !(proxyPref.value.startsWith("/") && prefName == "socks") &&
             (prefName == "http" || !shareProxiesPref.value)) {
         document.getElementById("networkProxy" + prefName.toUpperCase() + "_Port").focus();
         return false;
       }
     }
 
     // In the case of a shared proxy preference, backup the current values and update with the HTTP value
     if (shareProxiesPref.value) {
--- a/browser/components/preferences/in-content/tests/browser_connection_bug388287.js
+++ b/browser/components/preferences/in-content/tests/browser_connection_bug388287.js
@@ -76,28 +76,31 @@ function test() {
           gBrowser.contentWindow.gAdvancedPane.showConnections();
         }
       }
     }
   };
 
   // The actual tests to run, in a generator
   function* runConnectionTestsGen() {
-    let doc, connectionWin, proxyTypePref, sharePref, httpPref, httpPortPref, ftpPref, ftpPortPref;
+    let doc, connectionWin, proxyTypePref, sharePref;
+    let httpPref, httpPortPref, ftpPref, ftpPortPref, socksPref, socksPortPref;
 
     // Convenient function to reset the variables for the new window
     function setDoc(win) {
       doc = win.document;
       connectionWin = win;
       proxyTypePref = doc.getElementById("network.proxy.type");
       sharePref = doc.getElementById("network.proxy.share_proxy_settings");
       httpPref = doc.getElementById("network.proxy.http");
       httpPortPref = doc.getElementById("network.proxy.http_port");
       ftpPref = doc.getElementById("network.proxy.ftp");
       ftpPortPref = doc.getElementById("network.proxy.ftp_port");
+      socksPref = doc.getElementById("network.proxy.socks");
+      socksPortPref = doc.getElementById("network.proxy.socks_port");
     }
 
     // This batch of tests should not close the dialog
     setDoc(yield null);
 
     // Testing HTTP port 0 with share on
     proxyTypePref.value = 1;
     sharePref.value = true;
@@ -120,16 +123,24 @@ function test() {
     // The test will timeout if the onbeforeaccept kicks in erroneously.
     closeable = true;
 
     // Both ports 80, share on
     httpPortPref.value = 80;
     ftpPortPref.value = 80;
     doc.documentElement.acceptDialog();
 
+    // Domain socket based SOCKS, port is 0
+    setDoc(yield null);
+    proxyTypePref.value = 1;
+    sharePref.value = false;
+    socksPref.value = "/path/to/socks";
+    socksPortPref.value = 0;
+    doc.documentElement.acceptDialog();
+
     // HTTP 80, FTP 0, with share on
     setDoc(yield null);
     proxyTypePref.value = 1;
     sharePref.value = true;
     ftpPref.value = "localhost";
     httpPref.value = "localhost";
     httpPortPref.value = 80;
     ftpPortPref.value = 0;