test_corruptedDatabase.js (2077B)
1 /** 2 * Any copyright is dedicated to the Public Domain. 3 * http://creativecommons.org/publicdomain/zero/1.0/ 4 */ 5 6 async function doTest(profile) { 7 info("Testing profile " + profile); 8 9 info("Clearing"); 10 11 let request = clear(); 12 await requestFinished(request); 13 14 info("Installing package"); 15 16 installPackage(profile); 17 18 const principal = getPrincipal("http://example.org"); 19 20 let storage = getLocalStorage(principal); 21 22 let length = storage.length; 23 24 Assert.strictEqual(length, 0, "Correct length"); 25 26 info("Resetting client"); 27 28 request = resetClient(principal); 29 await requestFinished(request); 30 31 info("Getting usage"); 32 33 request = getOriginUsage(principal); 34 await requestFinished(request); 35 36 is(request.result.usage, 0, "Correct usage"); 37 } 38 39 add_task(async function testSteps() { 40 info("Setting pref"); 41 42 Services.prefs.setBoolPref( 43 "dom.storage.enable_unsupported_legacy_implementation", 44 false 45 ); 46 47 // XXX This should be refactored into separate sub test cases. 48 49 const profiles = [ 50 // This profile contains one localStorage, all localStorage related files, a 51 // script for localStorage creation and the storage database: 52 // - storage/default/http+++example.org/ls 53 // - storage/ls-archive.sqlite 54 // - create_db.js 55 // - storage.sqlite 56 // - webappsstore.sqlite 57 // The file create_db.js in the package was run locally, specifically it was 58 // temporarily added to xpcshell.toml and then executed: 59 // mach xpcshell-test --interactive dom/localstorage/test/unit/create_db.js 60 // Note: to make it become the profile in the test, additional manual steps 61 // are needed. 62 // 1. Manually change first 6 chars in data.sqlite to "foobar". 63 // 2. Remove the folder "storage/temporary". 64 "corruptedDatabase_profile", 65 // This profile is the same as corruptedDatabase_profile, except that the usage 66 // file (storage/default/http+++example.org/ls/usage) is missing. 67 "corruptedDatabase_missingUsageFile_profile", 68 ]; 69 70 for (const profile of profiles) { 71 await doTest(profile); 72 } 73 });