2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/publicdomain/zero/1.0/
7 * This test is mainly to verify that local storage directories are removed
8 * during local storage archive upgrade from version 3 to version 4.
12 async
function testSteps() {
14 "storage/default/http+++localhost/ls",
15 "storage/default/http+++www.mozilla.org/ls",
16 "storage/default/http+++example.com/ls",
19 const principalInfos
= [
21 "http://www.mozilla.org",
26 { key
: "foo0", value
: "bar" },
27 { key
: "foo1", value
: "A" },
28 { key
: "foo2", value
: "A".repeat(100) },
31 function getLocalStorage(principal
) {
32 return Services
.domStorageManager
.createStorage(
42 // xpcshell globals don't have associated clients in the Clients API sense, so
43 // we need to disable client validation so that this xpcshell test is allowed
44 // to use LocalStorage.
45 Services
.prefs
.setBoolPref("dom.storage.client_validation", false);
49 let request
= clear();
50 await
requestFinished(request
);
52 info("Installing package");
54 // The profile contains three initialized origin directories with local
55 // storage data, local storage archive, a script for origin initialization,
56 // the storage database and the web apps store database:
57 // - storage/default/https+++example.com
58 // - storage/default/https+++localhost
59 // - storage/default/https+++www.mozilla.org
60 // - storage/ls-archive.sqlite
63 // - webappsstore.sqlite
64 // The file create_db.js in the package was run locally (with a build with
65 // local storage archive version 3), specifically it was temporarily added to
66 // xpcshell.ini and then executed:
67 // mach xpcshell-test --interactive dom/localstorage/test/xpcshell/create_db.js
68 // Note: to make it become the profile in the test, additional manual steps
70 // 1. Remove the folder "storage/temporary".
71 installPackage("localStorageArchive4upgrade_profile");
73 info("Checking ls dirs");
75 for (let lsDir
of lsDirs
) {
76 let dir
= getRelativeFile(lsDir
);
78 exists
= dir
.exists();
79 ok(exists
, "ls directory does exist");
83 request
= await
requestFinished(request
);
85 info("Checking ls dirs");
87 for (let lsDir
of lsDirs
) {
88 let dir
= getRelativeFile(lsDir
);
90 exists
= dir
.exists();
91 ok(!exists
, "ls directory doesn't exist");
94 info("Getting storages");
97 for (let i
= 0; i
< principalInfos
.length
; i
++) {
98 let storage
= getLocalStorage(getPrincipal(principalInfos
[i
]));
99 storages
.push(storage
);
102 info("Verifying data");
104 for (let i
= 0; i
< storages
.length
; i
++) {
105 is(storages
[i
].getItem(data
[i
].key
), data
[i
].value
, "Correct value");