Bug 1492576 - If no protection is enabled, don't offer the user the ability to disable protection or report a problem. r=Ehsan a=pascalc
authorJohann Hofmann <jhofmann@mozilla.com>
Fri, 21 Sep 2018 01:45:19 +0000
changeset 492650 b829bb18e57a059eed1df5443aaa9f45c1db143a
parent 492649 ff52a0eb02c159e5fe93906bd2078200ddc23c25
child 492651 ae6e3d1a27dde6224d3cc010af0001c34d9874a1
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEhsan, pascalc
bugs1492576
milestone63.0
Bug 1492576 - If no protection is enabled, don't offer the user the ability to disable protection or report a problem. r=Ehsan a=pascalc Differential Revision: https://phabricator.services.mozilla.com/D6408
browser/base/content/browser-contentblocking.js
browser/base/content/test/trackingUI/browser_trackingUI_state.js
browser/themes/shared/controlcenter/panel.inc.css
--- a/browser/base/content/browser-contentblocking.js
+++ b/browser/base/content/browser-contentblocking.js
@@ -467,16 +467,17 @@ var ContentBlocking = {
 
     // Check whether the user has added an exception for this site.
     let type =  isBrowserPrivate ? "trackingprotection-pb" : "trackingprotection";
     let hasException = Services.perms.testExactPermission(baseURI, type) ==
       Services.perms.ALLOW_ACTION;
 
     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);
 
     if (isSimulated) {
       this.iconBox.removeAttribute("animate");
     } else if (active && webProgress.isTopLevel) {
       this.iconBox.setAttribute("animate", "true");
--- a/browser/base/content/test/trackingUI/browser_trackingUI_state.js
+++ b/browser/base/content/test/trackingUI/browser_trackingUI_state.js
@@ -61,16 +61,17 @@ function clickButton(sel) {
   let el = win.document.querySelector(sel);
   el.doCommand();
 }
 
 function testBenignPage() {
   info("Non-tracking content must not be blocked");
   ok(!ContentBlocking.content.hasAttribute("detected"), "no trackers are detected");
   ok(!ContentBlocking.content.hasAttribute("hasException"), "content shows no exception");
+  ok(!ContentBlocking.content.hasAttribute("active"), "content is not active");
 
   ok(!ContentBlocking.iconBox.hasAttribute("active"), "shield is not active");
   ok(!ContentBlocking.iconBox.hasAttribute("hasException"), "icon box shows no exception");
   ok(!ContentBlocking.iconBox.hasAttribute("tooltiptext"), "icon box has no tooltip");
 
   ok(BrowserTestUtils.is_hidden(ContentBlocking.iconBox), "icon box is hidden");
   ok(hidden("#tracking-action-block"), "blockButton is hidden");
   ok(hidden("#tracking-action-unblock"), "unblockButton is hidden");
@@ -84,16 +85,17 @@ function testBenignPage() {
     ok(hidden("#identity-popup-content-blocking-category-list"), "category list is hidden");
   }
 }
 
 function testBenignPageWithException() {
   info("Non-tracking content must not be blocked");
   ok(!ContentBlocking.content.hasAttribute("detected"), "no trackers are detected");
   ok(ContentBlocking.content.hasAttribute("hasException"), "content shows exception");
+  ok(!ContentBlocking.content.hasAttribute("active"), "content is not active");
 
   ok(!ContentBlocking.iconBox.hasAttribute("active"), "shield is not active");
   is(ContentBlocking.iconBox.hasAttribute("hasException"), ContentBlocking.enabled,
     "shield shows exception if CB is on");
   is(ContentBlocking.iconBox.getAttribute("tooltiptext"),
      gNavigatorBundle.getString("trackingProtection.icon.disabledTooltip"), "correct tooltip");
 
   is(!BrowserTestUtils.is_hidden(ContentBlocking.iconBox), ContentBlocking.enabled,
@@ -129,37 +131,37 @@ function testTrackingPage(window) {
   info("Tracking content must be blocked");
   ok(ContentBlocking.content.hasAttribute("detected"), "trackers are detected");
   ok(!ContentBlocking.content.hasAttribute("hasException"), "content shows no exception");
 
   let isPrivateBrowsing = PrivateBrowsingUtils.isWindowPrivate(window);
   let blockedByTP = areTrackersBlocked(isPrivateBrowsing);
   is(BrowserTestUtils.is_visible(ContentBlocking.iconBox), blockedByTP,
      "icon box is" + (blockedByTP ? "" : " not") + " visible");
+  is(ContentBlocking.content.hasAttribute("active"), blockedByTP,
+      "content is" + (blockedByTP ? "" : " not") + " active");
   is(ContentBlocking.iconBox.hasAttribute("active"), blockedByTP,
       "shield is" + (blockedByTP ? "" : " not") + " active");
   ok(!ContentBlocking.iconBox.hasAttribute("hasException"), "icon box shows no exception");
   is(ContentBlocking.iconBox.getAttribute("tooltiptext"),
      blockedByTP ? gNavigatorBundle.getString("trackingProtection.icon.activeTooltip") : "",
      "correct tooltip");
 
   ok(hidden("#tracking-action-block"), "blockButton is hidden");
 
   let isWindowPrivate = PrivateBrowsingUtils.isWindowPrivate(window);
   let cbUIEnabled = Services.prefs.getBoolPref(CB_UI_PREF);
-  let tpEnabled = isWindowPrivate ? Services.prefs.getBoolPref(TP_PB_PREF) : Services.prefs.getBoolPref(TP_PREF);
-  let blockingEnabled = cbUIEnabled ? Services.prefs.getBoolPref(CB_PREF) : tpEnabled;
   if (isWindowPrivate) {
     ok(hidden("#tracking-action-unblock"), "unblockButton is hidden");
-    is(!hidden("#tracking-action-unblock-private"), blockingEnabled,
-       "unblockButtonPrivate is" + (blockingEnabled ? "" : " not") + " visible");
+    is(!hidden("#tracking-action-unblock-private"), blockedByTP,
+       "unblockButtonPrivate is" + (blockedByTP ? "" : " not") + " visible");
   } else {
     ok(hidden("#tracking-action-unblock-private"), "unblockButtonPrivate is hidden");
-    is(!hidden("#tracking-action-unblock"), blockingEnabled,
-       "unblockButton is" + (blockingEnabled ? "" : " not") + " hidden");
+    is(!hidden("#tracking-action-unblock"), blockedByTP,
+       "unblockButton is" + (blockedByTP ? "" : " not") + " visible");
   }
 
   ok(hidden("#identity-popup-content-blocking-not-detected"), "blocking not detected label is hidden");
   ok(!hidden("#identity-popup-content-blocking-detected"), "blocking detected label is visible");
 
   if (cbUIEnabled) {
     ok(!hidden("#identity-popup-content-blocking-category-list"), "category list is visible");
     let category;
@@ -181,17 +183,18 @@ function testTrackingPageUnblocked(block
   info("Tracking content must be white-listed and not blocked");
   ok(ContentBlocking.content.hasAttribute("detected"), "trackers are detected");
   ok(ContentBlocking.content.hasAttribute("hasException"), "content shows exception");
 
   let isWindowPrivate = PrivateBrowsingUtils.isWindowPrivate(window);
   let cbUIEnabled = Services.prefs.getBoolPref(CB_UI_PREF);
   let tpEnabled = isWindowPrivate ? Services.prefs.getBoolPref(TP_PB_PREF) : Services.prefs.getBoolPref(TP_PREF);
   let blockingEnabled = cbUIEnabled ? Services.prefs.getBoolPref(CB_PREF) : tpEnabled;
-  ok(!ContentBlocking.iconBox.hasAttribute("active"), "shield is active");
+  ok(!ContentBlocking.content.hasAttribute("active"), "content is not active");
+  ok(!ContentBlocking.iconBox.hasAttribute("active"), "shield is not active");
   is(ContentBlocking.iconBox.hasAttribute("hasException"), blockingEnabled,
      "shield" + (blockingEnabled ? " shows" : " doesn't show") + " exception");
   is(ContentBlocking.iconBox.getAttribute("tooltiptext"),
      gNavigatorBundle.getString("trackingProtection.icon.disabledTooltip"), "correct tooltip");
 
   is(BrowserTestUtils.is_visible(ContentBlocking.iconBox), blockingEnabled,
      "icon box is" + (blockingEnabled ? "" : " not") + " visible");
   is(hidden("#tracking-action-block"), !blockingEnabled,
@@ -219,16 +222,17 @@ function testTrackingPageUnblocked(block
       "TP category item is not set to blocked");
   }
 }
 
 function testTrackingPageWithCBDisabled() {
   info("Tracking content must be white-listed and not blocked");
   ok(ContentBlocking.content.hasAttribute("detected"), "trackers are detected");
   ok(!ContentBlocking.content.hasAttribute("hasException"), "content shows no exception");
+  ok(!ContentBlocking.content.hasAttribute("active"), "content is not active");
 
   ok(!ContentBlocking.iconBox.hasAttribute("active"), "shield is not active");
   ok(!ContentBlocking.iconBox.hasAttribute("hasException"), "shield shows no exception");
   ok(!ContentBlocking.iconBox.getAttribute("tooltiptext"), "icon box has no tooltip");
 
   ok(BrowserTestUtils.is_hidden(ContentBlocking.iconBox), "icon box is hidden");
   ok(hidden("#tracking-action-block"), "blockButton is hidden");
   ok(hidden("#tracking-action-unblock"), "unblockButton is hidden");
--- a/browser/themes/shared/controlcenter/panel.inc.css
+++ b/browser/themes/shared/controlcenter/panel.inc.css
@@ -482,25 +482,25 @@ description#identity-popup-content-verif
 #identity-popup-content-blocking-report-breakage {
   margin-top: 6px;
 }
 
 /* Hide the "report breakage" button if TP is off or we have not detected any
  * trackers (except if the user added an exception, in which case they might
  * still (especially!) want to report the breakage). */
 #identity-popup-content-blocking-content:not([enabled]) #identity-popup-content-blocking-report-breakage,
-#identity-popup-content-blocking-content:not([detected]):not([hasException]) #identity-popup-content-blocking-report-breakage {
+#identity-popup-content-blocking-content:not([active]):not([hasException]) #identity-popup-content-blocking-report-breakage {
   display: none;
 }
 
 /* Show the right action buttons depending on content state */
 /* Offer to temporarily add an exception in private mode. */
-#main-window:not([privatebrowsingmode]) #identity-popup-content-blocking-content[enabled][detected]:not([hasException]) > #tracking-action-unblock,
+#main-window:not([privatebrowsingmode]) #identity-popup-content-blocking-content[active]:not([hasException]) > #tracking-action-unblock,
 /* Offer to permanently add an exception in normal mode. */
-#main-window[privatebrowsingmode] #identity-popup-content-blocking-content[enabled][detected]:not([hasException]) > #tracking-action-unblock-private,
+#main-window[privatebrowsingmode] #identity-popup-content-blocking-content[active]:not([hasException]) > #tracking-action-unblock-private,
 /* If there's an exception just offer to remove the exception again. */
 #identity-popup-content-blocking-content[enabled][hasException] > #tracking-action-block {
   display: -moz-box;
 }
 
 /* PERMISSIONS */
 
 #identity-popup-permissions-content {