summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/IndexedDB/reading-autoincrement-indexes.any.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/IndexedDB/reading-autoincrement-indexes.any.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/IndexedDB/reading-autoincrement-indexes.any.js')
-rw-r--r--testing/web-platform/tests/IndexedDB/reading-autoincrement-indexes.any.js108
1 files changed, 108 insertions, 0 deletions
diff --git a/testing/web-platform/tests/IndexedDB/reading-autoincrement-indexes.any.js b/testing/web-platform/tests/IndexedDB/reading-autoincrement-indexes.any.js
new file mode 100644
index 0000000000..abff3dd8b5
--- /dev/null
+++ b/testing/web-platform/tests/IndexedDB/reading-autoincrement-indexes.any.js
@@ -0,0 +1,108 @@
+// 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 request = index.getAll();
+ const result = await promiseForRequest(testCase, request);
+ assert_equals(result.length, 32);
+ for (let i = 1; i <= 32; ++i) {
+ assert_equals(result[i - 1].id, i, 'Autoincrement key');
+ assert_equals(result[i - 1].name, nameForId(i), 'String property');
+ }
+
+ database.close();
+}, 'IDBIndex.getAll() for 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 request = index.getAllKeys();
+ const result = await promiseForRequest(testCase, request);
+ assert_equals(result.length, 32);
+ for (let i = 1; i <= 32; ++i)
+ assert_equals(result[i - 1], i, 'Autoincrement key');
+
+ database.close();
+}, 'IDBIndex.getAllKeys() for 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');
+
+ for (let i = 1; i <= 32; ++i) {
+ const request = index.get(i);
+ const result = await promiseForRequest(testCase, request);
+ assert_equals(result.id, i, 'autoincrement key');
+ assert_equals(result.name, nameForId(i), 'string property');
+ }
+
+ database.close();
+}, 'IDBIndex.get() for an index on the autoincrement key');
+
+promise_test(async testCase => {
+ const database = await setupAutoincrementDatabase(testCase);
+
+ const stringSortedIds = idsSortedByStringCompare();
+
+ const transaction = database.transaction(['store'], 'readonly');
+ const store = transaction.objectStore('store');
+ const index = store.index('by_name');
+ const request = index.getAll();
+ const result = await promiseForRequest(testCase, request);
+ assert_equals(result.length, 32);
+ for (let i = 1; i <= 32; ++i) {
+ assert_equals(result[i - 1].id, stringSortedIds[i - 1],
+ 'autoincrement key');
+ assert_equals(result[i - 1].name, nameForId(stringSortedIds[i - 1]),
+ 'string property');
+ }
+
+ database.close();
+}, 'IDBIndex.getAll() for an index not covering the autoincrement key');
+
+promise_test(async testCase => {
+ const database = await setupAutoincrementDatabase(testCase);
+
+ const stringSortedIds = idsSortedByStringCompare();
+
+ const transaction = database.transaction(['store'], 'readonly');
+ const store = transaction.objectStore('store');
+ const index = store.index('by_name');
+ const request = index.getAllKeys();
+ const result = await promiseForRequest(testCase, request);
+ assert_equals(result.length, 32);
+ for (let i = 1; i <= 32; ++i)
+ assert_equals(result[i - 1], stringSortedIds[i - 1], 'String property');
+
+ database.close();
+}, 'IDBIndex.getAllKeys() returns correct result for 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');
+
+ for (let i = 1; i <= 32; ++i) {
+ const request = index.get(nameForId(i));
+ const result = await promiseForRequest(testCase, request);
+ assert_equals(result.id, i, 'Autoincrement key');
+ assert_equals(result.name, nameForId(i), 'String property');
+ }
+
+ database.close();
+}, 'IDBIndex.get() for an index not covering the autoincrement key');