Bug 1486092 - Part 2: Make the reject tracker cookie behavior also depend on the browser.contentblocking.enabled pref; r=baku

The semantics implemented are as follows: the feature requires this new
pref to also be set to true, otherwise cookies from trackers will be
accepted.
This commit is contained in:
Ehsan Akhgari 2018-08-24 18:54:10 -04:00
parent 2d62042b5c
commit 363e542f6e
3 changed files with 32 additions and 3 deletions

View file

@ -12653,7 +12653,8 @@ void
nsIDocument::MaybeAllowStorageForOpener()
{
if (StaticPrefs::network_cookie_cookieBehavior() !=
nsICookieService::BEHAVIOR_REJECT_TRACKER) {
nsICookieService::BEHAVIOR_REJECT_TRACKER ||
!StaticPrefs::browser_contentblocking_enabled()) {
return;
}

View file

@ -2271,7 +2271,8 @@ RuntimeService::PropagateFirstPartyStorageAccessGranted(nsPIDOMWindowInner* aWin
AssertIsOnMainThread();
MOZ_ASSERT(aWindow);
MOZ_ASSERT(StaticPrefs::network_cookie_cookieBehavior() ==
nsICookieService::BEHAVIOR_REJECT_TRACKER);
nsICookieService::BEHAVIOR_REJECT_TRACKER &&
StaticPrefs::browser_contentblocking_enabled());
nsTArray<WorkerPrivate*> workers;
GetWorkersForWindow(aWindow, workers);
@ -2885,7 +2886,8 @@ PropagateFirstPartyStorageAccessGrantedToWorkers(nsPIDOMWindowInner* aWindow)
{
AssertIsOnMainThread();
MOZ_ASSERT(StaticPrefs::network_cookie_cookieBehavior() ==
nsICookieService::BEHAVIOR_REJECT_TRACKER);
nsICookieService::BEHAVIOR_REJECT_TRACKER &&
StaticPrefs::browser_contentblocking_enabled());
RuntimeService* runtime = RuntimeService::GetService();
if (runtime) {

View file

@ -150,6 +150,11 @@ AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(const nsAString& aOrigi
return StorageAccessGrantPromise::CreateAndResolve(true, __func__);
}
if (!StaticPrefs::browser_contentblocking_enabled()) {
LOG(("The content blocking pref has been disabled, bail out early"));
return StorageAccessGrantPromise::CreateAndResolve(true, __func__);
}
nsCOMPtr<nsIPrincipal> topLevelStoragePrincipal;
nsAutoCString trackingOrigin;
@ -324,6 +329,14 @@ AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(nsPIDOMWindowInner* aWin
}
MOZ_ASSERT(behavior == nsICookieService::BEHAVIOR_REJECT_TRACKER);
// Now, we have to also honour the Content Blocking pref.
if (!StaticPrefs::browser_contentblocking_enabled()) {
LOG(("The content blocking pref has been disabled, bail out early by "
"by pretending our window isn't a tracking window"));
return true;
}
if (!nsContentUtils::IsTrackingResourceWindow(aWindow)) {
LOG(("Our window isn't a tracking window"));
return true;
@ -484,6 +497,13 @@ AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(nsIHttpChannel* aChannel
MOZ_ASSERT(behavior == nsICookieService::BEHAVIOR_REJECT_TRACKER);
// Now, we have to also honour the Content Blocking pref.
if (!StaticPrefs::browser_contentblocking_enabled()) {
LOG(("The content blocking pref has been disabled, bail out early by "
"pretending our channel isn't a tracking channel"));
return true;
}
nsIPrincipal* parentPrincipal = loadInfo->TopLevelStorageAreaPrincipal();
if (!parentPrincipal) {
LOG(("No top-level storage area principal at hand"));
@ -591,6 +611,12 @@ AntiTrackingCommon::MaybeIsFirstPartyStorageAccessGrantedFor(nsPIDOMWindowInner*
return true;
}
// Now, we have to also honour the Content Blocking pref.
if (!StaticPrefs::browser_contentblocking_enabled()) {
LOG(("The content blocking pref has been disabled, bail out early"));
return true;
}
if (!nsContentUtils::IsThirdPartyWindowOrChannel(aFirstPartyWindow,
nullptr, aURI)) {
LOG(("Our window isn't a third-party window"));