Bug 1525856 - Enable the disabled portions of browser_trackingUI_fingerprinters.js and browser_trackingUI_cryptominers.js now that we correctly deal with channels in the face of the content blocking allow list; r=johannh
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 28 Feb 2019 18:13:47 +0000
changeset 520135 846b0c8b048e9b83f0f3b184a7bf2bc8001e6bf6
parent 520079 fd67a4332060ea5389d448b3453ea23064e50b5e
child 520136 8602628e7edaecadea855a64179b329da6ff1f20
child 520184 559e8b22fdc5812619eec44c0ed96f2631f172b0
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1525856
milestone67.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 1525856 - Enable the disabled portions of browser_trackingUI_fingerprinters.js and browser_trackingUI_cryptominers.js now that we correctly deal with channels in the face of the content blocking allow list; r=johannh Differential Revision: https://phabricator.services.mozilla.com/D21425
browser/base/content/test/trackingUI/browser_trackingUI_cryptominers.js
browser/base/content/test/trackingUI/browser_trackingUI_fingerprinters.js
--- a/browser/base/content/test/trackingUI/browser_trackingUI_cryptominers.js
+++ b/browser/base/content/test/trackingUI/browser_trackingUI_cryptominers.js
@@ -16,39 +16,57 @@ add_task(async function setup() {
     [ "privacy.trackingprotection.fingerprinting.enabled", false ],
   ]});
 });
 
 async function testIdentityState(hasException) {
   let promise = BrowserTestUtils.openNewForegroundTab({url: TRACKING_PAGE, gBrowser});
   let [tab] = await Promise.all([promise, waitForContentBlockingEvent()]);
 
+  if (hasException) {
+    let loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, TRACKING_PAGE);
+    ContentBlocking.disableForCurrentPage();
+    await loaded;
+  }
+
   ok(!ContentBlocking.content.hasAttribute("detected"), "cryptominers are not detected");
   ok(BrowserTestUtils.is_hidden(ContentBlocking.iconBox), "icon box is not visible");
 
   promise = waitForContentBlockingEvent();
 
   await ContentTask.spawn(tab.linkedBrowser, {}, function() {
     content.postMessage("cryptomining", "*");
   });
 
   await promise;
 
   ok(ContentBlocking.content.hasAttribute("detected"), "trackers are detected");
   ok(BrowserTestUtils.is_visible(ContentBlocking.iconBox), "icon box is visible");
   is(ContentBlocking.iconBox.hasAttribute("hasException"), hasException,
     "Shows an exception when appropriate");
 
+  if (hasException) {
+    let loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, TRACKING_PAGE);
+    ContentBlocking.enableForCurrentPage();
+    await loaded;
+  }
+
   BrowserTestUtils.removeTab(tab);
 }
 
 async function testSubview(hasException) {
   let promise = BrowserTestUtils.openNewForegroundTab({url: TRACKING_PAGE, gBrowser});
   let [tab] = await Promise.all([promise, waitForContentBlockingEvent()]);
 
+  if (hasException) {
+    let loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, TRACKING_PAGE);
+    ContentBlocking.disableForCurrentPage();
+    await loaded;
+  }
+
   promise = waitForContentBlockingEvent();
   await ContentTask.spawn(tab.linkedBrowser, {}, function() {
     content.postMessage("cryptomining", "*");
   });
   await promise;
 
   await openIdentityPopup();
 
@@ -71,31 +89,29 @@ async function testSubview(hasException)
   let mainView = document.getElementById("identity-popup-mainView");
   viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
   let backButton = subview.querySelector(".subviewbutton-back");
   backButton.click();
   await viewShown;
 
   ok(true, "Main view was shown");
 
+  if (hasException) {
+    let loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, TRACKING_PAGE);
+    ContentBlocking.enableForCurrentPage();
+    await loaded;
+  }
+
   BrowserTestUtils.removeTab(tab);
 }
 
 add_task(async function test() {
-  let uri = Services.io.newURI("https://example.org");
-
   Services.prefs.setBoolPref(CM_PREF, true);
 
   await testIdentityState(false);
-  Services.perms.add(uri, "trackingprotection", Services.perms.ALLOW_ACTION);
-  // TODO: This currently fails because of bug 1525458, fixing should allow us to re-enable it.
-  // await testIdentityState(true);
-  Services.perms.remove(uri, "trackingprotection");
+  await testIdentityState(true);
 
   await testSubview(false);
-  Services.perms.add(uri, "trackingprotection", Services.perms.ALLOW_ACTION);
-  // TODO: This currently fails because of bug 1525458, fixing should allow us to re-enable it.
-  // await testSubview(true);
-  Services.perms.remove(uri, "trackingprotection");
+  await testSubview(true);
 
   Services.prefs.clearUserPref(CM_PREF);
 });
 
