test_upgradeStorageFrom2_0.js (2944B)
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 UpgradeStorageFrom2_0To2_1 method. 8 */ 9 10 function* testSteps() { 11 const origins = [ 12 "storage/default/chrome/", 13 "storage/default/http+++www.mozilla.org/", 14 ]; 15 const paddingFilePath = "cache/.padding"; 16 17 const packages = [ 18 // Storage used by FF 55-56 (storage version 2.0). 19 // The profile contains two cache storages: 20 // - storage/default/chrome/cache, 21 // - storage/default/http+++www.mozilla.org/cache 22 // The file create_cache.js in the package was run locally, specifically it 23 // was temporarily added to xpcshell.toml and then executed: 24 // mach xpcshell-test --interactive dom/quota/test/xpcshell/create_cache.js 25 // Note: it only creates the directory "storage/default/chrome/cache". 26 // To make it become the profile in the test, two more manual steps are 27 // needed. 28 // 1. Remove the folder "storage/temporary". 29 // 2. Copy the content under the "storage/default/chrome" to 30 // "storage/default/http+++www.mozilla.org". 31 // 3. Manually create an asmjs folder under the 32 // "storage/default/http+++www.mozilla.org/". 33 "version2_0_profile", 34 "../defaultStorageDirectory_shared", 35 ]; 36 37 info("Clearing"); 38 39 clear(continueToNextStepSync); 40 yield undefined; 41 42 info("Verifying storage"); 43 44 verifyStorage(packages, "beforeInstall"); 45 46 info("Installing packages"); 47 48 installPackages(packages); 49 50 info("Verifying storage"); 51 52 verifyStorage(packages, "afterInstall"); 53 54 info("Checking padding files before upgrade (storage version 2.0)"); 55 56 for (let origin of origins) { 57 let paddingFile = getRelativeFile(origin + paddingFilePath); 58 let exists = paddingFile.exists(); 59 ok(!exists, "Padding file doesn't exist"); 60 } 61 62 info("Initializing"); 63 64 // Initialize to trigger storage upgrade from version 2.0. 65 let request = init(continueToNextStepSync); 66 yield undefined; 67 68 Assert.equal(request.resultCode, NS_OK, "Initialization succeeded"); 69 70 info("Verifying storage"); 71 72 verifyStorage(packages, "afterInit"); 73 74 info("Checking padding files after upgrade"); 75 76 for (let origin of origins) { 77 let paddingFile = getRelativeFile(origin + paddingFilePath); 78 let exists = paddingFile.exists(); 79 ok(exists, "Padding file does exist"); 80 81 info("Reading out contents of padding file"); 82 83 File.createFromNsIFile(paddingFile).then(grabArgAndContinueHandler); 84 let domFile = yield undefined; 85 86 let fileReader = new FileReader(); 87 fileReader.onload = continueToNextStepSync; 88 fileReader.readAsArrayBuffer(domFile); 89 yield undefined; 90 91 let paddingFileInfo = new Float64Array(fileReader.result); 92 Assert.equal(paddingFileInfo.length, 1, "Padding file does take 64 bytes."); 93 Assert.equal(paddingFileInfo[0], 0, "Padding size does default to zero."); 94 } 95 96 finishTest(); 97 }