Bug 1547889 - Part 1: Port AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor() to the cookie settings API; r=baku
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 30 Apr 2019 14:27:34 +0000
changeset 530773 43a08bca736a41a74e9473dac7a8c468790fcd29
parent 530772 6e4905f79080c6f34ab82f74ea8c76fcda0bb9fc
child 530774 29f01b943d7fb3a16927b59606fae910896597a9
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1547889
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1547889 - Part 1: Port AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor() to the cookie settings API; r=baku Differential Revision: https://phabricator.services.mozilla.com/D29319
toolkit/components/antitracking/AntiTrackingCommon.cpp
--- a/toolkit/components/antitracking/AntiTrackingCommon.cpp
+++ b/toolkit/components/antitracking/AntiTrackingCommon.cpp
@@ -772,22 +772,27 @@ AntiTrackingCommon::AddFirstPartyStorage
   if (NS_WARN_IF(NS_FAILED(rv))) {
     LOG(("Can't get the origin from the URI"));
     return StorageAccessGrantPromise::CreateAndReject(false, __func__);
   }
 
   LOG(("Adding a first-party storage exception for %s...",
        PromiseFlatCString(origin).get()));
 
-  if (StaticPrefs::network_cookie_cookieBehavior() !=
-      nsICookieService::BEHAVIOR_REJECT_TRACKER) {
+  Document* parentDoc = aParentWindow->GetExtantDoc();
+  if (!parentDoc) {
+    LOG(("Parent window has no doc"));
+    return StorageAccessGrantPromise::CreateAndReject(false, __func__);
+  }
+  auto cookieBehavior = parentDoc->CookieSettings()->GetCookieBehavior();
+  if (cookieBehavior != nsICookieService::BEHAVIOR_REJECT_TRACKER) {
     LOG(
         ("Disabled by network.cookie.cookieBehavior pref (%d), bailing out "
          "early",
-         StaticPrefs::network_cookie_cookieBehavior()));
+         cookieBehavior));
     return StorageAccessGrantPromise::CreateAndResolve(true, __func__);
   }
 
   if (CheckContentBlockingAllowList(aParentWindow)) {
     return StorageAccessGrantPromise::CreateAndResolve(true, __func__);
   }
 
   nsCOMPtr<nsIPrincipal> topLevelStoragePrincipal;