test_groupMismatch.js (1895B)
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 that the group loaded from the origin table 8 * gets updated (if necessary) before quota initialization for the given origin. 9 */ 10 11 async function testSteps() { 12 const principal = getPrincipal("https://foo.bar.mozilla-iot.org"); 13 const originUsage = 100; 14 15 info("Clearing"); 16 17 let request = clear(); 18 await requestFinished(request); 19 20 info("Installing package"); 21 22 // The profile contains one initialized origin directory with simple database 23 // data, a script for origin initialization and the storage database: 24 // - storage/default/https+++foo.bar.mozilla-iot.org 25 // - create_db.js 26 // - storage.sqlite 27 // The file create_db.js in the package was run locally, specifically it was 28 // temporarily added to xpcshell.toml and then executed: 29 // mach xpcshell-test --interactive dom/quota/test/xpcshell/create_db.js 30 // Note: to make it become the profile in the test, additional manual steps 31 // are needed. 32 // 1. Manually change the group and accessed values in the origin table in 33 // storage.sqlite by running this SQL statement: 34 // UPDATE origin SET group_ = 'mozilla-iot.org', accessed = 0 35 // 2. Manually change the group in .metadata-v2 from "bar.mozilla-iot.org" to 36 // "mozilla-iot.org". 37 // 3. Remove the folder "storage/temporary". 38 // 4. Remove the file "storage/ls-archive.sqlite". 39 installPackage("groupMismatch_profile"); 40 41 info("Initializing"); 42 43 request = init(); 44 await requestFinished(request); 45 46 info("Initializing temporary storage"); 47 48 request = initTemporaryStorage(); 49 await requestFinished(request); 50 51 info("Getting origin usage"); 52 53 request = getCachedOriginUsage(principal); 54 await requestFinished(request); 55 56 is(request.result, originUsage, "Correct origin usage"); 57 }