mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 1566961 - Integrate SocialTracking and ETP - tests, r=Ehsan
Differential Revision: https://phabricator.services.mozilla.com/D38570 --HG-- rename : toolkit/components/url-classifier/tests/mochitest/raptor.jpg => toolkit/components/antitracking/test/browser/raptor.jpg extra : moz-landing-system : lando
This commit is contained in:
parent
7f34a5abc1
commit
9071d156c9
@ -30,6 +30,8 @@ support-files =
|
||||
3rdPartyStorage.html
|
||||
3rdPartyStorageWO.html
|
||||
3rdPartyPartitioned.html
|
||||
localStorage.html
|
||||
raptor.jpg
|
||||
!/browser/modules/test/browser/head.js
|
||||
!/browser/base/content/test/general/head.js
|
||||
|
||||
@ -108,7 +110,6 @@ skip-if = fission
|
||||
[browser_denyPermissionForTracker.js]
|
||||
[browser_localStorageEvents.js]
|
||||
skip-if = fission
|
||||
support-files = localStorage.html
|
||||
[browser_partitionedLocalStorage.js]
|
||||
skip-if = fission
|
||||
[browser_partitionedLocalStorage_events.js]
|
||||
@ -133,3 +134,5 @@ support-files = matchAll.js
|
||||
[browser_partitionedSharedWorkers.js]
|
||||
skip-if = fission
|
||||
support-files = sharedWorker.js partitionedSharedWorker.js
|
||||
[browser_socialtracking.js]
|
||||
skip-if = fission
|
||||
|
@ -0,0 +1,110 @@
|
||||
function runTest(obj) {
|
||||
add_task(async _ => {
|
||||
info("Test: " + obj.testName);
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["dom.ipc.processCount", 1],
|
||||
["network.cookie.cookieBehavior", Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER],
|
||||
["privacy.trackingprotection.enabled", false],
|
||||
["privacy.trackingprotection.pbmode.enabled", false],
|
||||
["privacy.trackingprotection.annotate_channels", true],
|
||||
["privacy.storagePrincipal.enabledForTrackers", false],
|
||||
["urlclassifier.features.socialtracking.annotate.blacklistHosts", "not-tracking.example.com"],
|
||||
["privacy.trackingprotection.socialtracking.annotate.enabled", obj.annotationEnabled],
|
||||
["urlclassifier.features.socialtracking.blacklistHosts", "not-tracking.example.com"],
|
||||
["privacy.trackingprotection.socialtracking.enabled", obj.protectionEnabled],
|
||||
["privacy.socialtracking.block_cookies.enabled", obj.cookieBlocking],
|
||||
],
|
||||
});
|
||||
|
||||
await UrlClassifierTestUtils.addTestTrackers();
|
||||
|
||||
info("Creating a non-tracker top-level context");
|
||||
let tab = BrowserTestUtils.addTab(gBrowser, TEST_TOP_PAGE);
|
||||
let browser = gBrowser.getBrowserForTab(tab);
|
||||
await BrowserTestUtils.browserLoaded(browser);
|
||||
|
||||
info("The non-tracker page opens a tracker iframe");
|
||||
await ContentTask.spawn(
|
||||
browser,
|
||||
{
|
||||
page: TEST_4TH_PARTY_DOMAIN + TEST_PATH + "localStorage.html",
|
||||
image: TEST_4TH_PARTY_DOMAIN + TEST_PATH + "raptor.jpg",
|
||||
loading: obj.loading,
|
||||
result: obj.result,
|
||||
},
|
||||
async obj => {
|
||||
let loading = await new content.Promise(resolve => {
|
||||
let image = new content.Image();
|
||||
image.src = obj.image + "?" + Math.random();
|
||||
image.onload = _ => resolve(true);
|
||||
image.onerror = _ => resolve(false);
|
||||
});
|
||||
|
||||
is(loading, obj.loading, "Loading expected");
|
||||
|
||||
if (obj.loading) {
|
||||
let ifr = content.document.createElement("iframe");
|
||||
ifr.setAttribute("id", "ifr");
|
||||
ifr.setAttribute("src", obj.page);
|
||||
|
||||
info("Iframe loading...");
|
||||
await new content.Promise(resolve => {
|
||||
ifr.onload = resolve;
|
||||
content.document.body.appendChild(ifr);
|
||||
});
|
||||
|
||||
let p = new Promise(resolve => {
|
||||
content.addEventListener("message", e => { resolve(e.data); },
|
||||
{ once: true });
|
||||
});
|
||||
|
||||
info("Setting localStorage value...");
|
||||
ifr.contentWindow.postMessage("test", "*");
|
||||
|
||||
info("Getting the value...");
|
||||
let value = await p;
|
||||
is(value.status, obj.result, "We expect to succeed");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
}
|
||||
|
||||
runTest({
|
||||
testName: "Socialtracking-annotation feature not enabled",
|
||||
annotationEnabled: false,
|
||||
protectionEnabled: false,
|
||||
loading: true,
|
||||
cookieBlocking: false,
|
||||
result: true,
|
||||
});
|
||||
|
||||
runTest({
|
||||
testName: "Socialtracking-annotation feature enabled but not considered for tracking detection.",
|
||||
annotationEnabled: true,
|
||||
protectionEnabled: false,
|
||||
loading: true,
|
||||
cookieBlocking: false,
|
||||
result: true,
|
||||
});
|
||||
|
||||
runTest({
|
||||
testName: "Socialtracking-annotation feature enabled and considered for tracking detection.",
|
||||
annotationEnabled: true,
|
||||
protectionEnabled: false,
|
||||
loading: true,
|
||||
cookieBlocking: true,
|
||||
result: false,
|
||||
});
|
||||
|
||||
runTest({
|
||||
testName: "Socialtracking-protection feature enabled.",
|
||||
annotationEnabled: true,
|
||||
protectionEnabled: true,
|
||||
loading: false,
|
||||
cookieBlocking: true,
|
||||
result: false,
|
||||
});
|
BIN
toolkit/components/antitracking/test/browser/raptor.jpg
Normal file
BIN
toolkit/components/antitracking/test/browser/raptor.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
Loading…
Reference in New Issue
Block a user