Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- Manifest: dom/localstorage/test/unit/xpcshell.toml
/**
* Any copyright is dedicated to the Public Domain.
*/
add_task(async function testSteps() {
const principalInfos = [
];
const data = {
key: "foo",
value: "bar",
};
function verifyData(clearedOrigins) {
info("Getting storages");
let storages = [];
for (let i = 0; i < principalInfos.length; i++) {
let principalInfo = principalInfos[i];
let principal = getPrincipal(principalInfo.url, principalInfo.attrs);
let storage = getLocalStorage(principal);
storages.push(storage);
}
info("Verifying data");
for (let i = 0; i < storages.length; i++) {
let value = storages[i].getItem(data.key + i);
if (clearedOrigins.includes(i)) {
is(value, null, "Correct value");
} else {
is(value, data.value + i, "Correct value");
}
}
}
info("Setting pref");
Services.prefs.setBoolPref(
"dom.storage.enable_unsupported_legacy_implementation",
false
);
info("Stage 1 - Testing archived data migration");
info("Clearing");
let request = clear();
await requestFinished(request);
info("Installing package");
// The profile contains storage.sqlite and webappsstore.sqlite. The file
// create_db.js in the package was run locally, specifically it was
// temporarily added to xpcshell.ini and then executed:
// mach xpcshell-test --interactive dom/localstorage/test/unit/create_db.js
installPackage("migration_profile");
verifyData([]);
info("Stage 2 - Testing archived data clearing");
for (let type of ["origin", "prefix", "pattern"]) {
info("Clearing");
request = clear();
await requestFinished(request);
info("Installing package");
// See the comment for the first installPackage() call.
installPackage("migration_profile");
let clearedOrigins = [];
switch (type) {
case "origin": {
request = clearOrigin(principal, "default");
await requestFinished(request);
clearedOrigins.push(4);
break;
}
case "prefix": {
request = clearOriginsByPrefix(principal, "default");
await requestFinished(request);
clearedOrigins.push(5, 6);
break;
}
case "pattern": {
request = clearOriginsByPattern(JSON.stringify({ userContextId: 15 }));
await requestFinished(request);
clearedOrigins.push(7, 8, 9);
break;
}
default: {
throw new Error("Unknown type: " + type);
}
}
verifyData(clearedOrigins);
}
});