Bug 1551601 - When performing a cross process redirect update the loadInfo to have the correct browsingContext r=nika
Differential Revision: https://phabricator.services.mozilla.com/D35839
This commit is contained in:
@@ -8301,19 +8301,22 @@ nsresult nsDocShell::CreateContentViewer(const nsACString& aContentType,
|
||||
|
||||
if (DocGroup::TryToLoadIframesInBackground()) {
|
||||
if ((!mContentViewer || GetDocument()->IsInitialDocument()) && IsFrame()) {
|
||||
// At this point, we know we just created a new iframe document based on the
|
||||
// response from the server, and we check if it's a cross-domain iframe
|
||||
// At this point, we know we just created a new iframe document based on
|
||||
// the response from the server, and we check if it's a cross-domain
|
||||
// iframe
|
||||
|
||||
RefPtr<Document> newDoc = viewer->GetDocument();
|
||||
|
||||
RefPtr<nsDocShell> parent = GetParentDocshell();
|
||||
nsCOMPtr<nsIPrincipal> parentPrincipal = parent->GetDocument()->NodePrincipal();
|
||||
nsCOMPtr<nsIPrincipal> parentPrincipal =
|
||||
parent->GetDocument()->NodePrincipal();
|
||||
nsCOMPtr<nsIPrincipal> thisPrincipal = newDoc->NodePrincipal();
|
||||
|
||||
SiteIdentifier parentSite;
|
||||
SiteIdentifier thisSite;
|
||||
|
||||
nsresult rv = BasePrincipal::Cast(parentPrincipal)->GetSiteIdentifier(parentSite);
|
||||
nsresult rv =
|
||||
BasePrincipal::Cast(parentPrincipal)->GetSiteIdentifier(parentSite);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = BasePrincipal::Cast(thisPrincipal)->GetSiteIdentifier(thisSite);
|
||||
@@ -8323,9 +8326,12 @@ nsresult nsDocShell::CreateContentViewer(const nsACString& aContentType,
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
nsCOMPtr<nsIURI> prinURI;
|
||||
thisPrincipal->GetURI(getter_AddRefs(prinURI));
|
||||
nsPrintfCString marker("Iframe loaded in background: %s", prinURI->GetSpecOrDefault().get());
|
||||
nsPrintfCString marker("Iframe loaded in background: %s",
|
||||
prinURI->GetSpecOrDefault().get());
|
||||
TimeStamp now = TimeStamp::Now();
|
||||
profiler_add_text_marker("Background Iframe", marker, JS::ProfilingCategoryPair::DOM, now, now, Nothing(), Nothing());
|
||||
profiler_add_text_marker("Background Iframe", marker,
|
||||
JS::ProfilingCategoryPair::DOM, now, now,
|
||||
Nothing(), Nothing());
|
||||
#endif
|
||||
SetBackgroundLoadIframe();
|
||||
}
|
||||
@@ -8335,9 +8341,9 @@ nsresult nsDocShell::CreateContentViewer(const nsACString& aContentType,
|
||||
NS_ENSURE_SUCCESS(Embed(viewer, "", nullptr), NS_ERROR_FAILURE);
|
||||
|
||||
if (TreatAsBackgroundLoad()) {
|
||||
nsCOMPtr<nsIRunnable> triggerParentCheckDocShell = NewRunnableMethod(
|
||||
"nsDocShell::TriggerParentCheckDocShellIsEmpty", this,
|
||||
&nsDocShell::TriggerParentCheckDocShellIsEmpty);
|
||||
nsCOMPtr<nsIRunnable> triggerParentCheckDocShell =
|
||||
NewRunnableMethod("nsDocShell::TriggerParentCheckDocShellIsEmpty", this,
|
||||
&nsDocShell::TriggerParentCheckDocShellIsEmpty);
|
||||
nsresult rv = NS_DispatchToCurrentThread(triggerParentCheckDocShell);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
@@ -10600,6 +10606,19 @@ nsresult nsDocShell::OpenInitializedChannel(nsIChannel* aChannel,
|
||||
|
||||
MaybeCreateInitialClientSource();
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo;
|
||||
aChannel->GetLoadInfo(getter_AddRefs(loadInfo));
|
||||
|
||||
LoadInfo* li = static_cast<LoadInfo*>(loadInfo.get());
|
||||
if (loadInfo->GetExternalContentPolicyType() ==
|
||||
nsIContentPolicy::TYPE_DOCUMENT) {
|
||||
li->UpdateBrowsingContextID(mBrowsingContext->Id());
|
||||
} else if (loadInfo->GetExternalContentPolicyType() ==
|
||||
nsIContentPolicy::TYPE_SUBDOCUMENT) {
|
||||
li->UpdateFrameBrowsingContextID(mBrowsingContext->Id());
|
||||
}
|
||||
// TODO: more attributes need to be updated on the LoadInfo (bug 1561706)
|
||||
|
||||
// Since we are loading a document we need to make sure the proper reserved
|
||||
// and initial client data is stored on the nsILoadInfo. The
|
||||
// ClientChannelHelper does this and ensures that it is propagated properly
|
||||
|
||||
Reference in New Issue
Block a user