gecko-dev/toolkit/components/antitracking/test/browser/browser_fileUrl.js
Tim Huang 3fd8634816 Bug 1695050 - Part 3: Update current test cases and add a new test case. r=dimi
This patch updates the pref for existing content blocking tests. And it
also adds a new test to verify that the cookieBehavior in regular
windowa and private window are both correct.

Differential Revision: https://phabricator.services.mozilla.com/D109046
2021-03-29 11:01:51 +00:00

41 lines
1 KiB
JavaScript

/**
* Bug 1663192 - Testing for ensuring the top-level window in a fire url is
* treated as first-party.
*/
"use strict";
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["network.cookie.cookieBehavior", 1],
["network.cookie.cookieBehavior.pbmode", 1],
],
});
});
add_task(async function() {
let dir = getChromeDir(getResolvedURI(gTestPath));
dir.append("file_localStorage.html");
const uriString = Services.io.newFileURI(dir).spec;
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, uriString);
await SpecialPowers.spawn(tab.linkedBrowser, [], function() {
let result = content.document.getElementById("result");
is(
result.textContent,
"PASS",
"The localStorage is accessible in top-level window"
);
let loadInfo = content.docShell.currentDocumentChannel.loadInfo;
ok(
!loadInfo.isThirdPartyContextToTopWindow,
"The top-level window shouldn't be third-party"
);
});
BrowserTestUtils.removeTab(tab);
});