Bug 1501992 - Add tests for the cookies subpanel in the control center. r=Ehsan
☠☠ backed out by 08e30fbc9ab1 ☠ ☠
authorJohann Hofmann <jhofmann@mozilla.com>
Sat, 01 Dec 2018 23:25:44 +0000
changeset 505548 6cb8a465440afd06dc059f209aba683b2e2c0cb5
parent 505547 b54b117c15e9abe79342925671ff13a790c1c454
child 505549 be65d09ef059e78daf60df9737503cfcb6dc8a86
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEhsan
bugs1501992
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 1501992 - Add tests for the cookies subpanel in the control center. r=Ehsan Differential Revision: https://phabricator.services.mozilla.com/D13146
browser/base/content/test/trackingUI/benignPage.html
browser/base/content/test/trackingUI/browser.ini
browser/base/content/test/trackingUI/browser_trackingUI_categories.js
browser/base/content/test/trackingUI/browser_trackingUI_cookies_subview.js
browser/base/content/test/trackingUI/browser_trackingUI_fetch.js
browser/base/content/test/trackingUI/browser_trackingUI_open_preferences.js
browser/base/content/test/trackingUI/browser_trackingUI_pbmode_exceptions.js
browser/base/content/test/trackingUI/browser_trackingUI_report_breakage.js
browser/base/content/test/trackingUI/browser_trackingUI_state.js
browser/base/content/test/trackingUI/browser_trackingUI_telemetry.js
browser/base/content/test/trackingUI/browser_trackingUI_trackers_subview.js
browser/base/content/test/trackingUI/head.js
browser/base/content/test/trackingUI/trackingAPI.js
--- a/browser/base/content/test/trackingUI/benignPage.html
+++ b/browser/base/content/test/trackingUI/benignPage.html
@@ -2,11 +2,17 @@
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 <html dir="ltr" xml:lang="en-US" lang="en-US">
   <head>
     <meta charset="utf8">
   </head>
   <body>
-    <iframe src="http://not-tracking.example.com/"></iframe>
+    <!--TODO: We used to have an iframe here, to double-check that benign-->
+    <!--iframes may be included in pages. However, the cookie restrictions-->
+    <!--project introduced a change that declared blockable content to be-->
+    <!--found on any page that embeds iframes, rendering this unusable for-->
+    <!--our purposes. That's not ideal and we intend to restore this iframe.-->
+    <!--(See bug 1511303 for a more detailed technical explanation.)-->
+    <!--<iframe src="http://not-tracking.example.com/"></iframe>-->
   </body>
 </html>
--- a/browser/base/content/test/trackingUI/browser.ini
+++ b/browser/base/content/test/trackingUI/browser.ini
@@ -8,16 +8,17 @@ support-files =
   trackingAPI.js
   trackingPage.html
 
 [browser_trackingUI_3.js]
 [browser_trackingUI_animation.js]
 [browser_trackingUI_animation_2.js]
 [browser_trackingUI_appMenu.js]
 [browser_trackingUI_categories.js]
+[browser_trackingUI_cookies_subview.js]
 [browser_trackingUI_fetch.js]
 support-files =
   file_trackingUI_fetch.html
   file_trackingUI_fetch.js
   file_trackingUI_fetch.js^headers^
 [browser_trackingUI_open_preferences.js]
 [browser_trackingUI_pbmode_exceptions.js]
 [browser_trackingUI_report_breakage.js]
