mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-09 04:39:03 +02:00
Differential Revision: https://phabricator.services.mozilla.com/D55155 --HG-- extra : moz-landing-system : lando
94 lines
2.4 KiB
JavaScript
94 lines
2.4 KiB
JavaScript
/* import-globals-from antitracking_head.js */
|
|
|
|
requestLongerTimeout(4);
|
|
|
|
AntiTracking.runTestInNormalAndPrivateMode(
|
|
"localStorage",
|
|
async _ => {
|
|
try {
|
|
localStorage.foo = 42;
|
|
ok(false, "LocalStorage cannot be used!");
|
|
} catch (e) {
|
|
ok(true, "LocalStorage cannot be used!");
|
|
is(e.name, "SecurityError", "We want a security 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.runTestInNormalAndPrivateMode(
|
|
"localStorage and Storage Access API",
|
|
async _ => {
|
|
/* import-globals-from storageAccessAPIHelpers.js */
|
|
await noStorageAccessInitially();
|
|
|
|
try {
|
|
localStorage.foo = 42;
|
|
ok(false, "LocalStorage cannot be used!");
|
|
} catch (e) {
|
|
ok(true, "LocalStorage cannot be used!");
|
|
is(e.name, "SecurityError", "We want a security error message.");
|
|
}
|
|
|
|
/* import-globals-from storageAccessAPIHelpers.js */
|
|
await callRequestStorageAccess();
|
|
|
|
if (
|
|
[
|
|
SpecialPowers.Ci.nsICookieService.BEHAVIOR_REJECT,
|
|
SpecialPowers.Ci.nsICookieService.BEHAVIOR_REJECT_FOREIGN,
|
|
].includes(
|
|
SpecialPowers.Services.prefs.getIntPref("network.cookie.cookieBehavior")
|
|
)
|
|
) {
|
|
try {
|
|
localStorage.foo = 42;
|
|
ok(false, "LocalStorage cannot be used!");
|
|
} catch (e) {
|
|
ok(true, "LocalStorage cannot be used!");
|
|
is(e.name, "SecurityError", "We want a security 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
|
|
);
|