diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 4ca1503a184b..cc22e384561d 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -1511,14 +1511,6 @@ nsDocShell::GetHasForeignCookiesBeenBlocked(bool* aHasForeignCookiesBeenBlocked) return NS_OK; } -NS_IMETHODIMP -nsDocShell::GetHasCookiesLoaded(bool* aHasCookiesLoaded) -{ - nsCOMPtr doc(GetDocument()); - *aHasCookiesLoaded = doc && doc->GetHasCookiesLoaded(); - return NS_OK; -} - NS_IMETHODIMP nsDocShell::GetAllowPlugins(bool* aAllowPlugins) { diff --git a/docshell/base/nsIDocShell.idl b/docshell/base/nsIDocShell.idl index d07c4b73b170..0986531242db 100644 --- a/docshell/base/nsIDocShell.idl +++ b/docshell/base/nsIDocShell.idl @@ -649,12 +649,6 @@ interface nsIDocShell : nsIDocShellTreeItem */ [infallible] readonly attribute boolean hasForeignCookiesBeenBlocked; - /** - * This attribute determines whether a document seen cookies or storage - * attempts ever whether they've been allowed or blocked. - */ - [infallible] readonly attribute boolean hasCookiesLoaded; - /** * Disconnects this docshell's editor from its window, and stores the * editor data in the open document's session history entry. This diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 339477120404..b01097a3cfad 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -544,17 +544,16 @@ Navigator::CookieEnabled() } uint32_t rejectedReason = 0; - bool granted = - AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(mWindow, - codebaseURI, - &rejectedReason); + if (AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(mWindow, + codebaseURI, + &rejectedReason)) { + return true; + } - AntiTrackingCommon::NotifyBlockingDecision(mWindow, - granted ? - AntiTrackingCommon::BlockingDecision::eAllow : - AntiTrackingCommon::BlockingDecision::eBlock, - rejectedReason); - return granted; + if (rejectedReason) { + AntiTrackingCommon::NotifyRejection(mWindow, rejectedReason); + } + return false; } bool diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 4df54f128b32..a2fbe037e48f 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -8902,19 +8902,11 @@ nsContentUtils::StorageDisabledByAntiTracking(nsPIDOMWindowInner* aWindow, bool disabled = StorageDisabledByAntiTrackingInternal(aWindow, aChannel, aPrincipal, aURI, &rejectedReason); - if (sAntiTrackingControlCenterUIEnabled) { + if (disabled && sAntiTrackingControlCenterUIEnabled && rejectedReason) { if (aWindow) { - AntiTrackingCommon::NotifyBlockingDecision(aWindow, - disabled ? - AntiTrackingCommon::BlockingDecision::eBlock : - AntiTrackingCommon::BlockingDecision::eAllow, - rejectedReason); + AntiTrackingCommon::NotifyRejection(aWindow, rejectedReason); } else if (aChannel) { - AntiTrackingCommon::NotifyBlockingDecision(aChannel, - disabled ? - AntiTrackingCommon::BlockingDecision::eBlock : - AntiTrackingCommon::BlockingDecision::eAllow, - rejectedReason); + AntiTrackingCommon::NotifyRejection(aChannel, rejectedReason); } } return disabled; diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index 6ae1b6df7231..38df69cbe386 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -5375,15 +5375,6 @@ nsGlobalWindowOuter::NotifyContentBlockingState(unsigned aState, if (!aBlocked) { unblocked = !doc->GetHasForeignCookiesBlocked(); } - } else if (aState == nsIWebProgressListener::STATE_COOKIES_LOADED) { - MOZ_ASSERT(!aBlocked, "We don't expected to see blocked STATE_COOKIES_LOADED"); - // Note that the logic in this branch is the logical negation of the logic - // in other branches, since the nsIDocument API we have is phrased in - // "loaded" terms as opposed to "blocked" terms. - doc->SetHasCookiesLoaded(!aBlocked, origin); - if (!aBlocked) { - unblocked = doc->GetHasCookiesLoaded(); - } } else { // Ignore nsIWebProgressListener::STATE_BLOCKED_UNSAFE_CONTENT; } diff --git a/dom/base/nsIDocument.h b/dom/base/nsIDocument.h index b2681f0652d1..f700f1d0495b 100644 --- a/dom/base/nsIDocument.h +++ b/dom/base/nsIDocument.h @@ -1111,26 +1111,6 @@ public: aHasCookiesBlockedByPermission); } - /** - * Set the cookies loaded flag for this document. - */ - void SetHasCookiesLoaded(bool aHasCookiesLoaded, - const nsAString& aOriginLoaded) - { - RecordContentBlockingLog(aOriginLoaded, - nsIWebProgressListener::STATE_COOKIES_LOADED, - !aHasCookiesLoaded); - } - - /** - * Get cookies loaded flag for this document. - */ - bool GetHasCookiesLoaded() - { - return !mContentBlockingLog.HasBlockedAnyOfType( - nsIWebProgressListener::STATE_COOKIES_LOADED); - } - /** * Get tracking content loaded flag for this document. */ diff --git a/netwerk/base/SimpleChannelParent.cpp b/netwerk/base/SimpleChannelParent.cpp index a9ede7fa520d..f66e75264ec1 100644 --- a/netwerk/base/SimpleChannelParent.cpp +++ b/netwerk/base/SimpleChannelParent.cpp @@ -38,13 +38,6 @@ SimpleChannelParent::NotifyTrackingProtectionDisabled() return NS_OK; } -NS_IMETHODIMP -SimpleChannelParent::NotifyCookieAllowed() -{ - // Nothing to do. - return NS_OK; -} - NS_IMETHODIMP SimpleChannelParent::NotifyTrackingCookieBlocked(uint32_t aRejectedReason) { diff --git a/netwerk/base/nsIParentChannel.idl b/netwerk/base/nsIParentChannel.idl index f551e8515bef..7628991dc5e1 100644 --- a/netwerk/base/nsIParentChannel.idl +++ b/netwerk/base/nsIParentChannel.idl @@ -34,12 +34,6 @@ interface nsIParentChannel : nsIStreamListener */ [noscript] void notifyTrackingProtectionDisabled(); - /** - * Called to notify the HttpChannelChild that cookie has been allowed for - * this load. - */ - [noscript] void notifyCookieAllowed(); - /** * Called to notify the HttpChannelChild that cookie has been blocked for * this load. diff --git a/netwerk/cookie/nsCookieService.cpp b/netwerk/cookie/nsCookieService.cpp index 90ee424be125..36af8126e46a 100644 --- a/netwerk/cookie/nsCookieService.cpp +++ b/netwerk/cookie/nsCookieService.cpp @@ -2269,7 +2269,6 @@ nsCookieService::SetCookieStringInternal(nsIURI *aHostURI, return; case STATUS_ACCEPTED: // Fallthrough case STATUS_ACCEPT_SESSION: - NotifyAccepted(aChannel); if (aIsForeign) { NotifyThirdParty(aHostURI, true, aChannel); } @@ -2289,14 +2288,6 @@ nsCookieService::SetCookieStringInternal(nsIURI *aHostURI, } } -void -nsCookieService::NotifyAccepted(nsIChannel* aChannel) -{ - AntiTrackingCommon::NotifyBlockingDecision(aChannel, - AntiTrackingCommon::BlockingDecision::eAllow, - 0); -} - // notify observers that a cookie was rejected due to the users' prefs. void nsCookieService::NotifyRejected(nsIURI *aHostURI, nsIChannel* aChannel, @@ -2307,9 +2298,7 @@ nsCookieService::NotifyRejected(nsIURI *aHostURI, nsIChannel* aChannel, os->NotifyObservers(aHostURI, "cookie-rejected", nullptr); } - AntiTrackingCommon::NotifyBlockingDecision(aChannel, - AntiTrackingCommon::BlockingDecision::eBlock, - aRejectedReason); + AntiTrackingCommon::NotifyRejection(aChannel, aRejectedReason); } // notify observers that a third-party cookie was accepted/rejected diff --git a/netwerk/cookie/nsCookieService.h b/netwerk/cookie/nsCookieService.h index d6a2fddde7c9..d91ad2b8ffdd 100644 --- a/netwerk/cookie/nsCookieService.h +++ b/netwerk/cookie/nsCookieService.h @@ -319,7 +319,6 @@ class nsCookieService final : public nsICookieService bool FindSecureCookie(const nsCookieKey& aKey, nsCookie* aCookie); void FindStaleCookies(nsCookieEntry *aEntry, int64_t aCurrentTime, const mozilla::Maybe &aIsSecure, nsTArray& aOutput, uint32_t aLimit); void TelemetryForEvictingStaleCookie(nsCookie* aEvicted, int64_t oldestCookieTime); - void NotifyAccepted(nsIChannel* aChannel); void NotifyRejected(nsIURI *aHostURI, nsIChannel* aChannel, uint32_t aRejectedReason); void NotifyThirdParty(nsIURI *aHostURI, bool aAccepted, nsIChannel *aChannel); void NotifyChanged(nsISupports *aSubject, const char16_t *aData, bool aOldCookieIsSession = false, bool aFromHttp = false); diff --git a/netwerk/protocol/data/DataChannelParent.cpp b/netwerk/protocol/data/DataChannelParent.cpp index 0416ed3d1556..9513c0a85b96 100644 --- a/netwerk/protocol/data/DataChannelParent.cpp +++ b/netwerk/protocol/data/DataChannelParent.cpp @@ -38,13 +38,6 @@ DataChannelParent::NotifyTrackingProtectionDisabled() return NS_OK; } -NS_IMETHODIMP -DataChannelParent::NotifyCookieAllowed() -{ - // Nothing to do. - return NS_OK; -} - NS_IMETHODIMP DataChannelParent::NotifyTrackingCookieBlocked(uint32_t aRejectedReason) { diff --git a/netwerk/protocol/file/FileChannelParent.cpp b/netwerk/protocol/file/FileChannelParent.cpp index f71bf0e5b5e6..029749bbb262 100644 --- a/netwerk/protocol/file/FileChannelParent.cpp +++ b/netwerk/protocol/file/FileChannelParent.cpp @@ -38,13 +38,6 @@ FileChannelParent::NotifyTrackingProtectionDisabled() return NS_OK; } -NS_IMETHODIMP -FileChannelParent::NotifyCookieAllowed() -{ - // Nothing to do. - return NS_OK; -} - NS_IMETHODIMP FileChannelParent::NotifyTrackingCookieBlocked(uint32_t aRejectedReason) { diff --git a/netwerk/protocol/ftp/FTPChannelParent.cpp b/netwerk/protocol/ftp/FTPChannelParent.cpp index b4ab472f79ee..a0026bf9d3cc 100644 --- a/netwerk/protocol/ftp/FTPChannelParent.cpp +++ b/netwerk/protocol/ftp/FTPChannelParent.cpp @@ -577,13 +577,6 @@ FTPChannelParent::NotifyTrackingProtectionDisabled() return NS_OK; } -NS_IMETHODIMP -FTPChannelParent::NotifyCookieAllowed() -{ - // One day, this should probably be filled in. - return NS_OK; -} - NS_IMETHODIMP FTPChannelParent::NotifyTrackingCookieBlocked(uint32_t aRejectedReason) { diff --git a/netwerk/protocol/http/HttpBackgroundChannelChild.cpp b/netwerk/protocol/http/HttpBackgroundChannelChild.cpp index 4c3257fa58c7..2e7e15ba1a78 100644 --- a/netwerk/protocol/http/HttpBackgroundChannelChild.cpp +++ b/netwerk/protocol/http/HttpBackgroundChannelChild.cpp @@ -348,21 +348,6 @@ HttpBackgroundChannelChild::RecvNotifyTrackingProtectionDisabled() return IPC_OK(); } -IPCResult -HttpBackgroundChannelChild::RecvNotifyCookieAllowed() -{ - LOG(("HttpBackgroundChannelChild::RecvNotifyCookieAllowed [this=%p]\n", this)); - MOZ_ASSERT(OnSocketThread()); - - if (NS_WARN_IF(!mChannelChild)) { - return IPC_OK(); - } - - mChannelChild->ProcessNotifyCookieAllowed(); - - return IPC_OK(); -} - IPCResult HttpBackgroundChannelChild::RecvNotifyTrackingCookieBlocked(const uint32_t& aRejectedReason) { diff --git a/netwerk/protocol/http/HttpBackgroundChannelChild.h b/netwerk/protocol/http/HttpBackgroundChannelChild.h index 7f679a998db1..2b8f36bea21b 100644 --- a/netwerk/protocol/http/HttpBackgroundChannelChild.h +++ b/netwerk/protocol/http/HttpBackgroundChannelChild.h @@ -65,8 +65,6 @@ protected: IPCResult RecvNotifyTrackingProtectionDisabled() override; - IPCResult RecvNotifyCookieAllowed() override; - IPCResult RecvNotifyTrackingCookieBlocked(const uint32_t& aRejectedReason) override; IPCResult RecvNotifyTrackingResource(const bool& aIsThirdParty) override; diff --git a/netwerk/protocol/http/HttpBackgroundChannelParent.cpp b/netwerk/protocol/http/HttpBackgroundChannelParent.cpp index 162637f9c3e3..3a19f321503d 100644 --- a/netwerk/protocol/http/HttpBackgroundChannelParent.cpp +++ b/netwerk/protocol/http/HttpBackgroundChannelParent.cpp @@ -379,35 +379,6 @@ HttpBackgroundChannelParent::OnNotifyTrackingProtectionDisabled() return SendNotifyTrackingProtectionDisabled(); } -bool -HttpBackgroundChannelParent::OnNotifyCookieAllowed() -{ - LOG(("HttpBackgroundChannelParent::OnNotifyCookieAllowed [this=%p]\n", this)); - AssertIsInMainProcess(); - - if (NS_WARN_IF(!mIPCOpened)) { - return false; - } - - if (!IsOnBackgroundThread()) { - MutexAutoLock lock(mBgThreadMutex); - RefPtr self = this; - nsresult rv = mBackgroundThread->Dispatch( - NS_NewRunnableFunction( - "net::HttpBackgroundChannelParent::OnNotifyCookieAllowed", - [self]() { - self->OnNotifyCookieAllowed(); - }), - NS_DISPATCH_NORMAL); - - MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv)); - - return NS_SUCCEEDED(rv); - } - - return SendNotifyCookieAllowed(); -} - bool HttpBackgroundChannelParent::OnNotifyTrackingCookieBlocked(uint32_t aRejectedReason) { diff --git a/netwerk/protocol/http/HttpBackgroundChannelParent.h b/netwerk/protocol/http/HttpBackgroundChannelParent.h index 0768f5276296..6d68583d60c0 100644 --- a/netwerk/protocol/http/HttpBackgroundChannelParent.h +++ b/netwerk/protocol/http/HttpBackgroundChannelParent.h @@ -69,9 +69,6 @@ public: // To send NotifyTrackingProtectionDisabled message over background channel. bool OnNotifyTrackingProtectionDisabled(); - // To send NotifyCookieAllowed message over background channel. - bool OnNotifyCookieAllowed(); - // To send NotifyTrackingCookieBlocked message over background channel. bool OnNotifyTrackingCookieBlocked(uint32_t aRejectedReason); diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp index a4e9a874e3e2..ee20a8af5a2f 100644 --- a/netwerk/protocol/http/HttpChannelChild.cpp +++ b/netwerk/protocol/http/HttpChannelChild.cpp @@ -2049,25 +2049,6 @@ HttpChannelChild::ProcessNotifyTrackingProtectionDisabled() NS_DISPATCH_NORMAL); } -void -HttpChannelChild::ProcessNotifyCookieAllowed() -{ - LOG(("HttpChannelChild::ProcessNotifyCookieAllowed [this=%p]\n", this)); - MOZ_ASSERT(OnSocketThread()); - - RefPtr self = this; - nsCOMPtr neckoTarget = GetNeckoTarget(); - neckoTarget->Dispatch( - NS_NewRunnableFunction( - "nsChannelClassifier::NotifyBlockingDecision", - [self]() { - AntiTrackingCommon::NotifyBlockingDecision(self, - AntiTrackingCommon::BlockingDecision::eAllow, - 0); - }), - NS_DISPATCH_NORMAL); -} - void HttpChannelChild::ProcessNotifyTrackingCookieBlocked(uint32_t aRejectedReason) { @@ -2080,9 +2061,7 @@ HttpChannelChild::ProcessNotifyTrackingCookieBlocked(uint32_t aRejectedReason) NS_NewRunnableFunction( "nsChannelClassifier::NotifyTrackingCookieBlocked", [self, aRejectedReason]() { - AntiTrackingCommon::NotifyBlockingDecision(self, - AntiTrackingCommon::BlockingDecision::eBlock, - aRejectedReason); + AntiTrackingCommon::NotifyRejection(self, aRejectedReason); }), NS_DISPATCH_NORMAL); } diff --git a/netwerk/protocol/http/HttpChannelChild.h b/netwerk/protocol/http/HttpChannelChild.h index 573930c0e7da..5bde3ec540c8 100644 --- a/netwerk/protocol/http/HttpChannelChild.h +++ b/netwerk/protocol/http/HttpChannelChild.h @@ -259,7 +259,6 @@ private: void ProcessFlushedForDiversion(); void ProcessDivertMessages(); void ProcessNotifyTrackingProtectionDisabled(); - void ProcessNotifyCookieAllowed(); void ProcessNotifyTrackingCookieBlocked(uint32_t aRejectedReason); void ProcessNotifyTrackingResource(bool aIsThirdParty); void ProcessSetClassifierMatchedInfo(const nsCString& aList, diff --git a/netwerk/protocol/http/HttpChannelParent.cpp b/netwerk/protocol/http/HttpChannelParent.cpp index 5d74fa94db35..cba89e650ffb 100644 --- a/netwerk/protocol/http/HttpChannelParent.cpp +++ b/netwerk/protocol/http/HttpChannelParent.cpp @@ -1903,17 +1903,6 @@ HttpChannelParent::NotifyTrackingProtectionDisabled() return NS_OK; } -NS_IMETHODIMP -HttpChannelParent::NotifyCookieAllowed() -{ - LOG(("HttpChannelParent::NotifyCookieAllowed [this=%p]\n", this)); - if (!mIPCClosed) { - MOZ_ASSERT(mBgParent); - Unused << NS_WARN_IF(!mBgParent->OnNotifyCookieAllowed()); - } - return NS_OK; -} - NS_IMETHODIMP HttpChannelParent::NotifyTrackingCookieBlocked(uint32_t aRejectedReason) { diff --git a/netwerk/protocol/http/PHttpBackgroundChannel.ipdl b/netwerk/protocol/http/PHttpBackgroundChannel.ipdl index 3b4191d73305..4696c1e9b4f4 100644 --- a/netwerk/protocol/http/PHttpBackgroundChannel.ipdl +++ b/netwerk/protocol/http/PHttpBackgroundChannel.ipdl @@ -56,9 +56,6 @@ child: // Tell the child that tracking protection was disabled for this load. async NotifyTrackingProtectionDisabled(); - // Tell the child that cookies are allowed for this load. - async NotifyCookieAllowed(); - // Tell the child that tracking cookies are blocked for this load. async NotifyTrackingCookieBlocked(uint32_t aRejectedReason); diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index 11ec2ecc10d4..7414c97435e7 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -838,18 +838,12 @@ nsHttpChannel::ConnectOnTailUnblock() LOG(("nsHttpChannel::ConnectOnTailUnblock [this=%p]\n", this)); bool isTrackingResource = mIsThirdPartyTrackingResource; // is atomic - if (isTrackingResource) { - bool engageFastBlock = CheckFastBlocked(); - AntiTrackingCommon::NotifyBlockingDecision(this, - engageFastBlock ? - AntiTrackingCommon::BlockingDecision::eBlock : - AntiTrackingCommon::BlockingDecision::eAllow, - nsIWebProgressListener::STATE_BLOCKED_SLOW_TRACKING_CONTENT); - if (engageFastBlock) { - Unused << AsyncAbort(NS_ERROR_TRACKING_ANNOTATION_URI); - CloseCacheEntry(false); - return NS_OK; - } + if (isTrackingResource && CheckFastBlocked()) { + AntiTrackingCommon::NotifyRejection(this, + nsIWebProgressListener::STATE_BLOCKED_SLOW_TRACKING_CONTENT); + Unused << AsyncAbort(NS_ERROR_TRACKING_ANNOTATION_URI); + CloseCacheEntry(false); + return NS_OK; } // Consider opening a TCP connection right away. diff --git a/security/manager/ssl/nsSecureBrowserUIImpl.cpp b/security/manager/ssl/nsSecureBrowserUIImpl.cpp index 1f4d7d45ec76..6ddda40656a3 100644 --- a/security/manager/ssl/nsSecureBrowserUIImpl.cpp +++ b/security/manager/ssl/nsSecureBrowserUIImpl.cpp @@ -205,10 +205,6 @@ nsSecureBrowserUIImpl::CheckForBlockedContent() if (docShell->GetHasAllCookiesBeenBlocked()) { mState |= STATE_COOKIES_BLOCKED_ALL; } - - if (docShell->GetHasCookiesLoaded()) { - mState |= STATE_COOKIES_LOADED; - } } // Helper function to determine if the given URI can be considered secure. diff --git a/toolkit/components/antitracking/AntiTrackingCommon.cpp b/toolkit/components/antitracking/AntiTrackingCommon.cpp index 89698d1e2f1f..dd9a27a6023f 100644 --- a/toolkit/components/antitracking/AntiTrackingCommon.cpp +++ b/toolkit/components/antitracking/AntiTrackingCommon.cpp @@ -494,7 +494,7 @@ AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(nsIPrincipal* aPrincipa LOG_SPEC(("Tracking principal (%s) hasn't been interacted with before, " "refusing to add a first-party storage permission to access it", _spec), trackingURI); - NotifyBlockingDecision(aParentWindow, BlockingDecision::eBlock, blockReason); + NotifyRejection(aParentWindow, blockReason); return StorageAccessGrantPromise::CreateAndReject(false, __func__); } @@ -1205,41 +1205,26 @@ AntiTrackingCommon::IsOnContentBlockingAllowList(nsIURI* aTopWinURI, } /* static */ void -AntiTrackingCommon::NotifyBlockingDecision(nsIChannel* aChannel, - BlockingDecision aDecision, - uint32_t aRejectedReason) +AntiTrackingCommon::NotifyRejection(nsIChannel* aChannel, + uint32_t aRejectedReason) { - MOZ_ASSERT(aRejectedReason == 0 || - aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION || + MOZ_ASSERT(aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION || aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER || aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL || aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN || aRejectedReason == nsIWebProgressListener::STATE_BLOCKED_SLOW_TRACKING_CONTENT); - MOZ_ASSERT(aDecision == BlockingDecision::eBlock || - aDecision == BlockingDecision::eAllow); if (!aChannel) { return; } - // When we allow loads, collapse all cookie related reason codes into STATE_COOKIES_LOADED. - bool sendCookieLoadedNotification = false; - if (aRejectedReason != nsIWebProgressListener::STATE_BLOCKED_SLOW_TRACKING_CONTENT) { - sendCookieLoadedNotification = true; - } - // Can be called in EITHER the parent or child process. nsCOMPtr parentChannel; NS_QueryNotificationCallbacks(aChannel, parentChannel); if (parentChannel) { // This channel is a parent-process proxy for a child process request. // Tell the child process channel to do this instead. - if (aDecision == BlockingDecision::eBlock) { - parentChannel->NotifyTrackingCookieBlocked(aRejectedReason); - } else { - // Ignore the code related to fastblock - parentChannel->NotifyCookieAllowed(); - } + parentChannel->NotifyTrackingCookieBlocked(aRejectedReason); return; } @@ -1261,38 +1246,22 @@ AntiTrackingCommon::NotifyBlockingDecision(nsIChannel* aChannel, nsCOMPtr uri; aChannel->GetURI(getter_AddRefs(uri)); - if (aDecision == BlockingDecision::eBlock) { - pwin->NotifyContentBlockingState(aRejectedReason, aChannel, true, uri); + pwin->NotifyContentBlockingState(aRejectedReason, aChannel, true, uri); - ReportBlockingToConsole(pwin, uri, aRejectedReason); - } - - if (sendCookieLoadedNotification) { - pwin->NotifyContentBlockingState(nsIWebProgressListener::STATE_COOKIES_LOADED, - aChannel, false, uri); - } + ReportBlockingToConsole(pwin, uri, aRejectedReason); } /* static */ void -AntiTrackingCommon::NotifyBlockingDecision(nsPIDOMWindowInner* aWindow, - BlockingDecision aDecision, - uint32_t aRejectedReason) +AntiTrackingCommon::NotifyRejection(nsPIDOMWindowInner* aWindow, + uint32_t aRejectedReason) { MOZ_ASSERT(aWindow); - MOZ_ASSERT(aRejectedReason == 0 || - aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION || + MOZ_ASSERT(aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION || aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER || aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL || aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN || aRejectedReason == nsIWebProgressListener::STATE_BLOCKED_SLOW_TRACKING_CONTENT); - MOZ_ASSERT(aDecision == BlockingDecision::eBlock || - aDecision == BlockingDecision::eAllow); - // When we allow loads, collapse all cookie related reason codes into STATE_COOKIES_LOADED. - bool sendCookieLoadedNotification = false; - if (aRejectedReason != nsIWebProgressListener::STATE_BLOCKED_SLOW_TRACKING_CONTENT) { - sendCookieLoadedNotification = true; - } nsCOMPtr pwin = GetTopWindow(aWindow); if (!pwin) { @@ -1318,16 +1287,9 @@ AntiTrackingCommon::NotifyBlockingDecision(nsPIDOMWindowInner* aWindow, } nsIURI* uri = document->GetDocumentURI(); - if (aDecision == BlockingDecision::eBlock) { - pwin->NotifyContentBlockingState(aRejectedReason, channel, true, uri); + pwin->NotifyContentBlockingState(aRejectedReason, channel, true, uri); - ReportBlockingToConsole(pwin, uri, aRejectedReason); - } - - if (sendCookieLoadedNotification) { - pwin->NotifyContentBlockingState(nsIWebProgressListener::STATE_COOKIES_LOADED, - channel, false, uri); - } + ReportBlockingToConsole(pwin, uri, aRejectedReason); } /* static */ void diff --git a/toolkit/components/antitracking/AntiTrackingCommon.h b/toolkit/components/antitracking/AntiTrackingCommon.h index 624640b0c04f..050bdd441ef0 100644 --- a/toolkit/components/antitracking/AntiTrackingCommon.h +++ b/toolkit/components/antitracking/AntiTrackingCommon.h @@ -129,18 +129,10 @@ public: ContentBlockingAllowListPurpose aPurpose, bool& aIsAllowListed); - enum class BlockingDecision { - eBlock, - eAllow, - }; - // This method can be called on the parent process or on the content process. // The notification is propagated to the child channel if aChannel is a parent // channel proxy. // - // aDecision can be eBlock if we have decided to block some content, or eAllow - // if we have decided to allow the content through. - // // aRejectedReason must be one of these values: // * nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION // * nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER @@ -148,12 +140,10 @@ public: // * nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN // * nsIWebProgressListener::STATE_BLOCKED_SLOW_TRACKING_CONTENT static void - NotifyBlockingDecision(nsIChannel* aChannel, BlockingDecision aDecision, - uint32_t aRejectedReason); + NotifyRejection(nsIChannel* aChannel, uint32_t aRejectedReason); static void - NotifyBlockingDecision(nsPIDOMWindowInner* aWindow, BlockingDecision aDecision, - uint32_t aRejectedReason); + NotifyRejection(nsPIDOMWindowInner* aWindow, uint32_t aRejectedReason); }; } // namespace mozilla diff --git a/toolkit/components/antitracking/test/browser/browser_subResources.js b/toolkit/components/antitracking/test/browser/browser_subResources.js index 9ea0d3c6c237..21285963b255 100644 --- a/toolkit/components/antitracking/test/browser/browser_subResources.js +++ b/toolkit/components/antitracking/test/browser/browser_subResources.js @@ -156,54 +156,29 @@ add_task(async function() { is(text, 1, "One cookie received received for scripts."); }); - let expectTrackerBlocked = (item, blocked) => { - is(item[0], Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_TRACKER, - "Correct blocking type reported"); - is(item[1], blocked, - "Correct blocking status reported"); - ok(item[2] >= 1, - "Correct repeat count reported"); - }; - - let expectTrackerFound = item => { - is(item[0], Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT, - "Correct blocking type reported"); - is(item[1], true, - "Correct blocking status reported"); - ok(item[2] >= 1, - "Correct repeat count reported"); - }; - - let expectCookiesLoaded = item => { - is(item[0], Ci.nsIWebProgressListener.STATE_COOKIES_LOADED, - "Correct blocking type reported"); - is(item[1], false, - "Correct blocking status reported"); - ok(item[2] >= 1, - "Correct repeat count reported"); - }; - let log = JSON.parse(await browser.getContentBlockingLog()); for (let trackerOrigin in log) { is(trackerOrigin, TEST_3RD_PARTY_DOMAIN, "Correct tracker origin must be reported"); let originLog = log[trackerOrigin]; - is(originLog.length, 16, "We should have 16 entries in the compressed log"); - expectTrackerFound(originLog[0]); - expectCookiesLoaded(originLog[1]); - expectTrackerBlocked(originLog[2], true); - expectCookiesLoaded(originLog[3]); - expectTrackerBlocked(originLog[4], true); - expectCookiesLoaded(originLog[5]); - expectTrackerBlocked(originLog[6], true); - expectCookiesLoaded(originLog[7]); - expectTrackerBlocked(originLog[8], true); - expectCookiesLoaded(originLog[9]); - expectTrackerBlocked(originLog[10], true); - expectCookiesLoaded(originLog[11]); - expectTrackerBlocked(originLog[12], true); - expectCookiesLoaded(originLog[13]); - expectTrackerBlocked(originLog[14], false); - expectCookiesLoaded(originLog[15]); + is(originLog.length, 3, "We should have 3 entries in the compressed log"); + is(originLog[0][0], Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT, + "Correct blocking type reported"); + is(originLog[0][1], true, + "Correct blocking status reported"); + ok(originLog[0][2] >= 1, + "Correct repeat count reported"); + is(originLog[1][0], Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_TRACKER, + "Correct blocking type reported"); + is(originLog[1][1], true, + "Correct blocking status reported"); + is(originLog[1][2], 6, + "Correct repeat count reported"); + is(originLog[2][0], Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_TRACKER, + "Correct blocking type reported"); + is(originLog[2][1], false, + "Correct blocking status reported"); + ok(originLog[2][2] >= 1, + "Correct repeat count reported"); } info("Removing the tab"); diff --git a/toolkit/components/antitracking/test/browser/head.js b/toolkit/components/antitracking/test/browser/head.js index d3b2b40fe9c0..c24398073003 100644 --- a/toolkit/components/antitracking/test/browser/head.js +++ b/toolkit/components/antitracking/test/browser/head.js @@ -365,16 +365,10 @@ this.AntiTracking = { let originLog = contentBlockingLog[trackerOrigin]; for (let i = 0; i < originLog.length; ++i) { let item = originLog[i]; - switch (item[0]) { - case Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT: - is(item[1], true, "Correct blocking status reported"); - ok(item[2] >= 1, "Correct repeat count reported"); - break; - case Ci.nsIWebProgressListener.STATE_COOKIES_LOADED: - is(item[1], false, "Correct blocking status reported"); - ok(item[2] >= 1, "Correct repeat count reported"); - break; - } + is(item[0], Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT, + "Correct blocking type must be reported"); + is(item[1], true, "Correct blocking status reported"); + ok(item[2] >= 1, "Correct repeat count reported"); } } } @@ -554,11 +548,20 @@ this.AntiTracking = { contentBlockingLog = JSON.parse(contentBlockingLogJSON); } catch (e) { } + // If this is the first cookie to be blocked, our state should have + // just changed, otherwise it should have previously contained the + // STATE_COOKIES_BLOCKED_TRACKER bit too. if (cookieBlocked) { + if (cookieBlocked == 1) { + is(oldState & Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_TRACKER, 0, + "When blocking the first cookie, old state should not have had the " + + "STATE_COOKIES_BLOCKED_TRACKER bit"); + } + for (let trackerOrigin in contentBlockingLog) { is(trackerOrigin, TEST_3RD_PARTY_DOMAIN, "Correct tracker origin must be reported"); let originLog = contentBlockingLog[trackerOrigin]; - ok(originLog.length >= 1, "We should have at least two items in the log"); + ok(originLog.length > 1, "We should have at least two items in the log"); for (let i = 0; i < originLog.length; ++i) { let item = originLog[i]; switch (item[0]) { @@ -580,10 +583,6 @@ this.AntiTracking = { is(item[2], 1, "Correct repeat count reported"); } break; - case Ci.nsIWebProgressListener.STATE_COOKIES_LOADED: - is(item[1], false, "Correct blocking status reported"); - ok(item[2] >= 1, "Correct repeat count reported"); - break; } } } @@ -697,18 +696,17 @@ this.AntiTracking = { } for (let trackerOrigin in contentBlockingLog) { + is(trackerOrigin, TEST_3RD_PARTY_DOMAIN, "Correct tracker origin must be reported"); let originLog = contentBlockingLog[trackerOrigin]; - ok(originLog.length >= 1, "We should have at least two items in the log"); + ok(originLog.length > 1, "We should have at least two items in the log"); for (let i = 0; i < originLog.length; ++i) { let item = originLog[i]; switch (item[0]) { case Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT: - is(trackerOrigin, TEST_3RD_PARTY_DOMAIN, "Correct tracker origin must be reported"); is(item[1], true, "Correct blocking status reported"); ok(item[2] >= 1, "Correct repeat count reported"); break; case Ci.nsIWebProgressListener.STATE_BLOCKED_TRACKING_CONTENT: - is(trackerOrigin, TEST_3RD_PARTY_DOMAIN, "Correct tracker origin must be reported"); if (item[1]) { ok(item[2] >= 1, "Correct repeat count reported"); } else { @@ -718,16 +716,10 @@ this.AntiTracking = { } break; case Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_TRACKER: - is(trackerOrigin, TEST_3RD_PARTY_DOMAIN, "Correct tracker origin must be reported"); // We can expect 1 or more repeat count whether or not blocking has happened, // so nothing to assert on item[1]. ok(item[2] >= 1, "Correct repeat count reported"); break; - case Ci.nsIWebProgressListener.STATE_COOKIES_LOADED: - // The trackerOrigin here is sometimes TEST_DOMAIN, sometimes TEST_3RD_PARTY_DOMAIN. - is(item[1], false, "Correct blocking status reported"); - ok(item[2] >= 1, "Correct repeat count reported"); - break; } } } diff --git a/uriloader/base/nsIWebProgressListener.idl b/uriloader/base/nsIWebProgressListener.idl index b91e9dd50537..eb61e68d8922 100644 --- a/uriloader/base/nsIWebProgressListener.idl +++ b/uriloader/base/nsIWebProgressListener.idl @@ -327,7 +327,6 @@ interface nsIWebProgressListener : nsISupports * STATE_BLOCKED_SLOW_TRACKING_CONTENT * Rejected because of the FastBlock feature. */ - const unsigned long STATE_COOKIES_LOADED = 0x00008000; const unsigned long STATE_COOKIES_BLOCKED_BY_PERMISSION = 0x10000000; const unsigned long STATE_COOKIES_BLOCKED_TRACKER = 0x20000000; const unsigned long STATE_COOKIES_BLOCKED_ALL = 0x40000000; diff --git a/uriloader/exthandler/nsExternalProtocolHandler.cpp b/uriloader/exthandler/nsExternalProtocolHandler.cpp index ee3b34fd4431..67397d215f5e 100644 --- a/uriloader/exthandler/nsExternalProtocolHandler.cpp +++ b/uriloader/exthandler/nsExternalProtocolHandler.cpp @@ -422,12 +422,6 @@ NS_IMETHODIMP nsExtProtocolChannel::NotifyTrackingProtectionDisabled() return NS_OK; } -NS_IMETHODIMP nsExtProtocolChannel::NotifyCookieAllowed() -{ - // nothing to do - return NS_OK; -} - NS_IMETHODIMP nsExtProtocolChannel::NotifyTrackingCookieBlocked(uint32_t aRejectedReason) { // nothing to do