Bug 1157732 - Allow ws (insecure) connections to localhost. r=kcambridge
authorDoug Turner <doug.turner@gmail.com>
Thu, 23 Apr 2015 20:43:40 +0200
changeset 272206 e8318ccd5c288c920f66442d9e526345e2ead80a
parent 272205 cbabce5695c4b0091a78226207e38b2640a6c916
child 272207 aca9e40788afe6085e5833a8dff2770f5b0dd52b
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskcambridge
bugs1157732
milestone40.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 1157732 - Allow ws (insecure) connections to localhost. r=kcambridge
dom/push/PushService.jsm
--- a/dom/push/PushService.jsm
+++ b/dom/push/PushService.jsm
@@ -882,31 +882,36 @@ this.PushService = {
       debug("Network is offline.");
       return null;
     }
 
     let socket;
     if (uri.scheme === "wss") {
       socket = Cc["@mozilla.org/network/protocol;1?name=wss"]
                  .createInstance(Ci.nsIWebSocketChannel);
-
-      socket.initLoadInfo(null, // aLoadingNode
-                          Services.scriptSecurityManager.getSystemPrincipal(),
-                          null, // aTriggeringPrincipal
-                          Ci.nsILoadInfo.SEC_NORMAL,
-                          Ci.nsIContentPolicy.TYPE_WEBSOCKET);
     }
     else if (uri.scheme === "ws") {
-      debug("Push over an insecure connection (ws://) is not allowed!");
-      return null;
+      if (uri.host != "localhost") {
+        debug("Push over an insecure connection (ws://) is not allowed!");
+        return null;
+      }
+      socket = Cc["@mozilla.org/network/protocol;1?name=ws"]
+                 .createInstance(Ci.nsIWebSocketChannel);
     }
     else {
       debug("Unsupported websocket scheme " + uri.scheme);
       return null;
     }
+
+    socket.initLoadInfo(null, // aLoadingNode
+                        Services.scriptSecurityManager.getSystemPrincipal(),
+                        null, // aTriggeringPrincipal
+                        Ci.nsILoadInfo.SEC_NORMAL,
+                        Ci.nsIContentPolicy.TYPE_WEBSOCKET);
+
     return socket;
   },
 
   _beginWSSetup: function() {
     debug("beginWSSetup()");
     if (this._currentState != STATE_SHUT_DOWN) {
       debug("_beginWSSetup: Not in shutdown state! Current state " +
             this._currentState);