summaryrefslogtreecommitdiffstats
path: root/dom/indexedDB/test/unit/test_mutableFileUpgrade.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/indexedDB/test/unit/test_mutableFileUpgrade.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.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/indexedDB/test/unit/test_mutableFileUpgrade.js')
-rw-r--r--dom/indexedDB/test/unit/test_mutableFileUpgrade.js128
1 files changed, 128 insertions, 0 deletions
diff --git a/dom/indexedDB/test/unit/test_mutableFileUpgrade.js b/dom/indexedDB/test/unit/test_mutableFileUpgrade.js
new file mode 100644
index 0000000000..1875b29924
--- /dev/null
+++ b/dom/indexedDB/test/unit/test_mutableFileUpgrade.js
@@ -0,0 +1,128 @@
+/**
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+/* exported testGenerator */
+var testGenerator = testSteps();
+
+function* testSteps() {
+ const dbNames = ["No files", "Blobs and mutable files"];
+ const version = 1;
+ const objectStoreName = "test";
+
+ clearAllDatabases(continueToNextStepSync);
+ yield undefined;
+
+ installPackagedProfile("mutableFileUpgrade_profile");
+
+ let request = indexedDB.open(dbNames[0], version);
+ request.onerror = errorHandler;
+ request.onupgradeneeded = unexpectedSuccessHandler;
+ request.onsuccess = grabEventAndContinueHandler;
+ let event = yield undefined;
+
+ is(event.type, "success", "Correct event type");
+
+ let db = event.target.result;
+ db.onerror = errorHandler;
+
+ request = db
+ .transaction([objectStoreName])
+ .objectStore(objectStoreName)
+ .get(1);
+ request.onsuccess = grabEventAndContinueHandler;
+ event = yield undefined;
+
+ is(event.target.result, "text", "Correct result");
+
+ request = indexedDB.open(dbNames[1], version);
+ request.onerror = errorHandler;
+ request.onupgradeneeded = unexpectedSuccessHandler;
+ request.onsuccess = grabEventAndContinueHandler;
+ event = yield undefined;
+
+ is(event.type, "success", "Correct event type");
+
+ db = event.target.result;
+ db.onerror = errorHandler;
+
+ request = db
+ .transaction([objectStoreName])
+ .objectStore(objectStoreName)
+ .get(1);
+ request.onsuccess = grabEventAndContinueHandler;
+ event = yield undefined;
+
+ is(event.target.result, "text", "Correct result");
+
+ request = db
+ .transaction([objectStoreName])
+ .objectStore(objectStoreName)
+ .get(2);
+ request.onsuccess = grabEventAndContinueHandler;
+ event = yield undefined;
+
+ verifyBlob(event.target.result, getBlob("blob0"));
+ yield undefined;
+
+ request = db
+ .transaction([objectStoreName])
+ .objectStore(objectStoreName)
+ .get(3);
+ request.onsuccess = grabEventAndContinueHandler;
+ event = yield undefined;
+
+ let result = event.target.result;
+
+ verifyBlob(result[0], getBlob("blob1"));
+ yield undefined;
+
+ verifyBlob(result[1], getBlob("blob2"));
+ yield undefined;
+
+ request = db
+ .transaction([objectStoreName])
+ .objectStore(objectStoreName)
+ .get(4);
+ request.onsuccess = grabEventAndContinueHandler;
+ event = yield undefined;
+
+ try {
+ event.target.result;
+ ok(false, "IDBMutableFile must not be read");
+ } catch (err) {
+ is(err.name, "InvalidStateError", "Wrong error type");
+ }
+
+ request = db
+ .transaction([objectStoreName])
+ .objectStore(objectStoreName)
+ .get(5);
+ request.onsuccess = grabEventAndContinueHandler;
+ event = yield undefined;
+
+ try {
+ event.target.result;
+ ok(false, "IDBMutableFile must not be read");
+ } catch (err) {
+ is(err.name, "InvalidStateError", "Wrong error type");
+ }
+
+ request = db
+ .transaction([objectStoreName])
+ .objectStore(objectStoreName)
+ .get(6);
+ request.onsuccess = grabEventAndContinueHandler;
+ event = yield undefined;
+
+ try {
+ event.target.result;
+ ok(false, "IDBMutableFile must not be read");
+ } catch (err) {
+ is(err.name, "InvalidStateError", "Wrong error type");
+ }
+
+ finishTest();
+ yield undefined;
+}