Bug 1511751 - Part 2 - Always show all categories in the cookies subpanel and note if they are empty. r=ewright
authorJohann Hofmann <jhofmann@mozilla.com>
Sat, 08 Dec 2018 00:05:57 +0000
changeset 508873 142c41711e58a31c64753fc9af704c3197a102e4
parent 508872 0f146f383c82188caa95b3c39739b2a85af16a1f
child 508874 a4c37fbac068d2e4e250d0d90c3c0f4c9129d8b0
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersewright
bugs1511751
milestone65.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 1511751 - Part 2 - Always show all categories in the cookies subpanel and note if they are empty. r=ewright Differential Revision: https://phabricator.services.mozilla.com/D13967
browser/base/content/browser-contentblocking.js
browser/base/content/test/trackingUI/browser_trackingUI_cookies_subview.js
browser/locales/en-US/chrome/browser/browser.properties
browser/themes/shared/controlcenter/panel.inc.css
--- a/browser/base/content/browser-contentblocking.js
+++ b/browser/base/content/browser-contentblocking.js
@@ -299,27 +299,36 @@ var ThirdPartyCookies = {
     let contentBlockingLogJSON = await gBrowser.selectedBrowser.getContentBlockingLog();
     let contentBlockingLog = JSON.parse(contentBlockingLogJSON);
 
     let categories = this._processContentBlockingLog(contentBlockingLog);
 
     this.subViewList.textContent = "";
 
     for (let category of ["firstParty", "trackers", "thirdParty"]) {
-      if (categories[category].length) {
-        let box = document.createXULElement("vbox");
-        let label = document.createXULElement("label");
-        label.className = "identity-popup-cookiesView-list-header";
-        label.textContent = gNavigatorBundle.getString(`contentBlocking.cookiesView.${category}.label`);
-        box.appendChild(label);
-        for (let info of categories[category]) {
-          box.appendChild(this._createListItem(info));
-        }
-        this.subViewList.appendChild(box);
+      let box = document.createXULElement("vbox");
+      let label = document.createXULElement("label");
+      label.className = "identity-popup-cookiesView-list-header";
+      label.textContent = gNavigatorBundle.getString(`contentBlocking.cookiesView.${category}.label`);
+      box.appendChild(label);
+
+      for (let info of categories[category]) {
+        box.appendChild(this._createListItem(info));
       }
+
+      // If the category is empty, add a label noting that to the user.
+      if (categories[category].length == 0) {
+        let emptyLabel = document.createXULElement("label");
+        emptyLabel.classList.add("identity-popup-content-blocking-empty-label");
+        emptyLabel.textContent =
+          gNavigatorBundle.getString(`contentBlocking.cookiesView.${category}.empty.label`);
+        box.appendChild(emptyLabel);
+      }
+
+      this.subViewList.appendChild(box);
     }
   },
 
   _hasException(origin) {
     for (let perm of Services.perms.getAllForPrincipal(gBrowser.contentPrincipal)) {
       if (perm.type == "3rdPartyStorage^" + origin || perm.type.startsWith("3rdPartyStorage^" + origin + "^")) {
         return true;
       }
--- a/browser/base/content/test/trackingUI/browser_trackingUI_cookies_subview.js
+++ b/browser/base/content/test/trackingUI/browser_trackingUI_cookies_subview.js
@@ -29,20 +29,20 @@ async function assertSitesListed(tracker
     let cookiesView = document.getElementById("identity-popup-cookiesView");
     let viewShown = BrowserTestUtils.waitForEvent(cookiesView, "ViewShown");
     categoryItem.click();
     await viewShown;
 
     ok(true, "Cookies view was shown");
 
     let listHeaders = cookiesView.querySelectorAll(".identity-popup-cookiesView-list-header");
-    is(listHeaders.length, 1, "We have 1 list header");
-    is(listHeaders[0].textContent,
-       gNavigatorBundle.getString(`contentBlocking.cookiesView.trackers.label`),
-       "The list header is for tracking cookies.");
+    is(listHeaders.length, 3, "We have 3 list headers");
+
+    let emptyLabels = cookiesView.querySelectorAll(".identity-popup-content-blocking-empty-label");
+    is(emptyLabels.length, 2, "We have 2 empty labels");
 
     let listItems = cookiesView.querySelectorAll(".identity-popup-content-blocking-list-item");
     is(listItems.length, 1, "We have 1 cookie in the list");
 
     let listItem = listItems[0];
     let label = listItem.querySelector(".identity-popup-content-blocking-list-host-label");
     is(label.value, "http://trackertest.org", "Has an item for trackertest.org");
     ok(BrowserTestUtils.is_visible(listItem), "List item is visible");
@@ -68,21 +68,18 @@ async function assertSitesListed(tracker
     is(result, undefined, "No securityChange events should be received");
 
     viewShown = BrowserTestUtils.waitForEvent(cookiesView, "ViewShown");
     categoryItem.click();
     await viewShown;
 
     ok(true, "Cookies view was shown");
 
-    listHeaders = cookiesView.querySelectorAll(".identity-popup-cookiesView-list-header");
-    is(listHeaders.length, 2, "We now have 2 list headers");
-    is(listHeaders[1].textContent,
-       gNavigatorBundle.getString(`contentBlocking.cookiesView.thirdParty.label`),
-       "The new list header is for third party cookies.");
+    emptyLabels = cookiesView.querySelectorAll(".identity-popup-content-blocking-empty-label");
+    is(emptyLabels.length, 1, "We have 1 empty label");
 
     listItems = cookiesView.querySelectorAll(".identity-popup-content-blocking-list-item");
     is(listItems.length, 2, "We have 2 cookies in the list");
 
     listItem = listItems[1];
     label = listItem.querySelector(".identity-popup-content-blocking-list-host-label");
     is(label.value, "https://test1.example.org", "Has an item for test1.example.org");
     ok(BrowserTestUtils.is_visible(listItem), "List item is visible");
@@ -106,21 +103,18 @@ async function assertSitesListed(tracker
     is(result, undefined, "No securityChange events should be received");
 
     viewShown = BrowserTestUtils.waitForEvent(cookiesView, "ViewShown");
     categoryItem.click();
     await viewShown;
 
     ok(true, "Cookies view was shown");
 
-    listHeaders = cookiesView.querySelectorAll(".identity-popup-cookiesView-list-header");
-    is(listHeaders.length, 3, "We now have 3 list headers");
-    is(listHeaders[0].textContent,
-       gNavigatorBundle.getString(`contentBlocking.cookiesView.firstParty.label`),
-       "The new list header is for first party cookies.");
+    emptyLabels = cookiesView.querySelectorAll(".identity-popup-content-blocking-empty-label");
+    is(emptyLabels.length, 0, "We have 0 empty label");
 
     listItems = cookiesView.querySelectorAll(".identity-popup-content-blocking-list-item");
     is(listItems.length, 3, "We have 2 cookies in the list");
 
     listItem = listItems[0];
     label = listItem.querySelector(".identity-popup-content-blocking-list-host-label");
     is(label.value, "http://not-tracking.example.com", "Has an item for the first party");
     ok(BrowserTestUtils.is_visible(listItem), "List item is visible");
@@ -159,22 +153,16 @@ add_task(async function testCookiesSubVi
     ok(BrowserTestUtils.is_visible(categoryItem), "TP category item is visible");
     let cookiesView = document.getElementById("identity-popup-cookiesView");
     let viewShown = BrowserTestUtils.waitForEvent(cookiesView, "ViewShown");
     categoryItem.click();
     await viewShown;
 
     ok(true, "Cookies view was shown");
 
-    let listHeaders = cookiesView.querySelectorAll(".identity-popup-cookiesView-list-header");
-    is(listHeaders.length, 1, "We have 1 list header");
-    is(listHeaders[0].textContent,
-       gNavigatorBundle.getString(`contentBlocking.cookiesView.trackers.label`),
-       "The list header is for tracking cookies.");
-
     let listItems = cookiesView.querySelectorAll(".identity-popup-content-blocking-list-item");
     is(listItems.length, 1, "We have 1 cookie in the list");
 
     let listItem = listItems[0];
     let label = listItem.querySelector(".identity-popup-content-blocking-list-host-label");
     is(label.value, "http://trackertest.org", "Has an item for trackertest.org");
     ok(BrowserTestUtils.is_visible(listItem), "List item is visible");
     ok(listItem.classList.contains("allowed"), "Indicates whether the cookie was blocked or allowed");
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -525,18 +525,33 @@ contentBlocking.cookies.allowed.label=Al
 #   contentBlocking.cookies.blockingUnvisited.label,contentBlocking.cookies.blockingAll.label):
 # See localization note for contentBlocking.trackers.blocking.label to get recommendations on translating "Blocking".
 contentBlocking.cookies.blockingTrackers.label=Blocking Tracking Cookies
 contentBlocking.cookies.blocking3rdParty.label=Blocking Third-Party Cookies
 contentBlocking.cookies.blockingUnvisited.label=Blocking Unvisited Site Cookies
 contentBlocking.cookies.blockingAll.label=Blocking All Cookies
 
 contentBlocking.cookiesView.firstParty.label=From This Site
+# LOCALIZATION NOTE (contentBlocking.cookiesView.firstParty.empty.label):
+#  This references the header from contentBlocking.cookiesView.firstParty.label:
+#  "[Cookies] From This Site: None detected on this site".
+contentBlocking.cookiesView.firstParty.empty.label=None detected on this site
+
 contentBlocking.cookiesView.trackers.label=Tracking Cookies
+# LOCALIZATION NOTE (contentBlocking.cookiesView.trackers.empty.label):
+#  This references the header from contentBlocking.cookiesView.trackers.label:
+#  "Tracking Cookies: None detected on this site".
+contentBlocking.cookiesView.trackers.empty.label=None detected on this site
+
 contentBlocking.cookiesView.thirdParty.label=Third-Party Cookies
+# LOCALIZATION NOTE (contentBlocking.cookiesView.thirdParty.empty.label):
+#  This references the header from contentBlocking.cookiesView.thirdParty.label:
+#  "Third-Party Cookies: None detected on this site".
+contentBlocking.cookiesView.thirdParty.empty.label=None detected on this site
+
 # LOCALIZATION NOTE (contentBlocking.cookiesView.allowed.label):
 #   This label is shown next to a cookie origin in the cookies subview.
 #   It forms the end of the (imaginary) sentence "www.example.com [was] Allowed"
 contentBlocking.cookiesView.allowed.label=Allowed
 # LOCALIZATION NOTE (contentBlocking.cookiesView.blocked.label):
 #   This label is shown next to a cookie origin in the cookies subview.
 #   It forms the end of the (imaginary) sentence "www.example.com [was] Blocked"
 contentBlocking.cookiesView.blocked.label=Blocked
--- a/browser/themes/shared/controlcenter/panel.inc.css
+++ b/browser/themes/shared/controlcenter/panel.inc.css
@@ -156,16 +156,17 @@
   display: inline;
   padding-inline-end: 25px;
   padding-inline-start: 0px;
   color: var(--panel-disabled-color);
 }
 
 /* CONTENT */
 
+.identity-popup-content-blocking-empty-label,
 #tracking-protection-preferences-button > .toolbarbutton-text,
 .identity-popup-footer,
 .tracking-protection-button,
 #identity-popup-trackersView-strict-info > label,
 .identity-popup-cookiesView-list-header,
 .identity-popup-content-blocking-list-item > label,
 #identity-popup-mainView-panel-header > label,
 #identity-popup-trackersView > .panel-header,
@@ -434,16 +435,26 @@ description#identity-popup-content-verif
 
 /* This subview could get filled with a lot of trackers, set a maximum size
  * and allow it to scroll vertically.*/
 #identity-popup-cookiesView,
 #identity-popup-trackersView {
   max-height: 600px;
 }
 
+.identity-popup-content-blocking-empty-label {
+  color: var(--panel-disabled-color);
+}
+
+#identity-popup-cookiesView .identity-popup-content-blocking-empty-label {
+  margin-inline-start: 24px;
+  margin-top: 2px;
+  margin-bottom: 4px;
+}
+
 .identity-popup-cookiesView-list-header {
   color: var(--panel-disabled-color);
   margin: 5px 0;
 }
 
 .identity-popup-content-blocking-list {
   padding: 5px 20px;
   -moz-box-flex: 1;