diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/quota/test/xpcshell/upgrades/test_upgradeFromFlatOriginDirectories.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/quota/test/xpcshell/upgrades/test_upgradeFromFlatOriginDirectories.js')
-rw-r--r-- | dom/quota/test/xpcshell/upgrades/test_upgradeFromFlatOriginDirectories.js | 187 |
1 files changed, 187 insertions, 0 deletions
diff --git a/dom/quota/test/xpcshell/upgrades/test_upgradeFromFlatOriginDirectories.js b/dom/quota/test/xpcshell/upgrades/test_upgradeFromFlatOriginDirectories.js new file mode 100644 index 0000000000..f33ddac8ca --- /dev/null +++ b/dom/quota/test/xpcshell/upgrades/test_upgradeFromFlatOriginDirectories.js @@ -0,0 +1,187 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +// A flat origin directory is an origin directory with no sub directories for +// quota clients. The upgrade was initially done lazily and an empty .metadata +// file was used to indicate a successful upgrade. + +function* testSteps() { + const setups = [ + { + packages: [ + // Storage used prior FF 22 (indexedDB/ directory with flat origin + // directories). + // FF 26 renamed indexedDB/ to storage/persistent and the lazy upgrade + // of flat origin directories remained. There's a test for that below. + "indexedDBDirectory_flatOriginDirectories_profile", + "../indexedDBDirectory_shared", + ], + origins: [ + { + oldPath: "indexedDB/1007+f+app+++system.gaiamobile.org", + }, + + { + oldPath: "indexedDB/1007+t+https+++developer.cdn.mozilla.net", + }, + + { + oldPath: "indexedDB/http+++www.mozilla.org", + newPath: "storage/default/http+++www.mozilla.org", + url: "http://www.mozilla.org", + persistence: "default", + }, + ], + }, + + { + packages: [ + // Storage used by FF 26-35 (storage/persistent/ directory with not yet + // upgraded flat origin directories). + // FF 36 renamed storage/persistent/ to storage/default/ and all not + // yet upgraded flat origin directories were upgraded. There's a + // separate test for that: + // test_upgradeFromPersistentStorageDirectory_upgradeOriginDirectories. + "persistentStorageDirectory_flatOriginDirectories_profile", + "../persistentStorageDirectory_shared", + ], + origins: [ + { + oldPath: "storage/persistent/1007+f+app+++system.gaiamobile.org", + }, + + { + oldPath: + "storage/persistent/1007+t+https+++developer.cdn.mozilla.net", + }, + + { + oldPath: "storage/persistent/http+++www.mozilla.org", + newPath: "storage/default/http+++www.mozilla.org", + url: "http://www.mozilla.org", + persistence: "default", + }, + ], + }, + ]; + + const metadataFileName = ".metadata"; + + for (const setup of setups) { + clear(continueToNextStepSync); + yield undefined; + + info("Verifying storage"); + + verifyStorage(setup.packages, "beforeInstall"); + + info("Installing packages"); + + installPackages(setup.packages); + + info("Verifying storage"); + + verifyStorage(setup.packages, "afterInstall"); + + info("Checking origin directories"); + + for (const origin of setup.origins) { + let originDir = getRelativeFile(origin.oldPath); + let exists = originDir.exists(); + ok(exists, "Origin directory does exist"); + + let idbDir = originDir.clone(); + idbDir.append("idb"); + + exists = idbDir.exists(); + ok(!exists, "idb directory doesn't exist"); + + let metadataFile = originDir.clone(); + metadataFile.append(metadataFileName); + + exists = metadataFile.exists(); + ok(!exists, "Metadata file doesn't 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(setup.packages, "afterInit"); + + // TODO: Remove this block once temporary storage initialization is able to + // ignore unknown directories. + getRelativeFile("storage/default/invalid+++example.com").remove(false); + try { + getRelativeFile("storage/temporary/invalid+++example.com").remove(false); + } catch (ex) {} + + info("Checking origin directories"); + + for (const origin of setup.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"); + + let idbDir = originDir.clone(); + idbDir.append("idb"); + + exists = idbDir.exists(); + ok(exists, "idb directory does exist"); + + let metadataFile = originDir.clone(); + metadataFile.append(metadataFileName); + + exists = metadataFile.exists(); + ok(exists, "Metadata file 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 setup.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(); +} |