Bug 1522637 - Part 2: Include BrowsingContextID in LoadInfo for subdocument loads, r=valentin

Depends on D18602

Differential Revision: https://phabricator.services.mozilla.com/D18603

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nika Layzell 2019-02-15 19:49:04 +00:00
Родитель 0fc050a8b0
Коммит feecd3ed43
6 изменённых файлов: 41 добавлений и 8 удалений

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

@ -2323,13 +2323,17 @@ var SessionStoreInternal = {
return; // Not a document load.
}
let browsingContext = aChannel.loadInfo.browsingContext;
if (!browsingContext) {
return; // Not loading in a browsing context.
let cpType = aChannel.loadInfo.externalContentPolicyType;
let toplevel = cpType == Ci.nsIContentPolicy.TYPE_DOCUMENT;
if (!toplevel) {
return; // Not loading a toplevel document.
}
if (browsingContext.parent) {
return; // Not a toplevel load, can't flip procs.
let browsingContext = toplevel
? aChannel.loadInfo.browsingContext
: aChannel.loadInfo.frameBrowsingContext;
if (!browsingContext) {
return; // Not loading in a browsing context.
}
// Get principal for a document already loaded in the BrowsingContext.

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

@ -477,6 +477,7 @@ nsresult LoadInfoToLoadInfoArgs(nsILoadInfo* aLoadInfo,
aLoadInfo->GetInnerWindowID(), aLoadInfo->GetOuterWindowID(),
aLoadInfo->GetParentOuterWindowID(), aLoadInfo->GetTopOuterWindowID(),
aLoadInfo->GetFrameOuterWindowID(), aLoadInfo->GetBrowsingContextID(),
aLoadInfo->GetFrameBrowsingContextID(),
aLoadInfo->GetInitialSecurityCheckDone(),
aLoadInfo->GetIsInThirdPartyContext(), aLoadInfo->GetIsDocshellReload(),
aLoadInfo->GetSendCSPViolationEvents(), aLoadInfo->GetOriginAttributes(),
@ -634,7 +635,8 @@ nsresult LoadInfoArgsToLoadInfo(
loadInfoArgs.forceInheritPrincipalDropped(), loadInfoArgs.innerWindowID(),
loadInfoArgs.outerWindowID(), loadInfoArgs.parentOuterWindowID(),
loadInfoArgs.topOuterWindowID(), loadInfoArgs.frameOuterWindowID(),
loadInfoArgs.browsingContextID(), loadInfoArgs.initialSecurityCheckDone(),
loadInfoArgs.browsingContextID(), loadInfoArgs.frameBrowsingContextID(),
loadInfoArgs.initialSecurityCheckDone(),
loadInfoArgs.isInThirdPartyContext(), loadInfoArgs.isDocshellReload(),
loadInfoArgs.sendCSPViolationEvents(), loadInfoArgs.originAttributes(),
redirectChainIncludingInternalRedirects, redirectChain,

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

@ -80,6 +80,7 @@ LoadInfo::LoadInfo(
mTopOuterWindowID(0),
mFrameOuterWindowID(0),
mBrowsingContextID(0),
mFrameBrowsingContextID(0),
mInitialSecurityCheckDone(false),
mIsThirdPartyContext(false),
mIsDocshellReload(false),
@ -230,6 +231,9 @@ LoadInfo::LoadInfo(
nsCOMPtr<nsPIDOMWindowOuter> outerWindow = do_GetInterface(docShell);
if (outerWindow) {
mFrameOuterWindowID = outerWindow->WindowID();
RefPtr<dom::BrowsingContext> bc = outerWindow->GetBrowsingContext();
mFrameBrowsingContextID = bc ? bc->Id() : 0;
}
}
}
@ -362,6 +366,7 @@ LoadInfo::LoadInfo(nsPIDOMWindowOuter* aOuterWindow,
mTopOuterWindowID(0),
mFrameOuterWindowID(0),
mBrowsingContextID(0),
mFrameBrowsingContextID(0),
mInitialSecurityCheckDone(false),
mIsThirdPartyContext(false), // NB: TYPE_DOCUMENT implies !third-party.
mIsDocshellReload(false),
@ -500,7 +505,7 @@ LoadInfo::LoadInfo(
bool aForceInheritPrincipalDropped, uint64_t aInnerWindowID,
uint64_t aOuterWindowID, uint64_t aParentOuterWindowID,
uint64_t aTopOuterWindowID, uint64_t aFrameOuterWindowID,
uint64_t aBrowsingContextID,
uint64_t aBrowsingContextID, uint64_t aFrameBrowsingContextID,
bool aInitialSecurityCheckDone, bool aIsThirdPartyContext,
bool aIsDocshellReload, bool aSendCSPViolationEvents,
const OriginAttributes& aOriginAttributes,
@ -543,6 +548,7 @@ LoadInfo::LoadInfo(
mTopOuterWindowID(aTopOuterWindowID),
mFrameOuterWindowID(aFrameOuterWindowID),
mBrowsingContextID(aBrowsingContextID),
mFrameBrowsingContextID(aFrameBrowsingContextID),
mInitialSecurityCheckDone(aInitialSecurityCheckDone),
mIsThirdPartyContext(aIsThirdPartyContext),
mIsDocshellReload(aIsDocshellReload),
@ -993,12 +999,24 @@ LoadInfo::GetBrowsingContextID(uint64_t* aResult) {
return NS_OK;
}
NS_IMETHODIMP
LoadInfo::GetFrameBrowsingContextID(uint64_t* aResult) {
*aResult = mFrameBrowsingContextID;
return NS_OK;
}
NS_IMETHODIMP
LoadInfo::GetBrowsingContext(dom::BrowsingContext** aResult) {
*aResult = BrowsingContext::Get(mBrowsingContextID).take();
return NS_OK;
}
NS_IMETHODIMP
LoadInfo::GetFrameBrowsingContext(dom::BrowsingContext** aResult) {
*aResult = BrowsingContext::Get(mFrameBrowsingContextID).take();
return NS_OK;
}
NS_IMETHODIMP
LoadInfo::GetScriptableOriginAttributes(
JSContext* aCx, JS::MutableHandle<JS::Value> aOriginAttributes) {

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

@ -111,7 +111,7 @@ class LoadInfo final : public nsILoadInfo {
bool aForceInheritPrincipalDropped, uint64_t aInnerWindowID,
uint64_t aOuterWindowID, uint64_t aParentOuterWindowID,
uint64_t aTopOuterWindowID, uint64_t aFrameOuterWindowID,
uint64_t aBrowsingContextID,
uint64_t aBrowsingContextID, uint64_t aFrameBrowsingContextID,
bool aInitialSecurityCheckDone, bool aIsThirdPartyRequest,
bool aIsDocshellReload, bool aSendCSPViolationEvents,
const OriginAttributes& aOriginAttributes,
@ -184,6 +184,7 @@ class LoadInfo final : public nsILoadInfo {
uint64_t mTopOuterWindowID;
uint64_t mFrameOuterWindowID;
uint64_t mBrowsingContextID;
uint64_t mFrameBrowsingContextID;
bool mInitialSecurityCheckDone;
bool mIsThirdPartyContext;
bool mIsDocshellReload;

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

@ -634,6 +634,13 @@ interface nsILoadInfo : nsISupports
[infallible] readonly attribute unsigned long long browsingContextID;
readonly attribute BrowsingContext browsingContext;
/**
* Like `frameOuterWindowID`, however returning the BrowsingContextID
* instead.
*/
[infallible] readonly attribute unsigned long long frameBrowsingContextID;
readonly attribute BrowsingContext frameBrowsingContext;
/**
* Resets the PrincipalToInherit to a freshly created NullPrincipal
* which inherits the origin attributes from the loadInfo.

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

@ -64,6 +64,7 @@ struct LoadInfoArgs
uint64_t topOuterWindowID;
uint64_t frameOuterWindowID;
uint64_t browsingContextID;
uint64_t frameBrowsingContextID;
bool initialSecurityCheckDone;
bool isInThirdPartyContext;
bool isDocshellReload;