test_upgradeCacheFrom1.js (2250B)
1 /** 2 * Any copyright is dedicated to the Public Domain. 3 * http://creativecommons.org/publicdomain/zero/1.0/ 4 */ 5 6 /** 7 * This test is mainly to verify UpgradeCacheFrom1To2 method. 8 */ 9 10 async function testSteps() { 11 const packages = [ 12 // Storage used prior FF 88 (cache version 1). 13 // The profile contains one initialized origin directory with simple 14 // database data, a script for origin initialization and the storage 15 // database: 16 // - storage/default/https+++www.mozilla.org^userContextId=1 17 // - create_db.js 18 // - storage.sqlite 19 // The file create_db.js in the package was run locally, specifically it was 20 // temporarily added to xpcshell.toml and then executed: 21 // mach xpcshell-test dom/quota/test/xpcshell/upgrades/create_db.js 22 // --interactive 23 // Note: to make it become the profile in the test, additional manual steps 24 // are needed. 25 // 1. Remove the folder "storage/temporary". 26 // 2. Remove the file "storage/ls-archive.sqlite". 27 "cacheVersion1_profile", 28 "../defaultStorageDirectory_shared", 29 ]; 30 const principal = getPrincipal("https://www.mozilla.org", { 31 userContextId: 1, 32 }); 33 const originUsage = 100; 34 35 info("Clearing"); 36 37 let request = clear(); 38 await requestFinished(request); 39 40 info("Verifying storage"); 41 42 verifyStorage(packages, "beforeInstall"); 43 44 info("Installing package"); 45 46 installPackages(packages); 47 48 info("Verifying storage"); 49 50 verifyStorage(packages, "afterInstall"); 51 52 info("Initializing"); 53 54 request = init(); 55 await requestFinished(request); 56 57 info("Verifying storage"); 58 59 verifyStorage(packages, "afterInit"); 60 61 // TODO: Remove this block once temporary storage initialization is able to 62 // ignore unknown directories. 63 getRelativeFile("storage/default/invalid+++example.com").remove(false); 64 getRelativeFile("storage/temporary/invalid+++example.com").remove(false); 65 66 info("Initializing temporary storage"); 67 68 request = initTemporaryStorage(continueToNextStepSync); 69 await requestFinished(request); 70 71 info("Getting origin usage"); 72 73 request = getCachedOriginUsage(principal); 74 await requestFinished(request); 75 76 info("Verifying origin usage"); 77 78 is(request.result, originUsage, "Correct origin usage"); 79 }