summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/IndexedDB/reading-autoincrement-indexes-cursors.any.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 /testing/web-platform/tests/IndexedDB/reading-autoincrement-indexes-cursors.any.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 'testing/web-platform/tests/IndexedDB/reading-autoincrement-indexes-cursors.any.js')
-rw-r--r--testing/web-platform/tests/IndexedDB/reading-autoincrement-indexes-cursors.any.js88
1 files changed, 88 insertions, 0 deletions
diff --git a/testing/web-platform/tests/IndexedDB/reading-autoincrement-indexes-cursors.any.js b/testing/web-platform/tests/IndexedDB/reading-autoincrement-indexes-cursors.any.js
new file mode 100644
index 0000000000..ff71000683
--- /dev/null
+++ b/testing/web-platform/tests/IndexedDB/reading-autoincrement-indexes-cursors.any.js
@@ -0,0 +1,88 @@
+// META: global=window,dedicatedworker,sharedworker,serviceworker
+// META: script=resources/support-promises.js
+// META: script=resources/reading-autoincrement-common.js
+
+promise_test(async testCase => {
+ const database = await setupAutoincrementDatabase(testCase);
+
+ const transaction = database.transaction(['store'], 'readonly');
+ const store = transaction.objectStore('store');
+ const index = store.index('by_id');
+
+ const result = await getAllViaCursor(testCase, index);
+ assert_equals(result.length, 32);
+ for (let i = 1; i <= 32; ++i) {
+ assert_equals(result[i - 1].key, i, 'Autoincrement index key');
+ assert_equals(result[i - 1].primaryKey, i, 'Autoincrement primary key');
+ assert_equals(result[i - 1].value.id, i, 'Autoincrement key in value');
+ assert_equals(result[i - 1].value.name, nameForId(i),
+ 'String property in value');
+ }
+
+ database.close();
+}, 'IDBIndex.openCursor() iterates over an index on the autoincrement key');
+
+promise_test(async testCase => {
+ const database = await setupAutoincrementDatabase(testCase);
+
+ const transaction = database.transaction(['store'], 'readonly');
+ const store = transaction.objectStore('store');
+ const index = store.index('by_id');
+
+ const result = await getAllKeysViaCursor(testCase, index);
+ assert_equals(result.length, 32);
+ for (let i = 1; i <= 32; ++i) {
+ assert_equals(result[i - 1].key, i, 'Autoincrement index key');
+ assert_equals(result[i - 1].primaryKey, i, 'Autoincrement primary key');
+ }
+
+ database.close();
+}, 'IDBIndex.openKeyCursor() iterates over an index on the autoincrement key');
+
+promise_test(async testCase => {
+ const database = await setupAutoincrementDatabase(testCase);
+
+ const transaction = database.transaction(['store'], 'readonly');
+ const store = transaction.objectStore('store');
+ const index = store.index('by_name');
+
+ const stringSortedIds = idsSortedByStringCompare();
+
+ const result = await getAllViaCursor(testCase, index);
+ assert_equals(result.length, 32);
+ for (let i = 1; i <= 32; ++i) {
+ assert_equals(result[i - 1].key, nameForId(stringSortedIds[i - 1]),
+ 'Index key');
+ assert_equals(result[i - 1].primaryKey, stringSortedIds[i - 1],
+ 'Autoincrement primary key');
+ assert_equals(result[i - 1].value.id, stringSortedIds[i - 1],
+ 'Autoincrement key in value');
+ assert_equals(result[i - 1].value.name, nameForId(stringSortedIds[i - 1]),
+ 'String property in value');
+ }
+
+ database.close();
+}, 'IDBIndex.openCursor() iterates over an index not covering the ' +
+ 'autoincrement key');
+
+promise_test(async testCase => {
+ const database = await setupAutoincrementDatabase(testCase);
+
+ const transaction = database.transaction(['store'], 'readonly');
+ const store = transaction.objectStore('store');
+ const index = store.index('by_name');
+
+ const stringSortedIds = idsSortedByStringCompare();
+
+ const result = await getAllKeysViaCursor(testCase, index);
+ assert_equals(result.length, 32);
+ for (let i = 1; i <= 32; ++i) {
+ assert_equals(result[i - 1].key, nameForId(stringSortedIds[i - 1]),
+ 'Index key');
+ assert_equals(result[i - 1].primaryKey, stringSortedIds[i - 1],
+ 'Autoincrement primary key');
+ }
+
+ database.close();
+}, 'IDBIndex.openKeyCursor() iterates over an index not covering the ' +
+ 'autoincrement key');