test_removedOrigin.js (1948B)
1 /** 2 * Any copyright is dedicated to the Public Domain. 3 * http://creativecommons.org/publicdomain/zero/1.0/ 4 */ 5 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. 11 */ 12 13 async function testSteps() { 14 const principal = getPrincipal("http://example.com"); 15 const originUsage = 0; 16 17 info("Setting pref"); 18 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); 22 23 info("Clearing"); 24 25 let request = clear(); 26 await requestFinished(request); 27 28 info("Installing package"); 29 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.toml 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"); 44 45 info("Initializing"); 46 47 request = init(); 48 await requestFinished(request); 49 50 info("Initializing temporary storage"); 51 52 request = initTemporaryStorage(); 53 await requestFinished(request); 54 55 info("Getting origin usage"); 56 57 request = getCachedOriginUsage(principal); 58 await requestFinished(request); 59 60 is(request.result, originUsage, "Correct origin usage"); 61 }