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
This commit is contained in:
Ehsan Akhgari 2019-02-27 15:36:42 -05:00
parent 3bcc679115
commit 2630b5a96e
2 changed files with 52 additions and 20 deletions

View File

@ -21,6 +21,12 @@ 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");
@ -37,6 +43,12 @@ async function testIdentityState(hasException) {
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);
}
@ -44,6 +56,12 @@ 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", "*");
@ -76,25 +94,23 @@ async function testSubview(hasException) {
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);
});

View File

@ -21,6 +21,12 @@ 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");
@ -37,6 +43,12 @@ async function testIdentityState(hasException) {
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);
}
@ -44,6 +56,12 @@ 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", "*");
@ -76,25 +94,23 @@ async function testSubview(hasException) {
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);
});