diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /dom/quota/test/xpcshell/upgrades/test_upgradeFromIndexedDBDirectory.js | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/quota/test/xpcshell/upgrades/test_upgradeFromIndexedDBDirectory.js')
-rw-r--r-- | dom/quota/test/xpcshell/upgrades/test_upgradeFromIndexedDBDirectory.js | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/dom/quota/test/xpcshell/upgrades/test_upgradeFromIndexedDBDirectory.js b/dom/quota/test/xpcshell/upgrades/test_upgradeFromIndexedDBDirectory.js new file mode 100644 index 0000000000..b1b0966d67 --- /dev/null +++ b/dom/quota/test/xpcshell/upgrades/test_upgradeFromIndexedDBDirectory.js @@ -0,0 +1,121 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +/** + * This test is mainly to verify + * MaybeUpgradeFromIndexedDBDirectoryToPersistentStorageDirectory method. + */ + +function* testSteps() { + const origins = [ + { + oldPath: "indexedDB/http+++www.mozilla.org", + newPath: "storage/default/http+++www.mozilla.org", + url: "http://www.mozilla.org", + persistence: "default", + }, + + { + oldPath: "indexedDB/1007+f+app+++system.gaiamobile.org", + }, + + { + oldPath: "indexedDB/1007+t+https+++developer.cdn.mozilla.net", + }, + ]; + + const packages = [ + // Storage used prior FF 26 (indexedDB/ directory). + "indexedDBDirectory_profile", + "../indexedDBDirectory_shared", + ]; + + info("Clearing"); + + clear(continueToNextStepSync); + yield undefined; + + info("Verifying storage"); + + verifyStorage(packages, "beforeInstall"); + + info("Installing package"); + + installPackages(packages); + + info("Verifying storage"); + + verifyStorage(packages, "afterInstall"); + + for (let origin of origins) { + let originDir = getRelativeFile(origin.oldPath); + let exists = originDir.exists(); + ok(exists, "Origin directory does exist"); + + if (origin.newPath) { + originDir = getRelativeFile(origin.newPath); + exists = originDir.exists(); + ok(!exists, "Origin directory doesn't exist"); + } + } + + info("Initializing"); + + let request = init(continueToNextStepSync); + yield undefined; + + ok(request.resultCode == NS_OK, "Initialization succeeded"); + + info("Verifying storage"); + + verifyStorage(packages, "afterInit"); + + // TODO: Remove this block once temporary storage initialization is able to + // ignore unknown directories. + getRelativeFile("storage/default/invalid+++example.com").remove(false); + + info("Checking origin directories"); + + for (let origin of origins) { + let originDir = getRelativeFile(origin.oldPath); + let exists = originDir.exists(); + ok(!exists, "Origin directory doesn't exist"); + + if (origin.newPath) { + originDir = getRelativeFile(origin.newPath); + exists = originDir.exists(); + ok(exists, "Origin directory does exist"); + } + } + + info("Initializing temporary storage"); + + request = initTemporaryStorage(continueToNextStepSync); + yield undefined; + + ok(request.resultCode == NS_OK, "Initialization succeeded"); + + info("Initializing origins"); + + for (const origin of origins) { + if (origin.newPath) { + info("Initializing origin"); + + let principal = getPrincipal(origin.url); + request = initTemporaryOrigin( + origin.persistence, + principal, + continueToNextStepSync + ); + yield undefined; + + ok(request.resultCode == NS_OK, "Initialization succeeded"); + + ok(!request.result, "Origin directory wasn't created"); + } + } + + finishTest(); +} |