Bug 1290481 - P14: Add a test to verify QuotaManager upgrade from version 2 to version 3. r=bkelly, janv

MozReview-Commit-ID: KlVsaGhpABk

--HG--
extra : rebase_source : 465c2f8c45d3c7e5f2e3ac885b016ed15510bb9f
This commit is contained in:
Tom Tung 2017-07-18 19:08:59 +08:00
parent 44aaef6986
commit c4978e80f5
3 changed files with 78 additions and 0 deletions

View File

@ -0,0 +1,76 @@
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
var testGenerator = testSteps();
function* testSteps()
{
const origins = [
"storage/default/chrome/",
"storage/default/http+++www.mozilla.org/"
];
const paddingFilePath = "cache/.padding";
info("Clearing");
clear(continueToNextStepSync);
yield undefined;
// The profile contains two cache storages:
// - storage/default/chrome/cache,
// - storage/default/http+++www.mozilla.org/cache
// The file create_cache.js in the package was run locally, specifically it
// was temporarily added to xpcshell.ini and then executed:
// mach xpcshell-test --interactive dom/quota/test/unit/create_cache.js
// Note: it only creates the directory "storage/default/chrome/cache".
// To make it become the profile in the test, two more manual steps are
// needed.
// 1. Remove the folder "storage/temporary".
// 2. Copy the content under the "storage/default/chrome" to
// "storage/default/http+++www.mozilla.org".
installPackage("version3_0upgrade_profile");
info("Checking padding file before upgrade (QM version 2.0)");
for (let origin of origins) {
let paddingFile = getRelativeFile(origin + paddingFilePath);
let exists = paddingFile.exists();
ok(!exists, "Padding file doesn't exist");
}
info("Initializing");
// Initialize QuotaManager to trigger upgrade the QM to version 3.0
let request = init(continueToNextStepSync);
yield undefined;
ok(request.resultCode == NS_OK, "Initialization succeeded");
info("Checking padding files after upgrade (QM version 3.0)");
for (let origin of origins) {
let paddingFile = getRelativeFile(origin + paddingFilePath);
let exists = paddingFile.exists();
ok(exists, "Padding file does exist");
info("Reading out contents of padding file");
File.createFromNsIFile(paddingFile).then(grabArgAndContinueHandler);
let domFile = yield undefined;
let fileReader = new FileReader();
fileReader.onload = continueToNextStepSync;
fileReader.readAsArrayBuffer(domFile);
yield undefined;
let paddingFileInfo = new Float64Array(fileReader.result);
ok(paddingFileInfo.length == 1, "Padding file does take 64 bytes.");
ok(paddingFileInfo[0] == 0, "Padding size does default to zero.");
}
finishTest();
}

Binary file not shown.

View File

@ -16,6 +16,7 @@ support-files =
removeAppsUpgrade_profile.zip
storagePersistentUpgrade_profile.zip
tempMetadataCleanup_profile.zip
version3_0upgrade_profile.zip
[test_basics.js]
[test_bad_origin_directory.js]
@ -31,3 +32,4 @@ skip-if = release_or_beta
[test_storagePersistentUpgrade.js]
[test_tempMetadataCleanup.js]
[test_unknownFiles.js]
[test_version3_0upgrade.js]