mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-11 13:48:23 +02:00
Differential Revision: https://phabricator.services.mozilla.com/D24029 --HG-- rename : toolkit/components/antitracking/test/browser/head.js => toolkit/components/antitracking/test/browser/antitracking_head.js extra : moz-landing-system : lando
78 lines
2.3 KiB
JavaScript
78 lines
2.3 KiB
JavaScript
/* import-globals-from antitracking_head.js */
|
|
|
|
AntiTracking.runTest("localStorage",
|
|
async _ => {
|
|
is(window.localStorage, null, "LocalStorage is null");
|
|
try {
|
|
localStorage.foo = 42;
|
|
ok(false, "LocalStorage cannot be used!");
|
|
} catch (e) {
|
|
ok(true, "LocalStorage cannot be used!");
|
|
is(e.name, "TypeError", "We want a type error message.");
|
|
}
|
|
},
|
|
async _ => {
|
|
localStorage.foo = 42;
|
|
ok(true, "LocalStorage is allowed");
|
|
},
|
|
async _ => {
|
|
await new Promise(resolve => {
|
|
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
|
});
|
|
});
|
|
|
|
AntiTracking.runTest("localStorage and Storage Access API",
|
|
async _ => {
|
|
/* import-globals-from storageAccessAPIHelpers.js */
|
|
await noStorageAccessInitially();
|
|
|
|
is(window.localStorage, null, "LocalStorage is null");
|
|
try {
|
|
localStorage.foo = 42;
|
|
ok(false, "LocalStorage cannot be used!");
|
|
} catch (e) {
|
|
ok(true, "LocalStorage cannot be used!");
|
|
is(e.name, "TypeError", "We want a type error message.");
|
|
}
|
|
|
|
/* import-globals-from storageAccessAPIHelpers.js */
|
|
await callRequestStorageAccess();
|
|
|
|
if (SpecialPowers.Services.prefs.getIntPref("network.cookie.cookieBehavior") == SpecialPowers.Ci.nsICookieService.BEHAVIOR_REJECT) {
|
|
is(window.localStorage, null, "LocalStorage is null");
|
|
try {
|
|
localStorage.foo = 42;
|
|
ok(false, "LocalStorage cannot be used!");
|
|
} catch (e) {
|
|
ok(true, "LocalStorage cannot be used!");
|
|
is(e.name, "TypeError", "We want a type error message.");
|
|
}
|
|
} else {
|
|
localStorage.foo = 42;
|
|
ok(true, "LocalStorage is allowed");
|
|
}
|
|
},
|
|
async _ => {
|
|
/* import-globals-from storageAccessAPIHelpers.js */
|
|
if (allowListed) {
|
|
await hasStorageAccessInitially();
|
|
} else {
|
|
await noStorageAccessInitially();
|
|
}
|
|
|
|
localStorage.foo = 42;
|
|
ok(true, "LocalStorage is allowed");
|
|
|
|
/* import-globals-from storageAccessAPIHelpers.js */
|
|
await callRequestStorageAccess();
|
|
|
|
// For non-tracking windows, calling the API is a no-op
|
|
localStorage.foo = 42;
|
|
ok(true, "LocalStorage is allowed");
|
|
},
|
|
async _ => {
|
|
await new Promise(resolve => {
|
|
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
|
});
|
|
},
|
|
null, false, false);
|