Bug 1113323 - Make sure Protocolhandler sets same instance of loadinfo on the newly created channel (r=sicking)
--- 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;
}
};