зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1633401 - Make Document.HasStorageAccess fission compatible. r=baku
In Document::HasStorageAccess(), we try to get the top-level document. To check if the document is first-party to the top-level document. But, this won't work for Fission since the top-level document could be out-of-process. In this patch, we use broswing context to get the top-level principal to test if the document is thrid-party. If we cannot get the top-level outer window, the top-level document should be cross-origin. So, we know the answer. If the top-level document is available, we check the principal to see if the document is first-party. Differential Revision: https://phabricator.services.mozilla.com/D72664
This commit is contained in:
Родитель
3b565f53c5
Коммит
d07646ca8c
|
@ -15578,14 +15578,22 @@ already_AddRefed<mozilla::dom::Promise> Document::HasStorageAccess(
|
|||
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();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
nsPIDOMWindowInner* inner = GetInnerWindow();
|
||||
|
|
Загрузка…
Ссылка в новой задаче