Bug 1260931 - Part 4: update OriginAttributes when http redirect. r=smaug

This commit is contained in:
Yoshi Huang 2016-08-29 12:41:02 +08:00
Родитель 10b437080c
Коммит 02dbef1f56
1 изменённых файлов: 30 добавлений и 0 удалений

Просмотреть файл

@ -2901,6 +2901,36 @@ HttpBaseChannel::SetupReplacementChannel(nsIURI *newURI,
if (mLoadInfo) { if (mLoadInfo) {
nsCOMPtr<nsILoadInfo> newLoadInfo = nsCOMPtr<nsILoadInfo> newLoadInfo =
static_cast<mozilla::LoadInfo*>(mLoadInfo.get())->Clone(); static_cast<mozilla::LoadInfo*>(mLoadInfo.get())->Clone();
// re-compute the origin attributes of the loadInfo if it's top-level load.
bool isTopLevelDoc =
newLoadInfo->GetExternalContentPolicyType() == nsIContentPolicy::TYPE_DOCUMENT;
if (isTopLevelDoc) {
nsCOMPtr<nsILoadContext> loadContext;
NS_QueryNotificationCallbacks(this, loadContext);
DocShellOriginAttributes docShellAttrs;
if (loadContext) {
loadContext->GetOriginAttributes(docShellAttrs);
}
MOZ_ASSERT(docShellAttrs.mFirstPartyDomain.IsEmpty(),
"top-level docshell shouldn't have firstPartyDomain attribute.");
NeckoOriginAttributes attrs = newLoadInfo->GetOriginAttributes();
MOZ_ASSERT(docShellAttrs.mAppId == attrs.mAppId,
"docshell and necko should have the same appId attribute.");
MOZ_ASSERT(docShellAttrs.mUserContextId == attrs.mUserContextId,
"docshell and necko should have the same userContextId attribute.");
MOZ_ASSERT(docShellAttrs.mInIsolatedMozBrowser == attrs.mInIsolatedMozBrowser,
"docshell and necko should have the same inIsolatedMozBrowser attribute.");
MOZ_ASSERT(docShellAttrs.mPrivateBrowsingId == attrs.mPrivateBrowsingId,
"docshell and necko should have the same privateBrowsingId attribute.");
attrs.InheritFromDocShellToNecko(docShellAttrs, true, newURI);
newLoadInfo->SetOriginAttributes(attrs);
}
bool isInternalRedirect = bool isInternalRedirect =
(redirectFlags & (nsIChannelEventSink::REDIRECT_INTERNAL | (redirectFlags & (nsIChannelEventSink::REDIRECT_INTERNAL |
nsIChannelEventSink::REDIRECT_STS_UPGRADE)); nsIChannelEventSink::REDIRECT_STS_UPGRADE));