зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1848783, part 2 - Reorder checks in CheckCallingContextDecidesStorageAccessAPI - r=anti-tracking-reviewers,timhuang
Also, remove a too-early check for third-partyness from StorageAccessAPIHelper::CheckBrowserSettingsDecidesStorageAccessAPI- that gets checked later anyway and should not override an inactive document Differential Revision: https://phabricator.services.mozilla.com/D186983
This commit is contained in:
Родитель
f827c60a57
Коммит
57e314ac6e
|
@ -822,9 +822,6 @@ Maybe<bool> StorageAccessAPIHelper::CheckBrowserSettingsDecidesStorageAccessAPI(
|
|||
}
|
||||
return Nothing();
|
||||
case nsICookieService::BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN:
|
||||
if (!aThirdParty) {
|
||||
return Some(true);
|
||||
}
|
||||
if (aIsOnThirdPartySkipList) {
|
||||
return Some(true);
|
||||
}
|
||||
|
@ -841,10 +838,6 @@ Maybe<bool> StorageAccessAPIHelper::CheckCallingContextDecidesStorageAccessAPI(
|
|||
Document* aDocument, bool aRequestingStorageAccess) {
|
||||
MOZ_ASSERT(aDocument);
|
||||
|
||||
if (aDocument->IsTopLevelContentDocument()) {
|
||||
return Some(true);
|
||||
}
|
||||
|
||||
if (!aDocument->IsCurrentActiveDocument()) {
|
||||
return Some(false);
|
||||
}
|
||||
|
@ -869,31 +862,6 @@ Maybe<bool> StorageAccessAPIHelper::CheckCallingContextDecidesStorageAccessAPI(
|
|||
return Some(false);
|
||||
}
|
||||
|
||||
// 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, if the sub frame's origin differs from the main frame's
|
||||
// origin, they will be in different processes. We use IsInProcess()
|
||||
// check here to deterimine whether they have the same origin. In
|
||||
// non-fission mode, it is always in-process so we need to compare their
|
||||
// principals.
|
||||
if (bc->Top()->IsInProcess()) {
|
||||
nsCOMPtr<nsPIDOMWindowOuter> topOuter = bc->Top()->GetDOMWindow();
|
||||
if (!topOuter) {
|
||||
return Some(false);
|
||||
}
|
||||
nsCOMPtr<Document> topLevelDoc = topOuter->GetExtantDoc();
|
||||
if (!topLevelDoc) {
|
||||
return Some(false);
|
||||
}
|
||||
|
||||
if (topLevelDoc->NodePrincipal()->Equals(aDocument->NodePrincipal())) {
|
||||
return Some(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if NodePrincipal is not null
|
||||
if (!aDocument->NodePrincipal()) {
|
||||
return Some(false);
|
||||
|
@ -925,6 +893,14 @@ Maybe<bool> StorageAccessAPIHelper::CheckCallingContextDecidesStorageAccessAPI(
|
|||
return Some(false);
|
||||
}
|
||||
|
||||
if (!AntiTrackingUtils::IsThirdPartyDocument(aDocument)) {
|
||||
return Some(true);
|
||||
}
|
||||
|
||||
if (aDocument->IsTopLevelContentDocument()) {
|
||||
return Some(true);
|
||||
}
|
||||
|
||||
if (aRequestingStorageAccess) {
|
||||
if (aDocument->StorageAccessSandboxed()) {
|
||||
nsContentUtils::ReportToConsole(
|
||||
|
|
Загрузка…
Ссылка в новой задаче