Bug 1623268 - P2. Refine the logic of third-party checks in ContentBlocking::AllowAccessFor r=timhuang,baku

This patch doesn't change the current behavior.
The intention is to make this code section easier to understand.

Differential Revision: https://phabricator.services.mozilla.com/D67282

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dimi Lee 2020-03-26 15:12:02 +00:00
Родитель 3cd786fb66
Коммит 738efb7aa6
1 изменённых файлов: 10 добавлений и 17 удалений

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

@ -383,24 +383,17 @@ ContentBlocking::AllowAccessFor(
} else {
// We should be a 3rd party source.
bool isThirdParty = false;
if (behavior == nsICookieService::BEHAVIOR_REJECT_TRACKER) {
isThirdParty =
nsContentUtils::IsThirdPartyTrackingResourceWindow(parentWindow);
} else if (behavior == nsICookieService::
BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN) {
isThirdParty = nsContentUtils::IsThirdPartyWindowOrChannel(
parentWindow, nullptr, nullptr);
}
if (!isThirdParty) {
if (behavior == nsICookieService::BEHAVIOR_REJECT_TRACKER) {
// Make sure we are either a third-party tracker or a third-party
// window (depends upon the cookie bahavior).
if (behavior == nsICookieService::BEHAVIOR_REJECT_TRACKER &&
!nsContentUtils::IsThirdPartyTrackingResourceWindow(parentWindow)) {
LOG(("Our window isn't a third-party tracking window"));
} else if (behavior ==
nsICookieService::
BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN) {
return StorageAccessGrantPromise::CreateAndReject(false, __func__);
} else if (behavior == nsICookieService::
BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN &&
!nsContentUtils::IsThirdPartyWindowOrChannel(parentWindow,
nullptr, nullptr)) {
LOG(("Our window isn't a third-party window"));
}
return StorageAccessGrantPromise::CreateAndReject(false, __func__);
}