--- a/browser/base/content/test/trackingUI/browser_trackingUI_fingerprinters.js
+++ b/browser/base/content/test/trackingUI/browser_trackingUI_fingerprinters.js
@@ -16,39 +16,57 @@ add_task(async function setup() {
     [ "privacy.trackingprotection.cryptomining.enabled", false ],
   ]});
 });
 
 async function testIdentityState(hasException) {
   let promise = BrowserTestUtils.openNewForegroundTab({url: TRACKING_PAGE, gBrowser});
   let [tab] = await Promise.all([promise, waitForContentBlockingEvent()]);
 
+  if (hasException) {
+    let loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, TRACKING_PAGE);
+    ContentBlocking.disableForCurrentPage();
+    await loaded;
+  }
+
   ok(!ContentBlocking.content.hasAttribute("detected"), "fingerprinters are not detected");
   ok(BrowserTestUtils.is_hidden(ContentBlocking.iconBox), "icon box is not visible");
 
   promise = waitForContentBlockingEvent();
 
   await ContentTask.spawn(tab.linkedBrowser, {}, function() {
     content.postMessage("fingerprinting", "*");
   });
 
   await promise;
 
   ok(ContentBlocking.content.hasAttribute("detected"), "trackers are detected");
   ok(BrowserTestUtils.is_visible(ContentBlocking.iconBox), "icon box is visible");
   is(ContentBlocking.iconBox.hasAttribute("hasException"), hasException,
     "Shows an exception when appropriate");
 
+  if (hasException) {
+    let loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, TRACKING_PAGE);
+    ContentBlocking.enableForCurrentPage();
+    await loaded;
+  }
+
   BrowserTestUtils.removeTab(tab);
 }
 
 async function testSubview(hasException) {
   let promise = BrowserTestUtils.openNewForegroundTab({url: TRACKING_PAGE, gBrowser});
   let [tab] = await Promise.all([promise, waitForContentBlockingEvent()]);
 
+  if (hasException) {
+    let loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, TRACKING_PAGE);
+    ContentBlocking.disableForCurrentPage();
+    await loaded;
+  }
+
   promise = waitForContentBlockingEvent();
   await ContentTask.spawn(tab.linkedBrowser, {}, function() {
     content.postMessage("fingerprinting", "*");
   });
   await promise;
 
   await openIdentityPopup();
 
@@ -71,31 +89,29 @@ async function testSubview(hasException)
   let mainView = document.getElementById("identity-popup-mainView");
   viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
   let backButton = subview.querySelector(".subviewbutton-back");
   backButton.click();
   await viewShown;
 
   ok(true, "Main view was shown");
 
+  if (hasException) {
+    let loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, TRACKING_PAGE);
+    ContentBlocking.enableForCurrentPage();
+    await loaded;
+  }
+
   BrowserTestUtils.removeTab(tab);
 }
 
 add_task(async function test() {
-  let uri = Services.io.newURI("https://example.org");
-
   Services.prefs.setBoolPref(FP_PREF, true);
 
   await testIdentityState(false);
-  Services.perms.add(uri, "trackingprotection", Services.perms.ALLOW_ACTION);
-  // TODO: This currently fails because of bug 1525458, fixing should allow us to re-enable it.
-  // await testIdentityState(true);
-  Services.perms.remove(uri, "trackingprotection");
+  await testIdentityState(true);
 
   await testSubview(false);
-  Services.perms.add(uri, "trackingprotection", Services.perms.ALLOW_ACTION);
-  // TODO: This currently fails because of bug 1525458, fixing should allow us to re-enable it.
-  // await testSubview(true);
-  Services.perms.remove(uri, "trackingprotection");
+  await testSubview(true);
 
   Services.prefs.clearUserPref(FP_PREF);
 });