Bug 1633851 - Part 5: Use AntiTrackingUtils::IsThirdPartyWindow/Channel() in ContentBlocking.cpp. r=baku
authorTim Huang <tihuang@mozilla.com>
Wed, 13 May 2020 13:39:17 +0000
changeset 529614 ecbd52188ae8f8dfb9a7d1aa3a5f564dc9ec6014
parent 529613 9b070149d2eea1ee0d53ab35f4f3e8d03814cdb5
child 529615 96b72a0c6b1947c4314b9a79ac7da49752921d89
push id37412
push usercbrindusan@mozilla.com
push dateWed, 13 May 2020 21:46:27 +0000
treeherdermozilla-central@ea102a496187 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1633851
milestone78.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 1633851 - Part 5: Use AntiTrackingUtils::IsThirdPartyWindow/Channel() in ContentBlocking.cpp. r=baku Differential Revision: https://phabricator.services.mozilla.com/D74725
toolkit/components/antitracking/ContentBlocking.cpp
--- a/toolkit/components/antitracking/ContentBlocking.cpp
+++ b/toolkit/components/antitracking/ContentBlocking.cpp
@@ -896,17 +896,17 @@ bool ContentBlocking::ShouldAllowAccessF
   // As a performance optimization, we only perform this check for
   // BEHAVIOR_REJECT_FOREIGN and BEHAVIOR_LIMIT_FOREIGN.  For
   // BEHAVIOR_REJECT_TRACKER and BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN,
   // third-partiness is implicily checked later below.
   if (behavior != nsICookieService::BEHAVIOR_REJECT_TRACKER &&
       behavior !=
           nsICookieService::BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN) {
     // Let's check if this is a 3rd party context.
-    if (!nsContentUtils::IsThirdPartyWindowOrChannel(aWindow, nullptr, aURI)) {
+    if (!AntiTrackingUtils::IsThirdPartyWindow(aWindow, aURI)) {
       LOG(("Our window isn't a third-party window"));
       return true;
     }
   }
 
   if ((behavior == nsICookieService::BEHAVIOR_REJECT_FOREIGN &&
        !CookieJarSettings::IsRejectThirdPartyWithExceptions(behavior)) ||
       behavior == nsICookieService::BEHAVIOR_LIMIT_FOREIGN) {
@@ -944,18 +944,17 @@ bool ContentBlocking::ShouldAllowAccessF
         blockedReason =
             nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER;
       }
     }
   } else if (behavior ==
              nsICookieService::BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN) {
     if (nsContentUtils::IsThirdPartyTrackingResourceWindow(aWindow)) {
       // fall through
-    } else if (nsContentUtils::IsThirdPartyWindowOrChannel(aWindow, nullptr,
-                                                           aURI)) {
+    } else if (AntiTrackingUtils::IsThirdPartyWindow(aWindow, aURI)) {
       LOG(("We're in the third-party context, storage should be partitioned"));
       // fall through, but remember that we're partitioning.
       blockedReason = nsIWebProgressListener::STATE_COOKIES_PARTITIONED_FOREIGN;
     } else {
       LOG(("Our window isn't a third-party window, storage is allowed"));
       return true;
     }
   } else {
@@ -1155,18 +1154,17 @@ bool ContentBlocking::ShouldAllowAccessF
             nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER;
       }
     }
   } else if (behavior ==
              nsICookieService::BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN) {
     if (classifiedChannel &&
         classifiedChannel->IsThirdPartyTrackingResource()) {
       // fall through
-    } else if (nsContentUtils::IsThirdPartyWindowOrChannel(nullptr, aChannel,
-                                                           aURI)) {
+    } else if (AntiTrackingUtils::IsThirdPartyChannel(aChannel)) {
       LOG(("We're in the third-party context, storage should be partitioned"));
       // fall through but remember that we're partitioning.
       blockedReason = nsIWebProgressListener::STATE_COOKIES_PARTITIONED_FOREIGN;
     } else {
       LOG(("Our channel isn't a third-party channel, storage is allowed"));
       return true;
     }
   } else {
@@ -1268,18 +1266,17 @@ bool ContentBlocking::ApproximateAllowAc
          parentDocument->CookieJarSettings()->GetCookieBehavior()));
     return true;
   }
 
   if (ContentBlockingAllowList::Check(aFirstPartyWindow)) {
     return true;
   }
 
-  if (!nsContentUtils::IsThirdPartyWindowOrChannel(aFirstPartyWindow, nullptr,
-                                                   aURI)) {
+  if (!AntiTrackingUtils::IsThirdPartyWindow(aFirstPartyWindow, aURI)) {
     LOG(("Our window isn't a third-party window"));
     return true;
   }
 
   uint32_t cookiePermission = CheckCookiePermissionForPrincipal(
       parentDocument->CookieJarSettings(), parentDocument->NodePrincipal());
   if (cookiePermission != nsICookiePermission::ACCESS_DEFAULT) {
     LOG(