Bug 1480923 - Part 1: Remove the centralized third-party checks from nsChannelClassifier::ShouldEnableTrackingProtectionInternal in annotation-only mode; r=francois
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 10 Aug 2018 19:42:21 -0400
changeset 486871 ecdc0137474760b86511b53627204d53e4aa320e
parent 486870 b747faf1093a44b7901d05478db24efe4f57830f
child 486872 174bb3e3138c56cef6073ed5ba6e40367a1803de
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfrancois
bugs1480923
milestone63.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 1480923 - Part 1: Remove the centralized third-party checks from nsChannelClassifier::ShouldEnableTrackingProtectionInternal in annotation-only mode; r=francois
netwerk/base/nsChannelClassifier.cpp
--- a/netwerk/base/nsChannelClassifier.cpp
+++ b/netwerk/base/nsChannelClassifier.cpp
@@ -388,38 +388,41 @@ nsChannelClassifier::ShouldEnableTrackin
     if (!topWinURI) {
       LOG(("nsChannelClassifier[%p]: No window URI\n", this));
     }
 
     nsCOMPtr<nsIURI> chanURI;
     rv = aChannel->GetURI(getter_AddRefs(chanURI));
     NS_ENSURE_SUCCESS(rv, rv);
 
-    // Third party checks don't work for chrome:// URIs in mochitests, so just
-    // default to isThirdParty = true. We check isThirdPartyWindow to expand
-    // the list of domains that are considered first party (e.g., if
-    // facebook.com includes an iframe from fatratgames.com, all subsources
-    // included in that iframe are considered third-party with
-    // isThirdPartyChannel, even if they are not third-party w.r.t.
-    // facebook.com), and isThirdPartyChannel to prevent top-level navigations
-    // from being detected as third-party.
-    bool isThirdPartyChannel = true;
-    bool isThirdPartyWindow = true;
-    thirdPartyUtil->IsThirdPartyURI(chanURI, topWinURI, &isThirdPartyWindow);
-    thirdPartyUtil->IsThirdPartyChannel(aChannel, nullptr, &isThirdPartyChannel);
-    if (!isThirdPartyWindow || !isThirdPartyChannel) {
-      *result = false;
-      if (LOG_ENABLED()) {
-        nsCString spec = chanURI->GetSpecOrDefault();
-        spec.Truncate(std::min(spec.Length(), sMaxSpecLength));
-        LOG(("nsChannelClassifier[%p]: Skipping tracking protection checks "
-             "for first party or top-level load channel[%p] with uri %s",
-             this, aChannel, spec.get()));
+    // Only perform third-party checks for tracking protection
+    if (!aAnnotationsOnly) {
+      // Third party checks don't work for chrome:// URIs in mochitests, so just
+      // default to isThirdParty = true. We check isThirdPartyWindow to expand
+      // the list of domains that are considered first party (e.g., if
+      // facebook.com includes an iframe from fatratgames.com, all subsources
+      // included in that iframe are considered third-party with
+      // isThirdPartyChannel, even if they are not third-party w.r.t.
+      // facebook.com), and isThirdPartyChannel to prevent top-level navigations
+      // from being detected as third-party.
+      bool isThirdPartyChannel = true;
+      bool isThirdPartyWindow = true;
+      thirdPartyUtil->IsThirdPartyURI(chanURI, topWinURI, &isThirdPartyWindow);
+      thirdPartyUtil->IsThirdPartyChannel(aChannel, nullptr, &isThirdPartyChannel);
+      if (!isThirdPartyWindow || !isThirdPartyChannel) {
+        *result = false;
+        if (LOG_ENABLED()) {
+          nsCString spec = chanURI->GetSpecOrDefault();
+          spec.Truncate(std::min(spec.Length(), sMaxSpecLength));
+          LOG(("nsChannelClassifier[%p]: Skipping tracking protection checks "
+               "for first party or top-level load channel[%p] with uri %s",
+               this, aChannel, spec.get()));
+        }
+        return NS_OK;
       }
-      return NS_OK;
     }
 
     if (AddonMayLoad(aChannel, chanURI)) {
         return NS_OK;
     }
 
     nsCOMPtr<nsIIOService> ios = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);