Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
const { ForgetAboutSite } = ChromeUtils.importESModule(
"resource://gre/modules/ForgetAboutSite.sys.mjs"
);
const { SiteDataTestUtils } = ChromeUtils.importESModule(
);
function checkCookie(host, originAttributes) {
for (let cookie of Services.cookies.cookies) {
if (
ChromeUtils.isOriginAttributesEqual(
originAttributes,
cookie.originAttributes
) &&
cookie.host.includes(host)
) {
return true;
}
}
return false;
}
add_task(async function test_singleDomain() {
info("Test single cookie domain");
// Let's clean up all the data.
await SiteDataTestUtils.clear();
// Cleaning up.
await ForgetAboutSite.removeDataFromBaseDomain("example.com");
// All good.
ok(!checkCookie("example.com", {}), "No cookies");
// Clean up.
await SiteDataTestUtils.clear();
});
add_task(async function test_subDomain() {
info("Test cookies for sub domains");
// Let's clean up all the data.
await SiteDataTestUtils.clear();
// Cleaning up.
await ForgetAboutSite.removeDataFromBaseDomain("sub.example.com");
// All good.
ok(!checkCookie("example.com", {}), "No cookies for example.com");
ok(checkCookie("example.org", {}), "Has cookies for example.org");
// Clean up.
await SiteDataTestUtils.clear();
});