Bug 1650257: Part 2 - Abort SetNewDocument() if ancestors are discarded/cached. r=nika,smaug,sg
Differential Revision: https://phabricator.services.mozilla.com/D87486
This commit is contained in:
@@ -770,6 +770,25 @@ bool BrowsingContext::HasOpener() const {
|
||||
return sBrowsingContexts->Contains(GetOpenerId());
|
||||
}
|
||||
|
||||
bool BrowsingContext::AncestorsAreCurrent() const {
|
||||
const BrowsingContext* bc = this;
|
||||
while (true) {
|
||||
if (bc->IsDiscarded()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (WindowContext* wc = bc->GetParentWindowContext()) {
|
||||
if (wc->IsCached() || wc->IsDiscarded()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bc = wc->GetBrowsingContext();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Span<RefPtr<BrowsingContext>> BrowsingContext::Children() const {
|
||||
if (WindowContext* current = mCurrentWindowContext) {
|
||||
return current->Children();
|
||||
@@ -1610,6 +1629,15 @@ void BrowsingContext::Location(JSContext* aCx,
|
||||
}
|
||||
}
|
||||
|
||||
bool BrowsingContext::RemoveRootFromBFCacheSync() {
|
||||
if (WindowContext* wc = GetParentWindowContext()) {
|
||||
if (RefPtr<Document> doc = wc->TopWindowContext()->GetDocument()) {
|
||||
return doc->RemoveFromBFCacheSync();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
nsresult BrowsingContext::CheckSandboxFlags(nsDocShellLoadState* aLoadState) {
|
||||
const auto& sourceBC = aLoadState->SourceBrowsingContext();
|
||||
if (sourceBC.IsDiscarded() || (sourceBC && sourceBC->IsSandboxedFrom(this))) {
|
||||
|
||||
Reference in New Issue
Block a user