Backout b9abacaf5453:005a3405219c (bug 998372) for make check bustage
authorNathan Froyd <froydnj@mozilla.com>
Tue, 22 Apr 2014 10:31:25 -0400
changeset 198030 8f28e657fceccffbca18baf558b8eb75af3f2b80
parent 198029 94df6fc66986e23bacc2b31a030031f0f791fa74
child 198031 6f8bee9b010f6ab2343b40d2bd0e5b77295c30ea
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs998372
milestone31.0a1
backs outb9abacaf54532d22e4a6c726a6786e982f9420aa
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
Backout b9abacaf5453:005a3405219c (bug 998372) for make check bustage
testing/mozbase/mozprofile/mozprofile/permissions.py
--- a/testing/mozbase/mozprofile/mozprofile/permissions.py
+++ b/testing/mozbase/mozprofile/mozprofile/permissions.py
@@ -299,66 +299,53 @@ class Permissions(object):
                 proxy["remote"] = l.host
                 proxy[l.scheme] = l.port
 
         # overwrite defaults with user specified proxy
         if isinstance(user_proxy, dict):
             proxy.update(user_proxy)
 
         # TODO: this should live in a template!
-        # If you must escape things in this string with backslashes, be aware
-        # of the multiple layers of escaping at work:
-        #
-        # - Python will unescape backslashes;
-        # - Writing out the prefs will escape things via JSON serialization;
-        # - The prefs file reader will unescape backslashes;
-        # - The JS engine parser will unescape backslashes.
+        # TODO: So changing the 5th line of the regex below from (\\\\\\\\d+)
+        # to (\\\\d+) makes this code work. Not sure why there would be this
+        # difference between automation.py.in and this file.
         pacURL = """data:text/plain,
-var knownOrigins = (function () {
-  return [%(origins)s].reduce(function(t, h) { t[h] = true; return t; }, {})
-})();
-var uriRegex = new RegExp('^([a-z][-a-z0-9+.]*)' +
-                          '://' +
-                          '(?:[^/@]*@)?' +
-                          '(.*?)' +
-                          '(?::(\\\\d+))?/');
-var defaultPortsForScheme = {
-  'http': 80,
-  'ws': 80,
-  'https': 443,
-  'wss': 443
-};
-var originSchemesRemap = {
-  'ws': 'http',
-  'wss': 'https'
-};
-var proxyForScheme = {
-  'http': 'PROXY %(remote)s:%(http)s',
-  'https': 'PROXY %(remote)s:%(https)s',
-  'ws': 'PROXY %(remote)s:%(ws)s',
-  'wss': 'PROXY %(remote)s:%(wss)s'
-};
-
 function FindProxyForURL(url, host)
 {
-  var matches = uriRegex.exec(url);
+  var origins = [%(origins)s];
+  var regex = new RegExp('^([a-z][-a-z0-9+.]*)' +
+                         '://' +
+                         '(?:[^/@]*@)?' +
+                         '(.*?)' +
+                         '(?::(\\\\d+))?/');
+  var matches = regex.exec(url);
   if (!matches)
     return 'DIRECT';
-  var originalScheme = matches[1];
-  var host = matches[2];
-  var port = matches[3];
-  if (!port && originalScheme in defaultPortsForScheme) {
-    port = defaultPortsForScheme[originalScheme];
+  var isHttp = matches[1] == 'http';
+  var isHttps = matches[1] == 'https';
+  var isWebSocket = matches[1] == 'ws';
+  var isWebSocketSSL = matches[1] == 'wss';
+  if (!matches[3])
+  {
+    if (isHttp | isWebSocket) matches[3] = '80';
+    if (isHttps | isWebSocketSSL) matches[3] = '443';
   }
-  var schemeForOriginChecking = originSchemesRemap[originalScheme] || originalScheme;
+  if (isWebSocket)
+    matches[1] = 'http';
+  if (isWebSocketSSL)
+    matches[1] = 'https';
 
-  var origin = schemeForOriginChecking + '://' + host + ':' + port;
-  if (!(origin in knownOrigins))
+  var origin = matches[1] + '://' + matches[2] + ':' + matches[3];
+  if (origins.indexOf(origin) < 0)
     return 'DIRECT';
-  return proxyForScheme[originalScheme] || 'DIRECT';
+  if (isHttp) return 'PROXY %(remote)s:%(http)s';
+  if (isHttps) return 'PROXY %(remote)s:%(https)s';
+  if (isWebSocket) return 'PROXY %(remote)s:%(ws)s';
+  if (isWebSocketSSL) return 'PROXY %(remote)s:%(wss)s';
+  return 'DIRECT';
 }""" % proxy
         pacURL = "".join(pacURL.splitlines())
 
         prefs = []
         prefs.append(("network.proxy.type", 2))
         prefs.append(("network.proxy.autoconfig_url", pacURL))
 
         return prefs