From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- .../reading-autoincrement-indexes-cursors.any.js | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 testing/web-platform/tests/IndexedDB/reading-autoincrement-indexes-cursors.any.js (limited to 'testing/web-platform/tests/IndexedDB/reading-autoincrement-indexes-cursors.any.js') 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'); -- cgit v1.2.3