summaryrefslogtreecommitdiffstats
path: root/dom/indexedDB/test/unit/test_autoIncrement_indexes.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /dom/indexedDB/test/unit/test_autoIncrement_indexes.js
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/indexedDB/test/unit/test_autoIncrement_indexes.js')
-rw-r--r--dom/indexedDB/test/unit/test_autoIncrement_indexes.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/dom/indexedDB/test/unit/test_autoIncrement_indexes.js b/dom/indexedDB/test/unit/test_autoIncrement_indexes.js
new file mode 100644
index 0000000000..64de7f4efb
--- /dev/null
+++ b/dom/indexedDB/test/unit/test_autoIncrement_indexes.js
@@ -0,0 +1,60 @@
+/**
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+/* exported testGenerator */
+var testGenerator = testSteps();
+
+function* testSteps() {
+ let request = indexedDB.open(
+ this.window ? window.location.pathname : "Splendid Test",
+ 1
+ );
+ request.onerror = errorHandler;
+ request.onupgradeneeded = grabEventAndContinueHandler;
+ let event = yield undefined;
+
+ let db = request.result;
+ db.onerror = errorHandler;
+
+ let objectStore = db.createObjectStore("foo", {
+ keyPath: "id",
+ autoIncrement: true,
+ });
+ objectStore.createIndex("first", "first");
+ objectStore.createIndex("second", "second");
+ objectStore.createIndex("third", "third");
+
+ let data = { first: "foo", second: "foo", third: "foo" };
+
+ objectStore.add(data).onsuccess = grabEventAndContinueHandler;
+ event = yield undefined;
+
+ is(event.target.result, 1, "Added entry");
+ request.onsuccess = grabEventAndContinueHandler;
+
+ event = yield undefined;
+
+ objectStore = db.transaction("foo").objectStore("foo");
+ let first = objectStore.index("first");
+ let second = objectStore.index("second");
+ let third = objectStore.index("third");
+
+ first.get("foo").onsuccess = grabEventAndContinueHandler;
+ event = yield undefined;
+
+ is(event.target.result.id, 1, "Entry in first");
+
+ second.get("foo").onsuccess = grabEventAndContinueHandler;
+ event = yield undefined;
+
+ is(event.target.result.id, 1, "Entry in second");
+
+ third.get("foo").onsuccess = grabEventAndContinueHandler;
+ event = yield undefined;
+
+ is(event.target.result.id, 1, "Entry in third");
+
+ finishTest();
+}