--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -1650,22 +1650,35 @@ nsDocShell::LoadStream(nsIInputStream *a
// Get the appropriate LoadType from nsIDocShellLoadInfo type
loadType = ConvertDocShellLoadInfoToLoadType(lt);
}
NS_ENSURE_SUCCESS(Stop(nsIWebNavigation::STOP_NETWORK), NS_ERROR_FAILURE);
mLoadType = loadType;
+ nsCOMPtr<nsISupports> owner;
+ aLoadInfo->GetOwner(getter_AddRefs(owner));
+ nsCOMPtr<nsIPrincipal> requestingPrincipal = do_QueryInterface(owner);
+ if (!requestingPrincipal) {
+ requestingPrincipal = nsContentUtils::GetSystemPrincipal();
+ }
+
// build up a channel for this stream.
nsCOMPtr<nsIChannel> channel;
- NS_ENSURE_SUCCESS(NS_NewInputStreamChannel
- (getter_AddRefs(channel), uri, aStream,
- aContentType, aContentCharset),
- NS_ERROR_FAILURE);
+ nsresult rv =
+ NS_NewInputStreamChannel(getter_AddRefs(channel),
+ uri,
+ aStream,
+ requestingPrincipal,
+ nsILoadInfo::SEC_NORMAL,
+ nsIContentPolicy::TYPE_OTHER,
+ aContentType,
+ aContentCharset);
+ NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
nsCOMPtr<nsIURILoader>
uriLoader(do_GetService(NS_URI_LOADER_CONTRACTID));
NS_ENSURE_TRUE(uriLoader, NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(DoChannelLoad(channel, uriLoader, false),
NS_ERROR_FAILURE);
return NS_OK;
@@ -10261,35 +10274,38 @@ nsDocShell::DoURILoad(nsIURI * aURI,
if (isViewSource) {
nsViewSourceHandler *vsh = nsViewSourceHandler::GetInstance();
NS_ENSURE_TRUE(vsh,NS_ERROR_FAILURE);
rv = vsh->NewSrcdocChannel(aURI, aSrcdoc, aBaseURI,
getter_AddRefs(channel));
NS_ENSURE_SUCCESS(rv, rv);
+ nsCOMPtr<nsILoadInfo> loadInfo =
+ new LoadInfo(requestingPrincipal,
+ requestingNode,
+ securityFlags,
+ aContentPolicyType);
+ channel->SetLoadInfo(loadInfo);
}
else {
- rv = NS_NewInputStreamChannel(getter_AddRefs(channel),aURI,
- aSrcdoc,
- NS_LITERAL_CSTRING("text/html"),
- true);
+ rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel),
+ aURI,
+ aSrcdoc,
+ NS_LITERAL_CSTRING("text/html"),
+ requestingNode,
+ requestingPrincipal,
+ securityFlags,
+ aContentPolicyType,
+ true);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIInputStreamChannel> isc = do_QueryInterface(channel);
MOZ_ASSERT(isc);
isc->SetBaseURI(aBaseURI);
}
- // NS_NewInputStreamChannel does not yet attach the loadInfo in nsNetutil.h,
- // hence we have to manually attach the loadInfo for that channel.
- nsCOMPtr<nsILoadInfo> loadInfo =
- new LoadInfo(requestingPrincipal,
- requestingNode,
- securityFlags,
- aContentPolicyType);
- channel->SetLoadInfo(loadInfo);
}
nsCOMPtr<nsIApplicationCacheChannel> appCacheChannel =
do_QueryInterface(channel);
if (appCacheChannel) {
// Any document load should not inherit application cache.
appCacheChannel->SetInheritApplicationCache(false);