Bug 1510909 - Bypass calling nsContentUtils::IsThirdPartyWindowOrChannel() for BEHAVIOR_REJECT_TRACKER r=baku
☠☠ backed out by 66f69c1eb0c2 ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 30 Nov 2018 11:23:46 +0000
changeset 505396 481a655f835e07fa9e533ba27b92d10ed784f11c
parent 505395 1f77d2e610e24d08d28411c919829fe7d566777e
child 505397 75c7af226bcfdeda647e2637064c9792d72af1ac
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1510909
milestone65.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 1510909 - Bypass calling nsContentUtils::IsThirdPartyWindowOrChannel() for BEHAVIOR_REJECT_TRACKER r=baku Calling this function is just a waste of time since we will check third-partiness a few statements further down. Differential Revision: https://phabricator.services.mozilla.com/D13500
toolkit/components/antitracking/AntiTrackingCommon.cpp
--- a/toolkit/components/antitracking/AntiTrackingCommon.cpp
+++ b/toolkit/components/antitracking/AntiTrackingCommon.cpp
@@ -880,20 +880,25 @@ bool AntiTrackingCommon::IsFirstPartySto
   }
 
   if (behavior == nsICookieService::BEHAVIOR_REJECT) {
     LOG(("The cookie behavior pref mandates rejecting all cookies!"));
     *aRejectedReason = nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL;
     return false;
   }
 
-  // Let's check if this is a 3rd party context.
-  if (!nsContentUtils::IsThirdPartyWindowOrChannel(aWindow, nullptr, aURI)) {
-    LOG(("Our window isn't a third-party window"));
-    return true;
+  // As a performance optimization, we only perform this check for
+  // BEHAVIOR_REJECT_FOREIGN and BEHAVIOR_LIMIT_FOREIGN.  For
+  // BEHAVIOR_REJECT_TRACKER, third-partiness is implicily checked later below.
+  if (behavior != nsICookieService::BEHAVIOR_REJECT_TRACKER) {
+    // Let's check if this is a 3rd party context.
+    if (!nsContentUtils::IsThirdPartyWindowOrChannel(aWindow, nullptr, aURI)) {
+      LOG(("Our window isn't a third-party window"));
+      return true;
+    }
   }
 
   if (behavior == nsICookieService::BEHAVIOR_REJECT_FOREIGN ||
       behavior == nsICookieService::BEHAVIOR_LIMIT_FOREIGN) {
     // XXX For non-cookie forms of storage, we handle BEHAVIOR_LIMIT_FOREIGN by
     // simply rejecting the request to use the storage. In the future, if we
     // change the meaning of BEHAVIOR_LIMIT_FOREIGN to be one which makes sense
     // for non-cookie storage types, this may change.
@@ -904,16 +909,19 @@ bool AntiTrackingCommon::IsFirstPartySto
 
   MOZ_ASSERT(behavior == nsICookieService::BEHAVIOR_REJECT_TRACKER);
 
   if (!nsContentUtils::IsThirdPartyTrackingResourceWindow(aWindow)) {
     LOG(("Our window isn't a third-party tracking window"));
     return true;
   }
 
+  MOZ_ASSERT(
+      !nsContentUtils::IsThirdPartyWindowOrChannel(aWindow, nullptr, aURI));
+
   nsCOMPtr<nsIPrincipal> parentPrincipal;
   nsCOMPtr<nsIURI> parentPrincipalURI;
   nsCOMPtr<nsIURI> trackingURI;
   nsAutoCString trackingOrigin;
   if (!GetParentPrincipalAndTrackingOrigin(
           nsGlobalWindowInner::Cast(aWindow), getter_AddRefs(parentPrincipal),
           trackingOrigin, getter_AddRefs(trackingURI), nullptr)) {
     LOG(("Failed to obtain the parent principal and the tracking origin"));