зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1616171 - P2: nsILoadInfo::targetBrowsingContext attribute. r=mattwoodrow,nika
This new attribute on nsILoadInfo allows retrieving the BrowsingContext and BrowsingContextId for the BC of the document to be loaded by an nsILoadInfo. Differential Revision: https://phabricator.services.mozilla.com/D63127 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
8b1ffac083
Коммит
89e79e2d97
|
@ -2624,15 +2624,10 @@ var SessionStoreInternal = {
|
|||
}
|
||||
|
||||
// Check that the document has a corresponding BrowsingContext.
|
||||
let browsingContext;
|
||||
let isSubframe = false;
|
||||
let cp = channel.loadInfo.externalContentPolicyType;
|
||||
if (cp == Ci.nsIContentPolicy.TYPE_DOCUMENT) {
|
||||
browsingContext = channel.loadInfo.browsingContext;
|
||||
} else {
|
||||
browsingContext = channel.loadInfo.frameBrowsingContext;
|
||||
isSubframe = true;
|
||||
}
|
||||
let browsingContext = channel.loadInfo.targetBrowsingContext;
|
||||
let isSubframe =
|
||||
channel.loadInfo.externalContentPolicyType !=
|
||||
Ci.nsIContentPolicy.TYPE_DOCUMENT;
|
||||
|
||||
if (!browsingContext) {
|
||||
debug(`[process-switch]: no BrowsingContext - ignoring`);
|
||||
|
@ -2648,7 +2643,7 @@ var SessionStoreInternal = {
|
|||
|
||||
let topDocShell = topBC.embedderElement.ownerGlobal.docShell;
|
||||
let { useRemoteSubframes } = topDocShell.QueryInterface(Ci.nsILoadContext);
|
||||
if (!useRemoteSubframes && cp != Ci.nsIContentPolicy.TYPE_DOCUMENT) {
|
||||
if (!useRemoteSubframes && isSubframe) {
|
||||
debug(`[process-switch]: remote subframes disabled - ignoring`);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1055,6 +1055,14 @@ LoadInfo::GetFrameBrowsingContextID(uint64_t* aResult) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetTargetBrowsingContextID(uint64_t* aResult) {
|
||||
return (nsILoadInfo::GetExternalContentPolicyType() ==
|
||||
nsIContentPolicy::TYPE_SUBDOCUMENT)
|
||||
? GetFrameBrowsingContextID(aResult)
|
||||
: GetBrowsingContextID(aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetBrowsingContext(dom::BrowsingContext** aResult) {
|
||||
*aResult = BrowsingContext::Get(mBrowsingContextID).take();
|
||||
|
@ -1067,6 +1075,14 @@ LoadInfo::GetFrameBrowsingContext(dom::BrowsingContext** aResult) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetTargetBrowsingContext(dom::BrowsingContext** aResult) {
|
||||
uint64_t targetBrowsingContextID = 0;
|
||||
MOZ_ALWAYS_SUCCEEDS(GetTargetBrowsingContextID(&targetBrowsingContextID));
|
||||
*aResult = BrowsingContext::Get(targetBrowsingContextID).take();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetScriptableOriginAttributes(
|
||||
JSContext* aCx, JS::MutableHandle<JS::Value> aOriginAttributes) {
|
||||
|
|
|
@ -662,6 +662,15 @@ interface nsILoadInfo : nsISupports
|
|||
[infallible] readonly attribute unsigned long long frameBrowsingContextID;
|
||||
readonly attribute BrowsingContext frameBrowsingContext;
|
||||
|
||||
/**
|
||||
* If the element being loaded is a nsFrameLoaderOwner,
|
||||
* `targetBrowsingContext` is the Browsing Context which will contain the
|
||||
* loading document (see `frameBrowsingContext`). Otherwise, it is the
|
||||
* Browsing Context performing the load (see `browsingContext`).
|
||||
*/
|
||||
[infallible] readonly attribute unsigned long long targetBrowsingContextID;
|
||||
readonly attribute BrowsingContext targetBrowsingContext;
|
||||
|
||||
/**
|
||||
* Resets the PrincipalToInherit to a freshly created NullPrincipal
|
||||
* which inherits the origin attributes from the loadInfo.
|
||||
|
|
|
@ -2687,14 +2687,15 @@ void nsHttpChannel::AssertNotDocumentChannel() {
|
|||
return;
|
||||
}
|
||||
|
||||
nsContentPolicyType contentPolicy;
|
||||
MOZ_ALWAYS_SUCCEEDS(mLoadInfo->GetExternalContentPolicyType(&contentPolicy));
|
||||
RefPtr<BrowsingContext> bc;
|
||||
if (contentPolicy == CSPService::TYPE_DOCUMENT) {
|
||||
MOZ_ALWAYS_SUCCEEDS(mLoadInfo->GetBrowsingContext(getter_AddRefs(bc)));
|
||||
} else {
|
||||
MOZ_ALWAYS_SUCCEEDS(mLoadInfo->GetFrameBrowsingContext(getter_AddRefs(bc)));
|
||||
auto contentPolicy = mLoadInfo->GetExternalContentPolicyType();
|
||||
if (contentPolicy != nsIContentPolicy::TYPE_DOCUMENT &&
|
||||
contentPolicy != nsIContentPolicy::TYPE_SUBDOCUMENT) {
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<BrowsingContext> bc;
|
||||
MOZ_ALWAYS_SUCCEEDS(mLoadInfo->GetTargetBrowsingContext(getter_AddRefs(bc)));
|
||||
MOZ_ASSERT(bc); // It shouldn't be possible.
|
||||
if (!bc) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -37,8 +37,7 @@ amContentHandler.prototype = {
|
|||
|
||||
let { loadInfo } = aRequest;
|
||||
const { triggeringPrincipal } = loadInfo;
|
||||
let browsingContext =
|
||||
loadInfo.frameBrowsingContext || loadInfo.browsingContext;
|
||||
let browsingContext = loadInfo.targetBrowsingContext;
|
||||
|
||||
let sourceHost;
|
||||
let sourceURL;
|
||||
|
|
Загрузка…
Ссылка в новой задаче