Backed out changeset 9d8b4c0b99ed (bug 1945683) for causing btime failures. CLOSED...
[gecko.git] / dom / quota / test / xpcshell / caching / test_removedOrigin.js
blob1ecabb985e00337711aca11c9674ec8c9743f118
1 /**
2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/publicdomain/zero/1.0/
4 */
6 /**
7 * Verify that temporary storage initialization will notice a removed origin
8 * that the cache has data for and which indicates the origin was accessed
9 * during the last run. Currently, we expect LoadQuotaFromCache to fail because
10 * of this inconsistency and to fall back to full initialization.
13 async function testSteps() {
14 const principal = getPrincipal("http://example.com");
15 const originUsage = 0;
17 info("Setting pref");
19 // The packaged profile will have a different build ID and we would treat the
20 // cache as invalid if we didn't bypass this check.
21 Services.prefs.setBoolPref("dom.quotaManager.caching.checkBuildId", false);
23 info("Clearing");
25 let request = clear();
26 await requestFinished(request);
28 info("Installing package");
30 // The profile contains empty default storage, a script for origin
31 // initialization and the storage database:
32 // - storage/default
33 // - create_db.js
34 // - storage.sqlite
35 // The file create_db.js in the package was run locally, specifically it was
36 // temporarily added to xpcshell.ini and then executed:
37 // mach xpcshell-test --interactive dom/quota/test/xpcshell/create_db.js
38 // Note: to make it become the profile in the test, additional manual steps
39 // are needed.
40 // 1. Remove the folder "storage/default/http+++example.com".
41 // 2. Remove the folder "storage/temporary".
42 // 3. Remove the file "storage/ls-archive.sqlite".
43 installPackage("removedOrigin_profile");
45 info("Initializing");
47 request = init();
48 await requestFinished(request);
50 info("Initializing temporary storage");
52 request = initTemporaryStorage();
53 await requestFinished(request);
55 info("Getting origin usage");
57 request = getCachedOriginUsage(principal);
58 await requestFinished(request);
60 is(request.result, originUsage, "Correct origin usage");