Bug 1473685 - When a user "disables protection" on a site, and no trackers are detected, indicate that TP is turned off instead of on. r=nhnt11 draft
authorJohann Hofmann <jhofmann@mozilla.com>
Mon, 09 Jul 2018 12:34:44 +0200
changeset 815867 86096c64d2fa533dc8d8632660b16e18e0b6995c
parent 815516 ffb7b5015fc331bdc4c5e6ab52b9de669faa8864
push id115668
push userjhofmann@mozilla.com
push dateTue, 10 Jul 2018 04:44:59 +0000
reviewersnhnt11
bugs1473685
milestone63.0a1
Bug 1473685 - When a user "disables protection" on a site, and no trackers are detected, indicate that TP is turned off instead of on. r=nhnt11 MozReview-Commit-ID: 9JjCK1GYMbC
browser/base/content/test/trackingUI/browser_trackingUI_state.js
browser/themes/shared/controlcenter/panel.inc.css
--- a/browser/base/content/test/trackingUI/browser_trackingUI_state.js
+++ b/browser/base/content/test/trackingUI/browser_trackingUI_state.js
@@ -64,16 +64,17 @@ function testBenignPage() {
   ok(hidden("#tracking-loaded"), "labelTrackingLoaded is hidden");
   ok(hidden("#tracking-blocked"), "labelTrackingBlocked is hidden");
 }
 
 function testBenignPageWithException() {
   info("Non-tracking content must not be blocked");
   ok(!TrackingProtection.container.hidden, "The container is visible");
   ok(!TrackingProtection.content.hasAttribute("state"), "content: no state");
+  ok(TrackingProtection.content.hasAttribute("hasException"), "content has exception attribute");
   ok(!TrackingProtection.icon.hasAttribute("state"), "icon: no state");
   ok(!TrackingProtection.icon.hasAttribute("tooltiptext"), "icon: no tooltip");
 
   ok(hidden("#tracking-protection-icon"), "icon is hidden");
   is(!hidden("#tracking-action-block"), TrackingProtection.enabled,
      "blockButton is visible if TP is on");
   ok(hidden("#tracking-action-unblock"), "unblockButton is hidden");
   ok(!hidden("#tracking-protection-preferences-button"), "preferences button is visible");
@@ -187,21 +188,32 @@ async function testTrackingProtectionEna
 async function testTrackingProtectionDisabled(tab) {
   info("Testing with Tracking Protection DISABLED.");
 
   info("Load a test page not containing tracking elements");
   await promiseTabLoadEvent(tab, BENIGN_PAGE);
   testBenignPage();
 
   info("Load a test page not containing tracking elements which has an exception.");
+  let isPrivateBrowsing = PrivateBrowsingUtils.isWindowPrivate(tab.ownerGlobal);
   let uri = Services.io.newURI("https://example.org/");
-  Services.perms.add(uri, "trackingprotection", Services.perms.ALLOW_ACTION);
+  if (isPrivateBrowsing) {
+    PrivateBrowsingUtils.addToTrackingAllowlist(uri);
+  } else {
+    Services.perms.add(uri, "trackingprotection", Services.perms.ALLOW_ACTION);
+  }
+
   await promiseTabLoadEvent(tab, uri.spec);
   testBenignPageWithException();
-  Services.perms.remove(uri, "trackingprotection");
+
+  if (isPrivateBrowsing) {
+    PrivateBrowsingUtils.removeFromTrackingAllowlist(uri);
+  } else {
+    Services.perms.remove(uri, "trackingprotection");
+  }
 
   info("Load a test page containing tracking elements");
   await promiseTabLoadEvent(tab, TRACKING_PAGE);
   testTrackingPageUnblocked();
 }
 
 add_task(async function testNormalBrowsing() {
   await UrlClassifierTestUtils.addTestTrackers();
--- a/browser/themes/shared/controlcenter/panel.inc.css
+++ b/browser/themes/shared/controlcenter/panel.inc.css
@@ -302,29 +302,32 @@ description#identity-popup-content-verif
 
 /* TRACKING PROTECTION */
 
 #tracking-protection-content {
   background-image: url("chrome://browser/skin/controlcenter/tracking-protection.svg");
 }
 
 #tracking-protection-content[enabled="false"],
+#tracking-protection-content[hasException],
 #tracking-protection-content[state="loaded-tracking-content"] {
   background-image: url("chrome://browser/skin/controlcenter/tracking-protection-disabled.svg");
 }
 
 /* Show the "on" label by default, except when TP is disabled or there's a local exception. */
 #tracking-protection-label-off,
 #tracking-protection-content[enabled="false"] #tracking-protection-label-on,
+#tracking-protection-content[hasException] #tracking-protection-label-on,
 #tracking-protection-content[state="loaded-tracking-content"] #tracking-protection-label-on {
   display: none;
 }
 
 #tracking-protection-label-on,
 #tracking-protection-content[enabled="false"] #tracking-protection-label-off,
+#tracking-protection-content[hasException] #tracking-protection-label-off,
 #tracking-protection-content[state="loaded-tracking-content"] #tracking-protection-label-off {
   display: -moz-box;
 }
 
 #tracking-protection-content > description {
   display: none;
 }