From cb161b6b55a25bbf36c6c3632ecb0deb7f2154b0 Mon Sep 17 00:00:00 2001 From: Razvan Maries Date: Thu, 9 Jul 2020 15:53:12 +0300 Subject: [PATCH] Backed out 2 changesets (bug 1447935) for perma failures on test_headless.js. CLOSED TREE Backed out changeset 0332d1b01f63 (bug 1447935) Backed out changeset bcf6ab4e4f50 (bug 1447935) --- .../url-classifier/UrlClassifierCommon.cpp | 12 +------ ...lassifierFeatureCryptominingProtection.cpp | 34 +++++++++++-------- ...ssifierFeatureFingerprintingProtection.cpp | 33 ++++++++++-------- ...ssifierFeatureSocialTrackingProtection.cpp | 34 +++++++++++-------- ...UrlClassifierFeatureTrackingProtection.cpp | 32 +++++++++-------- 5 files changed, 75 insertions(+), 70 deletions(-) diff --git a/netwerk/url-classifier/UrlClassifierCommon.cpp b/netwerk/url-classifier/UrlClassifierCommon.cpp index cc4e485d5202..c0eee57cbeb7 100644 --- a/netwerk/url-classifier/UrlClassifierCommon.cpp +++ b/netwerk/url-classifier/UrlClassifierCommon.cpp @@ -342,16 +342,6 @@ nsresult UrlClassifierCommon::CreatePairwiseEntityListURI(nsIChannel* aChannel, } } } - - if (!topWinURI) { - UC_LOG( - ("CreatePairwiseWhiteListURI: No top-level window associated with " - "channel, get URI from loading principal instead")); - nsCOMPtr principal = loadInfo->GetLoadingPrincipal(); - auto* basePrin = BasePrincipal::Cast(principal); - rv = basePrin->GetURI(getter_AddRefs(topWinURI)); - Unused << NS_WARN_IF(NS_FAILED(rv)); - } } if (!topWinURI) { @@ -364,7 +354,7 @@ nsresult UrlClassifierCommon::CreatePairwiseEntityListURI(nsIChannel* aChannel, uri->GetAsciiSpec(spec); spec.Truncate( std::min(spec.Length(), UrlClassifierCommon::sMaxSpecLength)); - UC_LOG(("CreatePairwiseEntityListURI: No top-level URI associated with %s", + UC_LOG(("CreatePairwiseEntityListURI: No window URI associated with %s", spec.get())); } diff --git a/netwerk/url-classifier/UrlClassifierFeatureCryptominingProtection.cpp b/netwerk/url-classifier/UrlClassifierFeatureCryptominingProtection.cpp index f792cb2e3574..f8c15ae72848 100644 --- a/netwerk/url-classifier/UrlClassifierFeatureCryptominingProtection.cpp +++ b/netwerk/url-classifier/UrlClassifierFeatureCryptominingProtection.cpp @@ -6,10 +6,10 @@ #include "UrlClassifierFeatureCryptominingProtection.h" -#include "mozilla/AntiTrackingUtils.h" #include "mozilla/net/UrlClassifierCommon.h" #include "ChannelClassifierService.h" #include "mozilla/StaticPrefs_privacy.h" +#include "nsContentUtils.h" #include "nsNetUtil.h" namespace mozilla { @@ -87,23 +87,27 @@ UrlClassifierFeatureCryptominingProtection::MaybeCreate(nsIChannel* aChannel) { return nullptr; } - bool isThirdParty = AntiTrackingUtils::IsThirdPartyChannel(aChannel); + nsCOMPtr chanURI; + nsresult rv = aChannel->GetURI(getter_AddRefs(chanURI)); + if (NS_WARN_IF(NS_FAILED(rv))) { + return nullptr; + } + + bool isThirdParty = + nsContentUtils::IsThirdPartyWindowOrChannel(nullptr, aChannel, chanURI); if (!isThirdParty) { if (UC_LOG_ENABLED()) { - nsCOMPtr chanURI; - Unused << aChannel->GetURI(getter_AddRefs(chanURI)); - if (chanURI) { - nsCString spec = chanURI->GetSpecOrDefault(); - spec.Truncate( - std::min(spec.Length(), UrlClassifierCommon::sMaxSpecLength)); - UC_LOG( - ("UrlClassifierFeatureCryptominingProtection: Skipping cryptomining " - "checks " - "for first party or top-level load channel[%p] " - "with uri %s", - aChannel, spec.get())); - } + nsCString spec = chanURI->GetSpecOrDefault(); + spec.Truncate( + std::min(spec.Length(), UrlClassifierCommon::sMaxSpecLength)); + UC_LOG( + ("UrlClassifierFeatureCryptominingProtection: Skipping cryptomining " + "checks " + "for first party or top-level load channel[%p] " + "with uri %s", + aChannel, spec.get())); } + return nullptr; } diff --git a/netwerk/url-classifier/UrlClassifierFeatureFingerprintingProtection.cpp b/netwerk/url-classifier/UrlClassifierFeatureFingerprintingProtection.cpp index 469d0e10288c..c64b48ad658d 100644 --- a/netwerk/url-classifier/UrlClassifierFeatureFingerprintingProtection.cpp +++ b/netwerk/url-classifier/UrlClassifierFeatureFingerprintingProtection.cpp @@ -6,10 +6,10 @@ #include "UrlClassifierFeatureFingerprintingProtection.h" -#include "mozilla/AntiTrackingUtils.h" #include "mozilla/net/UrlClassifierCommon.h" #include "ChannelClassifierService.h" #include "mozilla/StaticPrefs_privacy.h" +#include "nsContentUtils.h" #include "nsNetUtil.h" namespace mozilla { @@ -90,22 +90,25 @@ UrlClassifierFeatureFingerprintingProtection::MaybeCreate( return nullptr; } - bool isThirdParty = AntiTrackingUtils::IsThirdPartyChannel(aChannel); + nsCOMPtr chanURI; + nsresult rv = aChannel->GetURI(getter_AddRefs(chanURI)); + if (NS_WARN_IF(NS_FAILED(rv))) { + return nullptr; + } + + bool isThirdParty = + nsContentUtils::IsThirdPartyWindowOrChannel(nullptr, aChannel, chanURI); if (!isThirdParty) { if (UC_LOG_ENABLED()) { - nsCOMPtr chanURI; - Unused << aChannel->GetURI(getter_AddRefs(chanURI)); - if (chanURI) { - nsCString spec = chanURI->GetSpecOrDefault(); - spec.Truncate( - std::min(spec.Length(), UrlClassifierCommon::sMaxSpecLength)); - UC_LOG( - ("UrlClassifierFeatureFingerprintingProtection: Skipping " - "fingerprinting checks " - "for first party or top-level load channel[%p] " - "with uri %s", - aChannel, spec.get())); - } + nsCString spec = chanURI->GetSpecOrDefault(); + spec.Truncate( + std::min(spec.Length(), UrlClassifierCommon::sMaxSpecLength)); + UC_LOG( + ("UrlClassifierFeatureFingerprintingProtection: Skipping " + "fingerprinting checks " + "for first party or top-level load channel[%p] " + "with uri %s", + aChannel, spec.get())); } return nullptr; } diff --git a/netwerk/url-classifier/UrlClassifierFeatureSocialTrackingProtection.cpp b/netwerk/url-classifier/UrlClassifierFeatureSocialTrackingProtection.cpp index 66483ff3df02..02404f59d232 100644 --- a/netwerk/url-classifier/UrlClassifierFeatureSocialTrackingProtection.cpp +++ b/netwerk/url-classifier/UrlClassifierFeatureSocialTrackingProtection.cpp @@ -6,10 +6,10 @@ #include "UrlClassifierFeatureSocialTrackingProtection.h" -#include "mozilla/AntiTrackingUtils.h" #include "mozilla/net/UrlClassifierCommon.h" #include "ChannelClassifierService.h" #include "mozilla/StaticPrefs_privacy.h" +#include "nsContentUtils.h" #include "nsNetUtil.h" namespace mozilla { @@ -90,23 +90,27 @@ UrlClassifierFeatureSocialTrackingProtection::MaybeCreate( return nullptr; } - bool isThirdParty = AntiTrackingUtils::IsThirdPartyChannel(aChannel); + nsCOMPtr chanURI; + nsresult rv = aChannel->GetURI(getter_AddRefs(chanURI)); + if (NS_WARN_IF(NS_FAILED(rv))) { + return nullptr; + } + + bool isThirdParty = + nsContentUtils::IsThirdPartyWindowOrChannel(nullptr, aChannel, chanURI); if (!isThirdParty) { if (UC_LOG_ENABLED()) { - nsCOMPtr chanURI; - Unused << aChannel->GetURI(getter_AddRefs(chanURI)); - if (chanURI) { - nsCString spec = chanURI->GetSpecOrDefault(); - spec.Truncate( - std::min(spec.Length(), UrlClassifierCommon::sMaxSpecLength)); - UC_LOG( - ("UrlClassifierFeatureSocialTrackingProtection: Skipping " - "socialtracking checks " - "for first party or top-level load channel[%p] " - "with uri %s", - aChannel, spec.get())); - } + nsCString spec = chanURI->GetSpecOrDefault(); + spec.Truncate( + std::min(spec.Length(), UrlClassifierCommon::sMaxSpecLength)); + UC_LOG( + ("UrlClassifierFeatureSocialTrackingProtection: Skipping " + "socialtracking checks " + "for first party or top-level load channel[%p] " + "with uri %s", + aChannel, spec.get())); } + return nullptr; } diff --git a/netwerk/url-classifier/UrlClassifierFeatureTrackingProtection.cpp b/netwerk/url-classifier/UrlClassifierFeatureTrackingProtection.cpp index 0864e1c82de6..800fb2038506 100644 --- a/netwerk/url-classifier/UrlClassifierFeatureTrackingProtection.cpp +++ b/netwerk/url-classifier/UrlClassifierFeatureTrackingProtection.cpp @@ -6,9 +6,9 @@ #include "UrlClassifierFeatureTrackingProtection.h" -#include "mozilla/AntiTrackingUtils.h" #include "mozilla/net/UrlClassifierCommon.h" #include "ChannelClassifierService.h" +#include "nsContentUtils.h" #include "nsIHttpChannelInternal.h" #include "nsILoadContext.h" #include "nsNetUtil.h" @@ -93,22 +93,26 @@ UrlClassifierFeatureTrackingProtection::MaybeCreate(nsIChannel* aChannel) { return nullptr; } - bool isThirdParty = AntiTrackingUtils::IsThirdPartyChannel(aChannel); + nsCOMPtr chanURI; + nsresult rv = aChannel->GetURI(getter_AddRefs(chanURI)); + if (NS_WARN_IF(NS_FAILED(rv))) { + return nullptr; + } + + bool isThirdParty = + nsContentUtils::IsThirdPartyWindowOrChannel(nullptr, aChannel, chanURI); if (!isThirdParty) { if (UC_LOG_ENABLED()) { - nsCOMPtr chanURI; - Unused << aChannel->GetURI(getter_AddRefs(chanURI)); - if (chanURI) { - nsCString spec = chanURI->GetSpecOrDefault(); - spec.Truncate( - std::min(spec.Length(), UrlClassifierCommon::sMaxSpecLength)); - UC_LOG( - ("UrlClassifierFeatureTrackingProtection: Skipping tracking " - "protection checks for first party or top-level load channel[%p] " - "with uri %s", - aChannel, spec.get())); - } + nsCString spec = chanURI->GetSpecOrDefault(); + spec.Truncate( + std::min(spec.Length(), UrlClassifierCommon::sMaxSpecLength)); + UC_LOG( + ("UrlClassifierFeatureTrackingProtection: Skipping tracking " + "protection checks for first party or top-level load channel[%p] " + "with uri %s", + aChannel, spec.get())); } + return nullptr; }