Bug 1113323 - Make sure Protocolhandler sets same instance of loadinfo on the newly created channel (r=sicking)
authorChristoph Kerschbaumer <mozilla@christophkerschbaumer.com>
Sun, 11 Jan 2015 20:21:37 -0800
changeset 223191 922d760d0dcf2d5418f85ccbab105c4fa5929643
parent 223190 b684185c1c542c75868adf0b7d16293d3cc6b1c7
child 223192 643589c3ef94ab60157309c3be7f1441c32503c2
push id53855
push usermozilla@christophkerschbaumer.com
push dateMon, 12 Jan 2015 06:05:02 +0000
treeherdermozilla-inbound@643589c3ef94 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs1113323
milestone37.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 1113323 - Make sure Protocolhandler sets same instance of loadinfo on the newly created channel (r=sicking)
netwerk/base/src/nsIOService.cpp
netwerk/test/unit/test_about_protocol.js
--- a/netwerk/base/src/nsIOService.cpp
+++ b/netwerk/base/src/nsIOService.cpp
@@ -679,17 +679,21 @@ nsIOService::NewChannelFromURIWithProxyF
     if (aLoadInfo && newChannel2Succeeded) {
       // Make sure that all the individual protocolhandlers attach
       // a loadInfo within it's implementation of ::newChannel2().
       // Once Bug 1087720 lands, we should remove the surrounding
       // if-clause here and always assert that we indeed have a
       // loadinfo on the newly created channel.
       nsCOMPtr<nsILoadInfo> loadInfo;
       (*result)->GetLoadInfo(getter_AddRefs(loadInfo));
-      MOZ_ASSERT(loadInfo);
+      // make sure we have the same instance of loadInfo on the newly created channel
+      if (aLoadInfo != loadInfo) {
+        MOZ_ASSERT(false, "newly created channel must have a loadinfo attached");
+        return NS_ERROR_UNEXPECTED;
+      }
 
       // If we're sandboxed, make sure to clear any owner the channel
       // might already have.
       if (loadInfo->GetLoadingSandboxed()) {
         (*result)->SetOwner(nullptr);
       }
     }
 
--- a/netwerk/test/unit/test_about_protocol.js
+++ b/netwerk/test/unit/test_about_protocol.js
@@ -5,25 +5,19 @@
 let Ci = Components.interfaces;
 let Cc = Components.classes;
 
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 let unsafeAboutModule = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
-  newChannel: function (aURI) {
-    let chan = Services.io.newChannel2("about:blank",
-                                       null,
-                                       null,
-                                       null,      // aLoadingNode
-                                       Services.scriptSecurityManager.getSystemPrincipal(),
-                                       null,      // aTriggeringPrincipal
-                                       Ci.nsILoadInfo.SEC_NORMAL,
-                                       Ci.nsIContentPolicy.TYPE_OTHER);
+  newChannel: function (aURI, aLoadInfo) {
+    var uri = Services.io.newURI("about:blank", null, null);
+    let chan = Services.io.newChannelFromURIWithLoadInfo(uri, aLoadInfo);
     chan.owner = Services.scriptSecurityManager.getSystemPrincipal();
     return chan;
   },
   getURIFlags: function (aURI) {
     return Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT;
   }
 };