Bug 1496557 - Expose Report Breakage for Cookie Restrictions on Release. r=Gijs
authorJohann Hofmann <jhofmann@mozilla.com>
Fri, 05 Oct 2018 11:27:55 +0200
changeset 495527 aebbddba77c67a989ad25713e5536477b044c1ce
parent 495526 bc381243c490f6e5b54a65734af5504e598e129d
child 495528 97208b5251d7e86cb4051711609b6236a944981e
child 495549 be99865efc836bcf19491ad6f1a62c47f279cf28
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1496557
milestone64.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 1496557 - Expose Report Breakage for Cookie Restrictions on Release. r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D7856
browser/app/profile/firefox.js
browser/base/content/browser-contentblocking.js
browser/base/content/test/trackingUI/browser_trackingUI_report_breakage.js
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1517,16 +1517,19 @@ pref("browser.contentblocking.cookies-si
 pref("browser.contentblocking.cookies-site-data.ui.reject-trackers.enabled", true);
 
 // Enable the Report Breakage UI on Nightly and Beta but not on Release yet.
 #ifdef EARLY_BETA_OR_EARLIER
 pref("browser.contentblocking.reportBreakage.enabled", true);
 #else
 pref("browser.contentblocking.reportBreakage.enabled", false);
 #endif
+// Show report breakage for tracking cookies in all channels.
+pref("browser.contentblocking.rejecttrackers.reportBreakage.enabled", true);
+
 pref("browser.contentblocking.reportBreakage.url", "https://tracking-protection-issues.herokuapp.com/new");
 
 // Content Blocking has a separate pref for the intro count, since the former TP intro
 // was updated when we introduced content blocking and we want people to see it again.
 pref("browser.contentblocking.introCount", 0);
 
 pref("privacy.trackingprotection.introCount", 0);
 pref("privacy.trackingprotection.introURL", "https://www.mozilla.org/%LOCALE%/firefox/%VERSION%/tracking-protection/start/");
--- a/browser/base/content/browser-contentblocking.js
+++ b/browser/base/content/browser-contentblocking.js
@@ -138,16 +138,17 @@ var TrackingProtection = {
   isBlockerActivated(state) {
     return state & Ci.nsIWebProgressListener.STATE_BLOCKED_TRACKING_CONTENT;
   },
 };
 
 var ThirdPartyCookies = {
   reportBreakageLabel: "cookierestrictions",
   PREF_ENABLED: "network.cookie.cookieBehavior",
+  PREF_REPORT_BREAKAGE_ENABLED: "browser.contentblocking.rejecttrackers.reportBreakage.enabled",
   PREF_ENABLED_VALUES: [
     // These values match the ones exposed under the Content Blocking section
     // of the Preferences UI.
     Ci.nsICookieService.BEHAVIOR_REJECT_FOREIGN,  // Block all third-party cookies
     Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER,  // Block third-party cookies from trackers
   ],
   PREF_UI_ENABLED: "browser.contentblocking.rejecttrackers.control-center.ui.enabled",
 
@@ -156,16 +157,18 @@ var ThirdPartyCookies = {
     return this.categoryItem =
       document.getElementById("identity-popup-content-blocking-category-3rdpartycookies");
   },
 
   init() {
     XPCOMUtils.defineLazyPreferenceGetter(this, "behaviorPref", this.PREF_ENABLED,
                                           Ci.nsICookieService.BEHAVIOR_ACCEPT);
     XPCOMUtils.defineLazyPreferenceGetter(this, "visible", this.PREF_UI_ENABLED, false);
+    XPCOMUtils.defineLazyPreferenceGetter(this, "reportBreakageEnabled",
+      this.PREF_REPORT_BREAKAGE_ENABLED, false);
   },
   get enabled() {
     return this.PREF_ENABLED_VALUES.includes(this.behaviorPref);
   },
 
   isBlockerActivated(state) {
     return (state & Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_TRACKER) != 0 ||
            (state & Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_FOREIGN) != 0;
@@ -282,24 +285,16 @@ var ContentBlocking = {
         this.appMenuVerticalSeparator.setAttribute("hidden", "true");
       }
     };
 
     this.updateGlobalToggleVisibility();
 
     Services.prefs.addObserver(this.PREF_GLOBAL_TOGGLE, this.updateGlobalToggleVisibility);
 
-    this.updateReportBreakageUI = () => {
-      this.reportBreakageButton.hidden = !Services.prefs.getBoolPref(this.PREF_REPORT_BREAKAGE_ENABLED);
-    };
-
-    this.updateReportBreakageUI();
-
-    Services.prefs.addObserver(this.PREF_REPORT_BREAKAGE_ENABLED, this.updateReportBreakageUI);
-
     this.updateAnimationsEnabled = () => {
       this.iconBox.toggleAttribute("animationsenabled",
         Services.prefs.getBoolPref(this.PREF_ANIMATIONS_ENABLED, false));
     };
 
     for (let blocker of this.blockers) {
       if (blocker.init) {
         blocker.init();
@@ -307,16 +302,18 @@ var ContentBlocking = {
     }
 
     this.updateAnimationsEnabled();
 
     Services.prefs.addObserver(this.PREF_ANIMATIONS_ENABLED, this.updateAnimationsEnabled);
 
     XPCOMUtils.defineLazyPreferenceGetter(this, "contentBlockingEnabled", this.PREF_ENABLED, false,
       this.updateEnabled.bind(this));
+    XPCOMUtils.defineLazyPreferenceGetter(this, "reportBreakageEnabled",
+      this.PREF_REPORT_BREAKAGE_ENABLED, false);
     XPCOMUtils.defineLazyPreferenceGetter(this, "contentBlockingUIEnabled", this.PREF_UI_ENABLED, false,
       this.updateUIEnabled.bind(this));
 
     this.updateEnabled();
     this.updateUIEnabled();
 
     this.activeTooltipText =
       gNavigatorBundle.getString("trackingProtection.icon.activeTooltip");
@@ -327,17 +324,16 @@ var ContentBlocking = {
   uninit() {
     for (let blocker of this.blockers) {
       if (blocker.uninit) {
         blocker.uninit();
       }
     }
 
     Services.prefs.removeObserver(this.PREF_ANIMATIONS_ENABLED, this.updateAnimationsEnabled);
-    Services.prefs.removeObserver(this.PREF_REPORT_BREAKAGE_ENABLED, this.updateReportBreakageUI);
     Services.prefs.removeObserver(this.PREF_GLOBAL_TOGGLE, this.updateGlobalToggleVisibility);
   },
 
   get enabled() {
     return this.contentBlockingUIEnabled ? this.contentBlockingEnabled : TrackingProtection.enabled;
   },
 
   updateEnabled() {
@@ -513,16 +509,28 @@ var ContentBlocking = {
 
     this.content.toggleAttribute("detected", detected);
     this.content.toggleAttribute("hasException", hasException);
     this.content.toggleAttribute("active", active);
 
     this.iconBox.toggleAttribute("active", active);
     this.iconBox.toggleAttribute("hasException", this.enabled && hasException);
 
+    // For release (due to the large volume) we only want to receive reports
+    // for breakage that is directly related to third party cookie blocking.
+    if (this.reportBreakageEnabled ||
+        (ThirdPartyCookies.reportBreakageEnabled &&
+         ThirdPartyCookies.activated &&
+         !FastBlock.activated &&
+         !TrackingProtection.activated)) {
+      this.reportBreakageButton.removeAttribute("hidden");
+    } else {
+      this.reportBreakageButton.setAttribute("hidden", "true");
+    }
+
     if (isSimulated) {
       this.iconBox.removeAttribute("animate");
     } else if (active && webProgress.isTopLevel) {
       this.iconBox.setAttribute("animate", "true");
 
       if (!isBrowserPrivate) {
         let introCount = Services.prefs.getIntPref(this.prefIntroCount);
         if (introCount < this.MAX_INTROS) {
--- a/browser/base/content/test/trackingUI/browser_trackingUI_report_breakage.js
+++ b/browser/base/content/test/trackingUI/browser_trackingUI_report_breakage.js
@@ -1,15 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/trackingPage.html";
 const BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/benignPage.html";
+const COOKIE_PAGE = "http://not-tracking.example.com/browser/browser/base/content/test/trackingUI/cookiePage.html";
 
 const CB_PREF = "browser.contentblocking.enabled";
 const CB_UI_PREF = "browser.contentblocking.ui.enabled";
 const TP_PREF = "privacy.trackingprotection.enabled";
 const PREF_REPORT_BREAKAGE_ENABLED = "browser.contentblocking.reportBreakage.enabled";
 const PREF_REPORT_BREAKAGE_URL = "browser.contentblocking.reportBreakage.url";
 
 let {HttpServer} = ChromeUtils.import("resource://testing-common/httpd.js", {});
@@ -73,21 +74,33 @@ add_task(async function testReportBreaka
       url: BENIGN_PAGE,
       prefs: {
         "browser.contentblocking.enabled": true,
         "privacy.trackingprotection.enabled": true,
         "browser.contentblocking.reportBreakage.enabled": true,
       },
       buttonVisible: false,
     },
+    {
+      url: COOKIE_PAGE,
+      prefs: {
+        "browser.contentblocking.enabled": true,
+        "browser.fastblock.enabled": false,
+        "privacy.trackingprotection.enabled": false,
+        "network.cookie.cookieBehavior": Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER,
+        "browser.contentblocking.reportBreakage.enabled": false,
+        "browser.contentblocking.rejecttrackers.reportBreakage.enabled": true,
+      },
+      buttonVisible: true,
+    },
   ];
 
   for (let scenario of scenarios) {
     for (let pref in scenario.prefs) {
-      Services.prefs.setBoolPref(pref, scenario.prefs[pref]);
+      Preferences.set(pref, scenario.prefs[pref]);
     }
 
     let uri = Services.io.newURI(scenario.url);
     if (scenario.hasException) {
       Services.perms.add(uri, "trackingprotection", Services.perms.ALLOW_ACTION);
     }
 
     await BrowserTestUtils.withNewTab(scenario.url, async function() {