summaryrefslogtreecommitdiffstats
path: root/dom/quota/test/xpcshell/upgrades/test_upgradeFromIndexedDBDirectory.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/quota/test/xpcshell/upgrades/test_upgradeFromIndexedDBDirectory.js
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
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.js121
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();
+}