Backed out changeset 09f0bd3285b9 (bug 1633401) for hasStorageAccess.sub.window.html failures CLOSED TREE

This commit is contained in:
Bogdan Tara 2020-04-29 16:07:13 +03:00
Родитель d014b03ba8
Коммит f734fa692f
1 изменённых файлов: 8 добавлений и 16 удалений

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

@ -15578,22 +15578,14 @@ already_AddRefed<mozilla::dom::Promise> Document::HasStorageAccess(
return promise.forget();
}
RefPtr<BrowsingContext> topBC = GetBrowsingContext()->Top();
// We check if the document is a first-party document here by testing if the
// top-level window is same-origin. In non-Fission mode, we can directly get
// the top-level window through the top browsing context since it should be
// in-process. And test their principals.
//
// In Fission mode, we can also directly get the top-level window. If we
// cannot get it, this means the top-level window is cross-origin. Then, we
// know our answer.
if (auto* topOuterWindow = topBC->GetDOMWindow()) {
if (nsGlobalWindowOuter::Cast(topOuterWindow)
->GetPrincipal()
->Equals(NodePrincipal())) {
promise->MaybeResolve(true);
return promise.forget();
}
nsCOMPtr<Document> topLevelDoc = GetTopLevelContentDocument();
if (!topLevelDoc) {
aRv.Throw(NS_ERROR_NOT_AVAILABLE);
return nullptr;
}
if (topLevelDoc->NodePrincipal()->Equals(NodePrincipal())) {
promise->MaybeResolve(true);
return promise.forget();
}
nsPIDOMWindowInner* inner = GetInnerWindow();