--- a/browser/base/content/test/trackingUI/browser_trackingUI_categories.js
+++ b/browser/base/content/test/trackingUI/browser_trackingUI_categories.js
@@ -11,19 +11,17 @@ registerCleanupFunction(function() {
   Services.prefs.clearUserPref(TP_PB_PREF);
   Services.prefs.clearUserPref(TPC_PREF);
   Services.prefs.clearUserPref(TT_PREF);
   Services.prefs.clearUserPref(CAT_PREF);
 });
 
 add_task(async function testCategoryLabelsInControlPanel() {
   await BrowserTestUtils.withNewTab("http://www.example.com", async function() {
-    let promisePanelOpen = BrowserTestUtils.waitForEvent(gIdentityHandler._identityPopup, "popupshown");
-    gIdentityHandler._identityBox.click();
-    await promisePanelOpen;
+    await openIdentityPopup();
 
     let preferencesButton = document.getElementById("tracking-protection-preferences-button");
     ok(preferencesButton.label, "The preferencesButton label exists");
 
     Services.prefs.setStringPref(CAT_PREF, "strict");
     await TestUtils.waitForCondition(() => preferencesButton.label ==
       gNavigatorBundle.getString("contentBlocking.category.strict"));
     is(preferencesButton.label, gNavigatorBundle.getString("contentBlocking.category.strict"),
@@ -65,8 +63,60 @@ add_task(async function testCategoryLabe
 
     Services.prefs.setStringPref(CAT_PREF, "custom");
     await TestUtils.waitForCondition(() => appMenuCategoryLabel.value ==
       gNavigatorBundle.getString("contentBlocking.category.custom"));
     is(appMenuCategoryLabel.value, gNavigatorBundle.getString("contentBlocking.category.custom"),
       "The appMenuCategory label has been changed to custom");
   });
 });
+
+add_task(async function testSubcategoryLabels() {
+  await BrowserTestUtils.withNewTab("http://www.example.com", async function() {
+    let categoryLabel =
+      document.getElementById("identity-popup-content-blocking-tracking-protection-state-label");
+
+    Services.prefs.setBoolPref(TP_PREF, true);
+    await TestUtils.waitForCondition(() => categoryLabel.textContent ==
+      gNavigatorBundle.getString("contentBlocking.trackers.blocked.label"),
+      "The category label has updated correctly");
+    is(categoryLabel.textContent, gNavigatorBundle.getString("contentBlocking.trackers.blocked.label"));
+
+    Services.prefs.setBoolPref(TP_PREF, false);
+    await TestUtils.waitForCondition(() => categoryLabel.textContent ==
+      gNavigatorBundle.getString("contentBlocking.trackers.allowed.label"),
+      "The category label has updated correctly");
+    is(categoryLabel.textContent, gNavigatorBundle.getString("contentBlocking.trackers.allowed.label"));
+
+    categoryLabel =
+      document.getElementById("identity-popup-content-blocking-cookies-state-label");
+
+    Services.prefs.setIntPref(TPC_PREF, Ci.nsICookieService.BEHAVIOR_ACCEPT);
+    await TestUtils.waitForCondition(() => categoryLabel.textContent ==
+      gNavigatorBundle.getString("contentBlocking.cookies.allowed.label"),
+      "The category label has updated correctly");
+    is(categoryLabel.textContent, gNavigatorBundle.getString("contentBlocking.cookies.allowed.label"));
+
+    Services.prefs.setIntPref(TPC_PREF, Ci.nsICookieService.BEHAVIOR_REJECT);
+    await TestUtils.waitForCondition(() => categoryLabel.textContent ==
+      gNavigatorBundle.getString("contentBlocking.cookies.allBlocked.label"),
+      "The category label has updated correctly");
+    is(categoryLabel.textContent, gNavigatorBundle.getString("contentBlocking.cookies.allBlocked.label"));
+
+    Services.prefs.setIntPref(TPC_PREF, Ci.nsICookieService.BEHAVIOR_REJECT_FOREIGN);
+    await TestUtils.waitForCondition(() => categoryLabel.textContent ==
+      gNavigatorBundle.getString("contentBlocking.cookies.3rdPartyBlocked.label"),
+      "The category label has updated correctly");
+    is(categoryLabel.textContent, gNavigatorBundle.getString("contentBlocking.cookies.3rdPartyBlocked.label"));
+
+    Services.prefs.setIntPref(TPC_PREF, Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER);
+    await TestUtils.waitForCondition(() => categoryLabel.textContent ==
+      gNavigatorBundle.getString("contentBlocking.cookies.trackersBlocked.label"),
+      "The category label has updated correctly");
+    is(categoryLabel.textContent, gNavigatorBundle.getString("contentBlocking.cookies.trackersBlocked.label"));
+
+    Services.prefs.setIntPref(TPC_PREF, Ci.nsICookieService.BEHAVIOR_LIMIT_FOREIGN);
+    await TestUtils.waitForCondition(() => categoryLabel.textContent ==
+      gNavigatorBundle.getString("contentBlocking.cookies.unvisitedBlocked.label"),
+      "The category label has updated correctly");
+    is(categoryLabel.textContent, gNavigatorBundle.getString("contentBlocking.cookies.unvisitedBlocked.label"));
+  });
+});
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/trackingUI/browser_trackingUI_cookies_subview.js
@@ -0,0 +1,190 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
+
+"use strict";
+
+const COOKIE_PAGE = "http://not-tracking.example.com/browser/browser/base/content/test/trackingUI/cookiePage.html";
+
+const TPC_PREF = "network.cookie.cookieBehavior";
+
+add_task(async function setup() {
+  // Avoid the content blocking tour interfering with our tests by popping up.
+  await SpecialPowers.pushPrefEnv({set: [[ContentBlocking.prefIntroCount, ContentBlocking.MAX_INTROS]]});
+  await UrlClassifierTestUtils.addTestTrackers();
+
+  registerCleanupFunction(() => {
+    UrlClassifierTestUtils.cleanupTestTrackers();
+  });
+});
+
+async function assertSitesListed(trackersBlocked, thirdPartyBlocked, firstPartyBlocked) {
+  await BrowserTestUtils.withNewTab(COOKIE_PAGE, async function(browser) {
+    await openIdentityPopup();
+
+    let categoryItem =
+      document.getElementById("identity-popup-content-blocking-category-cookies");
+    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");
+    is(listItem.classList.contains("allowed"), !trackersBlocked,
+      "Indicates whether the cookie was blocked or allowed");
+
+    let mainView = document.getElementById("identity-popup-mainView");
+    viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
+    let backButton = cookiesView.querySelector(".subviewbutton-back");
+    backButton.click();
+    await viewShown;
+
+    ok(true, "Main view was shown");
+
+    let change = waitForSecurityChange();
+    let timeoutPromise = new Promise(resolve => setTimeout(resolve, 1000));
+
+    await ContentTask.spawn(browser, {}, function() {
+      content.postMessage("third-party-cookie", "*");
+    });
+
+    let result = await Promise.race([change, timeoutPromise]);
+    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.");
+
+    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");
+    is(listItem.classList.contains("allowed"), !thirdPartyBlocked,
+      "Indicates whether the cookie was blocked or allowed");
+
+    viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
+    backButton.click();
+    await viewShown;
+
+    ok(true, "Main view was shown");
+
+    change = waitForSecurityChange();
+    timeoutPromise = new Promise(resolve => setTimeout(resolve, 1000));
+
+    await ContentTask.spawn(browser, {}, function() {
+      content.postMessage("first-party-cookie", "*");
+    });
+
+    result = await Promise.race([change, timeoutPromise]);
+    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.");
+
+    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");
+    is(listItem.classList.contains("allowed"), !firstPartyBlocked,
+      "Indicates whether the cookie was blocked or allowed");
+  });
+}
+
+add_task(async function testCookiesSubView() {
+  info("Testing cookies subview with reject tracking cookies.");
+  Services.prefs.setIntPref(TPC_PREF, Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER);
+  await assertSitesListed(true, false, false);
+  info("Testing cookies subview with reject third party cookies.");
+  Services.prefs.setIntPref(TPC_PREF, Ci.nsICookieService.BEHAVIOR_REJECT_FOREIGN);
+  await assertSitesListed(true, true, false);
+  info("Testing cookies subview with reject all cookies.");
+  Services.prefs.setIntPref(TPC_PREF, Ci.nsICookieService.BEHAVIOR_REJECT);
+  await assertSitesListed(true, true, true);
+  info("Testing cookies subview with accept all cookies.");
+  Services.prefs.setIntPref(TPC_PREF, Ci.nsICookieService.BEHAVIOR_ACCEPT);
+  await assertSitesListed(false, false, false);
+
+  Services.prefs.clearUserPref(TPC_PREF);
+});
+
+add_task(async function testCookiesSubViewAllowed() {
+  Services.prefs.setIntPref(TPC_PREF, Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER);
+  let principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin("http://trackertest.org/");
+  Services.perms.addFromPrincipal(principal, "cookie", Services.perms.ALLOW_ACTION);
+
+  await BrowserTestUtils.withNewTab(COOKIE_PAGE, async function(browser) {
+    await openIdentityPopup();
+
+    let categoryItem =
+      document.getElementById("identity-popup-content-blocking-category-cookies");
+    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");
+
+    let button = listItem.querySelector(".identity-popup-permission-remove-button");
+    ok(BrowserTestUtils.is_visible(button), "Permission remove button is visible");
+    button.click();
+    is(Services.perms.testExactPermissionFromPrincipal(principal, "cookie"), Services.perms.UNKNOWN_ACTION, "Button click should remove cookie pref.");
+    ok(!listItem.classList.contains("allowed"), "Has removed the allowed class");
+  });
+
+  Services.prefs.clearUserPref(TPC_PREF);
+});
--- a/browser/base/content/test/trackingUI/browser_trackingUI_fetch.js
+++ b/browser/base/content/test/trackingUI/browser_trackingUI_fetch.js
@@ -1,27 +1,10 @@
 const URL = "http://mochi.test:8888/browser/browser/base/content/test/trackingUI/file_trackingUI_fetch.html";
 
-function waitForSecurityChange(numChanges = 1) {
-  return new Promise(resolve => {
-    let n = 0;
-    let listener = {
-      onSecurityChange() {
-        n = n + 1;
-        info("Received onSecurityChange event " + n + " of " + numChanges);
-        if (n >= numChanges) {
-          gBrowser.removeProgressListener(listener);
-          resolve();
-        }
-      },
-    };
-    gBrowser.addProgressListener(listener);
-  });
-}
-
 add_task(async function test_fetch() {
   await SpecialPowers.pushPrefEnv({ set: [
     ["privacy.trackingprotection.enabled", true],
   ]});
 
   await BrowserTestUtils.withNewTab({ gBrowser, url: URL }, async function(newTabBrowser) {
     let securityChange = waitForSecurityChange();
     await ContentTask.spawn(newTabBrowser, null, async function() {
--- a/browser/base/content/test/trackingUI/browser_trackingUI_open_preferences.js
+++ b/browser/base/content/test/trackingUI/browser_trackingUI_open_preferences.js
@@ -59,18 +59,16 @@ add_task(async function testOpenPreferen
 });
 
 // Tests that clicking the contentblocking category items "add blocking" labels
 // links to about:preferences
 add_task(async function testOpenPreferencesFromAddBlockingButtons() {
   SpecialPowers.pushPrefEnv({set: [
     [TP_PREF, false],
     [TPC_PREF, Ci.nsICookieService.BEHAVIOR_ACCEPT],
-    [TP_UI_PREF, true],
-    [RT_UI_PREF, true],
   ]});
 
   await BrowserTestUtils.withNewTab(TRACKING_PAGE, async function() {
     let addBlockingButtons = document.querySelectorAll(".identity-popup-content-blocking-category-add-blocking");
     for (let button of addBlockingButtons) {
       let promisePanelOpen = BrowserTestUtils.waitForEvent(gIdentityHandler._identityPopup, "popupshown");
       gIdentityHandler._identityBox.click();
       await promisePanelOpen;
--- a/browser/base/content/test/trackingUI/browser_trackingUI_pbmode_exceptions.js
+++ b/browser/base/content/test/trackingUI/browser_trackingUI_pbmode_exceptions.js
@@ -52,22 +52,16 @@ function testTrackingPage(window) {
     ok(!hidden("#tracking-action-unblock-private"), "unblockButtonPrivate is visible");
   } else {
     ok(!hidden("#tracking-action-unblock"), "unblockButton is visible");
     ok(hidden("#tracking-action-unblock-private"), "unblockButtonPrivate is hidden");
   }
 
   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");
-
-  ok(!hidden("#identity-popup-content-blocking-category-list"), "category list is visible");
-  ok(hidden("#identity-popup-content-blocking-category-tracking-protection > #identity-popup-content-blocking-tracking-protection-label-allowed"),
-    "TP category item is not showing the allowed label");
-  ok(!hidden("#identity-popup-content-blocking-category-tracking-protection > #identity-popup-content-blocking-tracking-protection-label-blocked"),
-    "TP category item is set to blocked");
 }
 
 function testTrackingPageUnblocked() {
   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");
 
   ok(!ContentBlocking.iconBox.hasAttribute("active"), "shield is active");
@@ -76,22 +70,16 @@ function testTrackingPageUnblocked() {
      gNavigatorBundle.getString("trackingProtection.icon.disabledTooltip"), "correct tooltip");
 
   ok(BrowserTestUtils.is_visible(ContentBlocking.iconBox), "icon box is visible");
   ok(!hidden("#tracking-action-block"), "blockButton is visible");
   ok(hidden("#tracking-action-unblock"), "unblockButton is hidden");
 
   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");
-
-  ok(!hidden("#identity-popup-content-blocking-category-list"), "category list is visible");
-  ok(!hidden("#identity-popup-content-blocking-category-tracking-protection > #identity-popup-content-blocking-tracking-protection-label-allowed"),
-    "TP category item is showing the allowed label");
-  ok(hidden("#identity-popup-content-blocking-category-tracking-protection > #identity-popup-content-blocking-tracking-protection-label-blocked"),
-    "TP category item is not set to blocked");
 }
 
 add_task(async function testExceptionAddition() {
   await UrlClassifierTestUtils.addTestTrackers();
   let privateWin = await BrowserTestUtils.openNewBrowserWindow({private: true});
   browser = privateWin.gBrowser;
   let tab = await BrowserTestUtils.openNewForegroundTab({ gBrowser: browser, waitForLoad: true, waitForStateStop: true });
 
--- a/browser/base/content/test/trackingUI/browser_trackingUI_report_breakage.js
+++ b/browser/base/content/test/trackingUI/browser_trackingUI_report_breakage.js
@@ -21,23 +21,16 @@ add_task(async function setup() {
   let oldCanRecord = Services.telemetry.canRecordExtended;
   Services.telemetry.canRecordExtended = true;
 
   registerCleanupFunction(() => {
     Services.telemetry.canRecordExtended = oldCanRecord;
   });
 });
 
-function openIdentityPopup() {
-  let mainView = document.getElementById("identity-popup-mainView");
-  let viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
-  gIdentityHandler._identityBox.click();
-  return viewShown;
-}
-
 add_task(async function testReportBreakageVisibility() {
   let scenarios = [
     {
       url: TRACKING_PAGE,
       prefs: {
         "privacy.trackingprotection.enabled": true,
         "browser.contentblocking.reportBreakage.enabled": true,
       },
--- a/browser/base/content/test/trackingUI/browser_trackingUI_state.js
+++ b/browser/base/content/test/trackingUI/browser_trackingUI_state.js
@@ -51,49 +51,53 @@ 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");
 
   ok(!hidden("#identity-popup-content-blocking-not-detected"), "blocking not detected label is visible");
   ok(hidden("#identity-popup-content-blocking-detected"), "blocking detected label is hidden");
-  ok(hidden("#identity-popup-content-blocking-category-list"), "category list is hidden");
+  ok(hidden("#identity-popup-content-blocking-category-cookies"),
+    "Not showing cookie restrictions category");
+  ok(hidden("#identity-popup-content-blocking-category-tracking-protection"),
+    "Not showing trackers category");
 }
 
 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");
   ok(ContentBlocking.iconBox.hasAttribute("hasException"), "shield shows exception");
   is(ContentBlocking.iconBox.getAttribute("tooltiptext"),
      gNavigatorBundle.getString("trackingProtection.icon.disabledTooltip"), "correct tooltip");
 
   ok(!BrowserTestUtils.is_hidden(ContentBlocking.iconBox), "icon box is not hidden");
   ok(!hidden("#tracking-action-block"), "blockButton is visible");
   ok(hidden("#tracking-action-unblock"), "unblockButton is hidden");
 
   ok(!hidden("#identity-popup-content-blocking-not-detected"), "blocking not detected label is visible");
   ok(hidden("#identity-popup-content-blocking-detected"), "blocking detected label is hidden");
-  ok(hidden("#identity-popup-content-blocking-category-list"), "category list is hidden");
+  ok(hidden("#identity-popup-content-blocking-category-cookies"),
+    "Not showing cookie restrictions category");
+  ok(hidden("#identity-popup-content-blocking-category-tracking-protection"),
+    "Not showing trackers category");
 }
 
 function areTrackersBlocked(isPrivateBrowsing) {
   let blockedByTP = Services.prefs.getBoolPref(isPrivateBrowsing ? TP_PB_PREF : TP_PREF);
   let blockedByTPC = Services.prefs.getIntPref(TPC_PREF) == Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER;
   return blockedByTP || blockedByTPC;
 }
 
@@ -101,18 +105,16 @@ 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");
@@ -126,79 +128,43 @@ function testTrackingPage(window) {
     ok(hidden("#tracking-action-unblock-private"), "unblockButtonPrivate is 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");
 
-  ok(!hidden("#identity-popup-content-blocking-category-list"), "category list is visible");
-
-  let cookiesBlocked = Services.prefs.getIntPref(TPC_PREF) == Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER;
-  if (cookiesBlocked) {
-    let category = "#identity-popup-content-blocking-category-3rdpartycookies";
-    is(hidden(category + " > .identity-popup-content-blocking-category-add-blocking"), blockedByTP,
-      "Category item is" + (blockedByTP ? " not" : "") + " showing add blocking");
-    is(hidden(category + " > .identity-popup-content-blocking-category-state-label"), !blockedByTP,
-      "Category item is" + (blockedByTP ? "" : " not") + " set to blocked");
-
-    ok(hidden("#identity-popup-content-blocking-category-label-default"),
-      "Not showing default cookie restrictions label.");
-    ok(!hidden("#identity-popup-content-blocking-category-label-trackers"),
-      "Showing trackers cookie restrictions label.");
-  } else {
-    let category = "#identity-popup-content-blocking-category-tracking-protection";
-    is(hidden(category + " > #identity-popup-content-blocking-tracking-protection-label-allowed"), blockedByTP,
-      "Category item is" + (blockedByTP ? " not" : "") + " showing the allowed label");
-    is(!hidden(category + " > #identity-popup-content-blocking-tracking-protection-label-blocked"), blockedByTP,
-      "Category item is" + (blockedByTP ? "" : " not") + " set to blocked");
-
-    ok(hidden("#identity-popup-content-blocking-category-label-trackers"),
-      "Not showing trackers cookie restrictions label.");
-    ok(!hidden("#identity-popup-content-blocking-category-label-default"),
-      "Showing default cookie restrictions label.");
-  }
+  ok(!hidden("#identity-popup-content-blocking-category-tracking-protection"),
+    "Showing trackers category");
+  ok(!hidden("#identity-popup-content-blocking-category-cookies"),
+    "Showing cookie restrictions category");
 }
 
 function testTrackingPageUnblocked(blockedByTP, window) {
   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");
 
-  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 exception");
   is(ContentBlocking.iconBox.getAttribute("tooltiptext"),
      gNavigatorBundle.getString("trackingProtection.icon.disabledTooltip"), "correct tooltip");
 
   ok(BrowserTestUtils.is_visible(ContentBlocking.iconBox), "icon box is visible");
   ok(!hidden("#tracking-action-block"), "blockButton is visible");
   ok(hidden("#tracking-action-unblock"), "unblockButton is hidden");
 
   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");
 
-  ok(!hidden("#identity-popup-content-blocking-category-list"), "category list is visible");
-
-  let cookiesBlocked = Services.prefs.getIntPref(TPC_PREF) == Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER;
-  if (cookiesBlocked) {
-    let category = "#identity-popup-content-blocking-category-3rdpartycookies";
-    is(hidden(category + " > .identity-popup-content-blocking-category-add-blocking"), blockedByTP,
-      "Category item is" + (blockedByTP ? " not" : "") + " showing add blocking");
-    ok(!hidden("#identity-popup-content-blocking-category-tracking-protection > #identity-popup-content-blocking-tracking-protection-label-allowed"),
-      "TP category item is showing the allowed label");
-  } else {
-    let category = "#identity-popup-content-blocking-category-tracking-protection";
-    // If there's an exception we always show the "Allowed" label.
-    ok(!hidden(category + " > #identity-popup-content-blocking-tracking-protection-label-allowed"),
-      "Category item is showing the allowed label");
-    ok(hidden(category + " > #identity-popup-content-blocking-tracking-protection-label-blocked"),
-      "Category item is not set to blocked");
-  }
+  ok(!hidden("#identity-popup-content-blocking-category-tracking-protection"),
+    "Showing trackers category");
+  ok(!hidden("#identity-popup-content-blocking-category-cookies"),
+    "Showing cookie restrictions category");
 }
 
 async function testContentBlocking(tab) {
   info("Testing with Tracking Protection ENABLED.");
 
   info("Load a test page not containing tracking elements");
   await promiseTabLoadEvent(tab, BENIGN_PAGE);
   testBenignPage();
--- a/browser/base/content/test/trackingUI/browser_trackingUI_telemetry.js
+++ b/browser/base/content/test/trackingUI/browser_trackingUI_telemetry.js
@@ -45,17 +45,17 @@ add_task(async function setup() {
 add_task(async function testShieldHistogram() {
   Services.prefs.setBoolPref(PREF, true);
   let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
 
   // Reset these to make counting easier
   getShieldHistogram().clear();
 
   await promiseTabLoadEvent(tab, BENIGN_PAGE);
-  is(getShieldCounts()[0], 2, "Page loads without tracking");
+  is(getShieldCounts()[0], 1, "Page loads without tracking");
 
   await promiseTabLoadEvent(tab, TRACKING_PAGE);
   // Note that right now the shield histogram is not measuring what
   // you might think.  Since onSecurityChange fires twice for a tracking page,
   // the total page loads count is double counting, and the shield count
   // (which is meant to measure times when the shield wasn't shown) fires even
   // when tracking elements exist on the page.
   todo_is(getShieldCounts()[0], 1, "FIXME: TOTAL PAGE LOADS WITHOUT TRACKING IS DOUBLE COUNTING");
@@ -81,32 +81,27 @@ add_task(async function testShieldHistog
 add_task(async function testIdentityPopupEvents() {
   Services.prefs.setBoolPref(PREF, true);
   let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
 
   await promiseTabLoadEvent(tab, BENIGN_PAGE);
 
   Services.telemetry.clearEvents();
 
-  let { gIdentityHandler } = gBrowser.ownerGlobal;
-  let promisePanelOpen = BrowserTestUtils.waitForEvent(gIdentityHandler._identityPopup, "popupshown");
-  gIdentityHandler._identityBox.click();
-  await promisePanelOpen;
+  await openIdentityPopup();
 
   let events = Services.telemetry.snapshotEvents(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true).parent;
   let openEvents = events.filter(
     e => e[1] == "security.ui.identitypopup" && e[2] == "open" && e[3] == "identity_popup");
   is(openEvents.length, 1, "recorded telemetry for opening the identity popup");
   is(openEvents[0][4], "shield-hidden", "recorded the shield as hidden");
 
   await promiseTabLoadEvent(tab, TRACKING_PAGE);
 
-  promisePanelOpen = BrowserTestUtils.waitForEvent(gIdentityHandler._identityPopup, "popupshown");
-  gIdentityHandler._identityBox.click();
-  await promisePanelOpen;
+  await openIdentityPopup();
 
   events = Services.telemetry.snapshotEvents(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true).parent;
   openEvents = events.filter(
     e => e[1] == "security.ui.identitypopup" && e[2] == "open" && e[3] == "identity_popup");
   is(openEvents.length, 1, "recorded telemetry for opening the identity popup");
   is(openEvents[0][4], "shield-showing", "recorded the shield as showing");
 
   info("Disable TP for the page (which reloads the page)");
--- a/browser/base/content/test/trackingUI/browser_trackingUI_trackers_subview.js
+++ b/browser/base/content/test/trackingUI/browser_trackingUI_trackers_subview.js
@@ -4,61 +4,40 @@
 
 "use strict";
 
 const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/trackingPage.html";
 
 const TP_PREF = "privacy.trackingprotection.enabled";
 
 add_task(async function setup() {
+  // Avoid the content blocking tour interfering with our tests by popping up.
+  await SpecialPowers.pushPrefEnv({set: [[ContentBlocking.prefIntroCount, ContentBlocking.MAX_INTROS]]});
   await UrlClassifierTestUtils.addTestTrackers();
-});
-
-function openIdentityPopup() {
-  let mainView = document.getElementById("identity-popup-mainView");
-  let viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
-  gIdentityHandler._identityBox.click();
-  return viewShown;
-}
 
-function waitForSecurityChange(counter) {
-  return new Promise(resolve => {
-    let webProgressListener = {
-      onStateChange: () => {},
-      onStatusChange: () => {},
-      onLocationChange: () => {},
-      onSecurityChange: (webProgress, request, oldState, state) => {
-        if (--counter == 0) {
-          gBrowser.removeProgressListener(webProgressListener);
-          resolve(counter);
-        }
-      },
-      onProgressChange: () => {},
-      QueryInterface: ChromeUtils.generateQI([Ci.nsIWebProgressListener]),
-    };
-
-    gBrowser.addProgressListener(webProgressListener);
+  registerCleanupFunction(() => {
+    UrlClassifierTestUtils.cleanupTestTrackers();
   });
-}
+});
 
 async function assertSitesListed(blocked) {
   await BrowserTestUtils.withNewTab(TRACKING_PAGE, async function(browser) {
     await openIdentityPopup();
 
     let categoryItem =
       document.getElementById("identity-popup-content-blocking-category-tracking-protection");
     ok(BrowserTestUtils.is_visible(categoryItem), "TP category item is visible");
     let trackersView = document.getElementById("identity-popup-trackersView");
     let viewShown = BrowserTestUtils.waitForEvent(trackersView, "ViewShown");
     categoryItem.click();
     await viewShown;
 
     ok(true, "Trackers view was shown");
 
-    let listItems = document.querySelectorAll(".identity-popup-trackersView-list-item");
+    let listItems = trackersView.querySelectorAll(".identity-popup-content-blocking-list-item");
     is(listItems.length, 1, "We have 1 tracker in the list");
 
     let strictInfo = document.getElementById("identity-popup-trackersView-strict-info");
     is(BrowserTestUtils.is_hidden(strictInfo), Services.prefs.getBoolPref(TP_PREF),
       "Strict info is hidden if TP is enabled.");
 
     let mainView = document.getElementById("identity-popup-mainView");
     viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
@@ -79,17 +58,17 @@ async function assertSitesListed(blocked
     is(result, undefined, "No securityChange events should be received");
 
     viewShown = BrowserTestUtils.waitForEvent(trackersView, "ViewShown");
     categoryItem.click();
     await viewShown;
 
     ok(true, "Trackers view was shown");
 
-    listItems = Array.from(document.querySelectorAll(".identity-popup-trackersView-list-item"));
+    listItems = Array.from(trackersView.querySelectorAll(".identity-popup-content-blocking-list-item"));
     is(listItems.length, 2, "We have 2 trackers in the list");
 
     let listItem = listItems.find(item => item.querySelector("label").value == "trackertest.org");
     ok(listItem, "Has an item for trackertest.org");
     ok(BrowserTestUtils.is_visible(listItem), "List item is visible");
     is(listItem.classList.contains("allowed"), !blocked,
       "Indicates whether the tracker was blocked or allowed");
 
@@ -97,24 +76,24 @@ async function assertSitesListed(blocked
     ok(listItem, "Has an item for itisatracker.org");
     ok(BrowserTestUtils.is_visible(listItem), "List item is visible");
     is(listItem.classList.contains("allowed"), !blocked,
       "Indicates whether the tracker was blocked or allowed");
   });
 }
 
 add_task(async function testTrackersSubView() {
+  info("Testing trackers subview with TP disabled.");
   Services.prefs.setBoolPref(TP_PREF, false);
   await assertSitesListed(false);
+  info("Testing trackers subview with TP enabled.");
   Services.prefs.setBoolPref(TP_PREF, true);
   await assertSitesListed(true);
+  info("Testing trackers subview with TP enabled and a CB exception.");
   let uri = Services.io.newURI("https://tracking.example.org");
   Services.perms.add(uri, "trackingprotection", Services.perms.ALLOW_ACTION);
   await assertSitesListed(false);
+  info("Testing trackers subview with TP enabled and a CB exception removed.");
   Services.perms.remove(uri, "trackingprotection");
   await assertSitesListed(true);
+
   Services.prefs.clearUserPref(TP_PREF);
 });
-
-add_task(function cleanup() {
-  Services.prefs.clearUserPref(TP_PREF);
-  UrlClassifierTestUtils.cleanupTestTrackers();
-});
--- a/browser/base/content/test/trackingUI/head.js
+++ b/browser/base/content/test/trackingUI/head.js
@@ -27,8 +27,32 @@ function promiseTabLoadEvent(tab, url) {
 
   let loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, handle);
 
   if (url)
     BrowserTestUtils.loadURI(tab.linkedBrowser, url);
 
   return loaded;
 }
+
+function openIdentityPopup() {
+  let mainView = document.getElementById("identity-popup-mainView");
+  let viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
+  gIdentityHandler._identityBox.click();
+  return viewShown;
+}
+
+function waitForSecurityChange(numChanges = 1) {
+  return new Promise(resolve => {
+    let n = 0;
+    let listener = {
+      onSecurityChange() {
+        n = n + 1;
+        info("Received onSecurityChange event " + n + " of " + numChanges);
+        if (n >= numChanges) {
+          gBrowser.removeProgressListener(listener);
+          resolve(n);
+        }
+      },
+    };
+    gBrowser.addProgressListener(listener);
+  });
+}
--- a/browser/base/content/test/trackingUI/trackingAPI.js
+++ b/browser/base/content/test/trackingUI/trackingAPI.js
@@ -13,10 +13,25 @@ onmessage = event => {
     }
     break;
   case "cookie": {
       let ifr = document.createElement("iframe");
       ifr.src = "https://trackertest.org/browser/browser/base/content/test/trackingUI/cookieServer.sjs";
       document.body.appendChild(ifr);
     }
     break;
+  case "first-party-cookie": {
+      // Since the content blocking log doesn't seem to get updated for
+      // top-level cookies right now, we just create an iframe with the
+      // first party domain...
+      let ifr = document.createElement("iframe");
+      ifr.src = "http://not-tracking.example.com/browser/browser/base/content/test/trackingUI/cookieServer.sjs";
+      document.body.appendChild(ifr);
+    }
+    break;
+  case "third-party-cookie": {
+      let ifr = document.createElement("iframe");
+      ifr.src = "https://test1.example.org/browser/browser/base/content/test/trackingUI/cookieServer.sjs";
+      document.body.appendChild(ifr);
+    }
+    break;
   }
 };