From fbae672ca07997748d0fff5b0fb5e4ce381ad139 Mon Sep 17 00:00:00 2001 From: Nihanth Subramanya Date: Fri, 27 Sep 2019 10:41:48 +0000 Subject: [PATCH] Bug 1579209 - [Protections Panel] Use new STATE_COOKIES_LOADED_TRACKER for cookies category item visibility logic. r=johannh Differential Revision: https://phabricator.services.mozilla.com/D47323 --HG-- extra : moz-landing-system : lando --- .../base/content/browser-siteProtections.js | 22 ++++++++++--------- .../browser_trackingUI_open_preferences.js | 4 +++- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/browser/base/content/browser-siteProtections.js b/browser/base/content/browser-siteProtections.js index 4bb7f008c2cd..89dd096e4ac2 100644 --- a/browser/base/content/browser-siteProtections.js +++ b/browser/base/content/browser-siteProtections.js @@ -672,20 +672,22 @@ var ThirdPartyCookies = { }, isDetected(state) { - if (this.behaviorPref == Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER) { - // We don't have a state that specifically represents loaded tracker cookies, - // so use loaded tracking content as a proxy - it's not perfect but it - // yields fewer false-positives than the generic loaded cookies state. + if (this.isBlocking(state)) { + return true; + } + + if ( + this.behaviorPref == Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER || + this.behaviorPref == Ci.nsICookieService.BEHAVIOR_ACCEPT + ) { return ( - (state & Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT) != 0 + (state & Ci.nsIWebProgressListener.STATE_COOKIES_LOADED_TRACKER) != 0 ); } - // We don't have any proxies for the other cookie behaviors unfortunately. - return ( - this.isBlocking(state) || - (state & Ci.nsIWebProgressListener.STATE_COOKIES_LOADED) != 0 - ); + // We don't have specific flags for the other cookie behaviors so just + // fall back to STATE_COOKIES_LOADED. + return (state & Ci.nsIWebProgressListener.STATE_COOKIES_LOADED) != 0; }, async updateSubView() { diff --git a/browser/base/content/test/trackingUI/browser_trackingUI_open_preferences.js b/browser/base/content/test/trackingUI/browser_trackingUI_open_preferences.js index 38220f6783a8..d6fd358dbec4 100644 --- a/browser/base/content/test/trackingUI/browser_trackingUI_open_preferences.js +++ b/browser/base/content/test/trackingUI/browser_trackingUI_open_preferences.js @@ -7,6 +7,8 @@ const TP_PREF = "privacy.trackingprotection.enabled"; const TPC_PREF = "network.cookie.cookieBehavior"; const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/trackingPage.html"; +const COOKIE_PAGE = + "http://tracking.example.com/browser/browser/base/content/test/trackingUI/cookiePage.html"; async function waitAndAssertPreferencesShown(_spotlight, identityPopup) { await BrowserTestUtils.waitForEvent( @@ -103,7 +105,7 @@ add_task(async function testOpenPreferencesFromCookiesSubview() { ); let promise = BrowserTestUtils.openNewForegroundTab({ - url: TRACKING_PAGE, + url: COOKIE_PAGE, gBrowser, });