Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'linux' && os_version == '18.04' && asan OR os == 'linux' && os_version == '18.04' && tsan OR debug
- Manifest: toolkit/components/antitracking/test/browser/browser.toml
/* Any copyright is dedicated to the Public Domain.
add_task(async function () {
info("Starting first party tracker test");
await SpecialPowers.pushPrefEnv({
set: [
["privacy.trackingprotection.enabled", true],
["privacy.trackingprotection.annotate_channels", true],
],
});
await UrlClassifierTestUtils.addTestTrackers();
let tab = BrowserTestUtils.addTab(
gBrowser,
);
gBrowser.selectedTab = tab;
let browser = gBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser);
info("Create a cross-site iframe.");
await SpecialPowers.spawn(browser, [], async () => {
const iframe = content.document.createElement("iframe");
iframe.src =
let loaded = new Promise(resolve => {
iframe.addEventListener("load", resolve, { once: true });
});
content.document.body.appendChild(iframe);
await loaded;
});
info("Create make a same-site-to-top-level request inside that iframe.");
let result = await SpecialPowers.spawn(browser, [], async function () {
const iframe = content.document.querySelector("iframe");
const result = await SpecialPowers.spawn(iframe, [], async () => {
info("Image loading ...");
let loading = new content.Promise(resolve => {
let image = new content.Image();
image.src =
Math.random();
image.onload = _ => resolve(true);
image.onerror = _ => resolve(false);
});
return loading;
});
return result;
});
ok(result, "Same-site-to-top-level should never be a tracker.");
info("Create make a cross-site-to-top-level request inside that iframe.");
result = await SpecialPowers.spawn(browser, [], async function () {
const iframe = content.document.querySelector("iframe");
const result = await SpecialPowers.spawn(iframe, [], async () => {
info("Image loading ...");
let loading = new content.Promise(resolve => {
let image = new content.Image();
image.src =
Math.random();
image.onload = _ => resolve(true);
image.onerror = _ => resolve(false);
});
return loading;
});
return result;
});
ok(!result, "Sanity check on a different tracker.");
info("Checking the content blocking log");
let log = JSON.parse(browser.getContentBlockingLog());
is(
undefined,
"Must not have an entry for a same-site tracker."
);
is(
1,
"Entry for blocking a tracker exists."
);
is(
Ci.nsIWebProgressListener.STATE_BLOCKED_TRACKING_CONTENT,
"Entry for blocking a tracker has the right flag."
);
is(
true,
"Entry for blocking a tracker has the right 'blocked' boolean."
);
is(
1,
"Entry for blocking a tracker has the right count."
);
UrlClassifierTestUtils.cleanupTestTrackers();
BrowserTestUtils.removeTab(tab);
await SpecialPowers.flushPrefEnv();
});
add_task(async _ => {
await new Promise(resolve => {
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, () =>
resolve()
);
});
});