Bug 1626404: Part 2a - Store source BrowsingContext rather than DocShell in LoadState. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D69418
This commit is contained in:
@@ -4045,7 +4045,7 @@ nsresult nsDocShell::LoadErrorPage(nsIURI* aErrorURI, nsIURI* aFailedURI,
|
|||||||
loadState->SetTriggeringPrincipal(nsContentUtils::GetSystemPrincipal());
|
loadState->SetTriggeringPrincipal(nsContentUtils::GetSystemPrincipal());
|
||||||
loadState->SetLoadType(LOAD_ERROR_PAGE);
|
loadState->SetLoadType(LOAD_ERROR_PAGE);
|
||||||
loadState->SetFirstParty(true);
|
loadState->SetFirstParty(true);
|
||||||
loadState->SetSourceDocShell(this);
|
loadState->SetSourceBrowsingContext(mBrowsingContext);
|
||||||
|
|
||||||
return InternalLoad(loadState, nullptr, nullptr);
|
return InternalLoad(loadState, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
@@ -4148,7 +4148,7 @@ nsDocShell::Reload(uint32_t aReloadFlags) {
|
|||||||
loadState->SetLoadType(loadType);
|
loadState->SetLoadType(loadType);
|
||||||
loadState->SetFirstParty(true);
|
loadState->SetFirstParty(true);
|
||||||
loadState->SetSrcdocData(srcdoc);
|
loadState->SetSrcdocData(srcdoc);
|
||||||
loadState->SetSourceDocShell(this);
|
loadState->SetSourceBrowsingContext(mBrowsingContext);
|
||||||
loadState->SetBaseURI(baseURI);
|
loadState->SetBaseURI(baseURI);
|
||||||
rv = InternalLoad(loadState, nullptr, nullptr);
|
rv = InternalLoad(loadState, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
@@ -8793,9 +8793,9 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
|
|||||||
|
|
||||||
// If a source docshell has been passed, check to see if we are sandboxed
|
// If a source docshell has been passed, check to see if we are sandboxed
|
||||||
// from it as the result of an iframe or CSP sandbox.
|
// from it as the result of an iframe or CSP sandbox.
|
||||||
if (aLoadState->SourceDocShell() &&
|
const auto& sourceBC = aLoadState->SourceBrowsingContext();
|
||||||
aLoadState->SourceDocShell()->GetBrowsingContext()->IsSandboxedFrom(
|
if (sourceBC.IsDiscarded() ||
|
||||||
mBrowsingContext)) {
|
(sourceBC && sourceBC->IsSandboxedFrom(mBrowsingContext))) {
|
||||||
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12358,7 +12358,7 @@ nsresult nsDocShell::OnLinkClickSync(
|
|||||||
loadState->SetHeadersStream(aHeadersDataStream);
|
loadState->SetHeadersStream(aHeadersDataStream);
|
||||||
loadState->SetLoadType(loadType);
|
loadState->SetLoadType(loadType);
|
||||||
loadState->SetFirstParty(true);
|
loadState->SetFirstParty(true);
|
||||||
loadState->SetSourceDocShell(this);
|
loadState->SetSourceBrowsingContext(mBrowsingContext);
|
||||||
loadState->SetIsFormSubmission(aContent->IsHTMLElement(nsGkAtoms::form));
|
loadState->SetIsFormSubmission(aContent->IsHTMLElement(nsGkAtoms::form));
|
||||||
nsresult rv = InternalLoad(loadState, aDocShell, aRequest);
|
nsresult rv = InternalLoad(loadState, aDocShell, aRequest);
|
||||||
|
|
||||||
|
|||||||
@@ -421,12 +421,9 @@ void nsDocShellLoadState::SetSrcdocData(const nsAString& aSrcdocData) {
|
|||||||
mSrcdocData = aSrcdocData;
|
mSrcdocData = aSrcdocData;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIDocShell* nsDocShellLoadState::SourceDocShell() const {
|
void nsDocShellLoadState::SetSourceBrowsingContext(
|
||||||
return mSourceDocShell;
|
BrowsingContext* aSourceBrowsingContext) {
|
||||||
}
|
mSourceBrowsingContext = aSourceBrowsingContext;
|
||||||
|
|
||||||
void nsDocShellLoadState::SetSourceDocShell(nsIDocShell* aSourceDocShell) {
|
|
||||||
mSourceDocShell = aSourceDocShell;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIURI* nsDocShellLoadState::BaseURI() const { return mBaseURI; }
|
nsIURI* nsDocShellLoadState::BaseURI() const { return mBaseURI; }
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ class DocShellLoadStateInit;
|
|||||||
* call.
|
* call.
|
||||||
*/
|
*/
|
||||||
class nsDocShellLoadState final {
|
class nsDocShellLoadState final {
|
||||||
|
using BrowsingContext = mozilla::dom::BrowsingContext;
|
||||||
|
template <typename T>
|
||||||
|
using MaybeDiscarded = mozilla::dom::MaybeDiscarded<T>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NS_INLINE_DECL_REFCOUNTING(nsDocShellLoadState);
|
NS_INLINE_DECL_REFCOUNTING(nsDocShellLoadState);
|
||||||
|
|
||||||
@@ -140,9 +144,11 @@ class nsDocShellLoadState final {
|
|||||||
|
|
||||||
void SetSrcdocData(const nsAString& aSrcdocData);
|
void SetSrcdocData(const nsAString& aSrcdocData);
|
||||||
|
|
||||||
nsIDocShell* SourceDocShell() const;
|
const MaybeDiscarded<BrowsingContext>& SourceBrowsingContext() const {
|
||||||
|
return mSourceBrowsingContext;
|
||||||
|
}
|
||||||
|
|
||||||
void SetSourceDocShell(nsIDocShell* aSourceDocShell);
|
void SetSourceBrowsingContext(BrowsingContext* aSourceBrowsingContext);
|
||||||
|
|
||||||
nsIURI* BaseURI() const;
|
nsIURI* BaseURI() const;
|
||||||
|
|
||||||
@@ -337,7 +343,7 @@ class nsDocShellLoadState final {
|
|||||||
nsString mSrcdocData;
|
nsString mSrcdocData;
|
||||||
|
|
||||||
// When set, this is the Source Browsing Context for the navigation.
|
// When set, this is the Source Browsing Context for the navigation.
|
||||||
nsCOMPtr<nsIDocShell> mSourceDocShell;
|
MaybeDiscarded<BrowsingContext> mSourceBrowsingContext;
|
||||||
|
|
||||||
// Used for srcdoc loads to give view-source knowledge of the load's base URI
|
// Used for srcdoc loads to give view-source knowledge of the load's base URI
|
||||||
// as this information isn't embedded in the load's URI.
|
// as this information isn't embedded in the load's URI.
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ void LocationBase::SetURI(nsIURI* aURI, nsIPrincipal& aSubjectPrincipal,
|
|||||||
RefPtr<BrowsingContext> accessingBC;
|
RefPtr<BrowsingContext> accessingBC;
|
||||||
if (sourceWindow) {
|
if (sourceWindow) {
|
||||||
accessingBC = sourceWindow->GetBrowsingContext();
|
accessingBC = sourceWindow->GetBrowsingContext();
|
||||||
loadState->SetSourceDocShell(sourceWindow->GetDocShell());
|
loadState->SetSourceBrowsingContext(sourceWindow->GetBrowsingContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
loadState->SetLoadFlags(nsIWebNavigation::LOAD_FLAGS_NONE);
|
loadState->SetLoadFlags(nsIWebNavigation::LOAD_FLAGS_NONE);
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ RefPtr<ClientOpPromise> ClientNavigateOpChild::DoNavigate(
|
|||||||
|
|
||||||
loadState->SetReferrerInfo(referrerInfo);
|
loadState->SetReferrerInfo(referrerInfo);
|
||||||
loadState->SetLoadType(LOAD_STOP_CONTENT);
|
loadState->SetLoadType(LOAD_STOP_CONTENT);
|
||||||
loadState->SetSourceDocShell(docShell);
|
loadState->SetSourceBrowsingContext(docShell->GetBrowsingContext());
|
||||||
loadState->SetLoadFlags(nsIWebNavigation::LOAD_FLAGS_NONE);
|
loadState->SetLoadFlags(nsIWebNavigation::LOAD_FLAGS_NONE);
|
||||||
loadState->SetFirstParty(true);
|
loadState->SetFirstParty(true);
|
||||||
rv = docShell->LoadURI(loadState, false);
|
rv = docShell->LoadURI(loadState, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user