Bug 1593573 - Update socialtracking UI test. r=xeonchen
authorNihanth Subramanya <nhnt11@gmail.com>
Mon, 04 Nov 2019 16:34:53 +0000
changeset 500405 be848609eea8b155c542412ca96dacabed7f7cff
parent 500404 2fa5d33ca68a18ea49f6dea6a3611b5c719e4b48
child 500406 eaf25cd8fd0357f04a5e25d662e8232c2a366a70
push id36763
push userrmaries@mozilla.com
push dateMon, 04 Nov 2019 21:44:06 +0000
treeherdermozilla-central@75a7a3400888 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxeonchen
bugs1593573
milestone72.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 1593573 - Update socialtracking UI test. r=xeonchen Differential Revision: https://phabricator.services.mozilla.com/D51613
browser/base/content/test/trackingUI/browser_trackingUI_socialtracking.js
--- a/browser/base/content/test/trackingUI/browser_trackingUI_socialtracking.js
+++ b/browser/base/content/test/trackingUI/browser_trackingUI_socialtracking.js
@@ -16,16 +16,22 @@ add_task(async function setup() {
       [
         "urlclassifier.features.socialtracking.blacklistHosts",
         "social-tracking.example.org",
       ],
       [
         "urlclassifier.features.socialtracking.annotate.blacklistHosts",
         "social-tracking.example.org",
       ],
+      // Whitelist trackertest.org loaded by default in trackingPage.html
+      ["urlclassifier.trackingWhitelistTable.testEntries", "example.com"],
+      [
+        "urlclassifier.trackingAnnotationWhitelistTable.testEntries",
+        "example.com",
+      ],
       ["privacy.trackingprotection.enabled", false],
       ["privacy.trackingprotection.annotate_channels", true],
     ],
   });
 });
 
 async function testIdentityState(hasException) {
   let promise = BrowserTestUtils.openNewForegroundTab({
@@ -174,51 +180,108 @@ async function testCategoryItem(blockLoa
   Services.prefs.setBoolPref(ST_BLOCK_COOKIES_PREF, false);
 
   let promise = BrowserTestUtils.openNewForegroundTab({
     url: TRACKING_PAGE,
     gBrowser,
   });
   let [tab] = await Promise.all([promise, waitForContentBlockingEvent()]);
 
+  await openProtectionsPopup();
+
   let categoryItem = document.getElementById(
     "protections-popup-category-socialblock"
   );
 
+  let noTrackersDetectedDesc = document.getElementById(
+    "protections-popup-no-trackers-found-description"
+  );
+
+  ok(categoryItem.hasAttribute("uidisabled"), "Category should be uidisabled");
+
+  ok(
+    !categoryItem.classList.contains("blocked"),
+    "Category not marked as blocked"
+  );
+  ok(!BrowserTestUtils.is_visible(categoryItem), "Item should be hidden");
+  ok(
+    !gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
+    "trackers are not detected"
+  );
+
+  await SpecialPowers.spawn(tab.linkedBrowser, [], function() {
+    content.postMessage("socialtracking", "*");
+  });
+
   ok(
     !categoryItem.classList.contains("blocked"),
     "Category not marked as blocked"
   );
+  ok(!BrowserTestUtils.is_visible(categoryItem), "Item should be hidden");
   ok(
-    categoryItem.classList.contains("notFound"),
-    "Category marked as not found"
+    !gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
+    "trackers are not detected"
+  );
+  ok(
+    BrowserTestUtils.is_visible(noTrackersDetectedDesc),
+    "No Trackers Detcted should be shown"
   );
 
+  BrowserTestUtils.removeTab(tab);
+
   Services.prefs.setBoolPref(ST_BLOCK_COOKIES_PREF, true);
 
+  promise = BrowserTestUtils.openNewForegroundTab({
+    url: TRACKING_PAGE,
+    gBrowser,
+  });
+  [tab] = await Promise.all([promise, waitForContentBlockingEvent()]);
+
+  await openProtectionsPopup();
+
+  ok(!categoryItem.hasAttribute("uidisabled"), "Item shouldn't be uidisabled");
+
   ok(categoryItem.classList.contains("blocked"), "Category marked as blocked");
   ok(
     categoryItem.classList.contains("notFound"),
     "Category marked as not found"
   );
+  // At this point we should still be showing "No Trackers Detected"
+  ok(!BrowserTestUtils.is_visible(categoryItem), "Item should not be visible");
+  ok(
+    BrowserTestUtils.is_visible(noTrackersDetectedDesc),
+    "No Trackers Detcted should be shown"
+  );
+  ok(
+    !gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
+    "trackers are not detected"
+  );
 
   await SpecialPowers.spawn(tab.linkedBrowser, [], function() {
     content.postMessage("socialtracking", "*");
   });
 
   await TestUtils.waitForCondition(() => {
     return !categoryItem.classList.contains("notFound");
   });
 
   ok(categoryItem.classList.contains("blocked"), "Category marked as blocked");
-
   ok(
     !categoryItem.classList.contains("notFound"),
     "Category not marked as not found"
   );
+  ok(BrowserTestUtils.is_visible(categoryItem), "Item should be visible");
+  ok(
+    !BrowserTestUtils.is_visible(noTrackersDetectedDesc),
+    "No Trackers Detcted should be hidden"
+  );
+  ok(
+    gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
+    "trackers are not detected"
+  );
 
   BrowserTestUtils.removeTab(tab);
 
   Services.prefs.clearUserPref(ST_PROTECTION_PREF);
 }
 
 add_task(async function testIdentityUI() {
   requestLongerTimeout(2);