diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/IndexedDB/delete-range.any.js | |
parent | Initial commit. (diff) | |
download | firefox-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/delete-range.any.js')
-rw-r--r-- | testing/web-platform/tests/IndexedDB/delete-range.any.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/testing/web-platform/tests/IndexedDB/delete-range.any.js b/testing/web-platform/tests/IndexedDB/delete-range.any.js new file mode 100644 index 0000000000..b86d646354 --- /dev/null +++ b/testing/web-platform/tests/IndexedDB/delete-range.any.js @@ -0,0 +1,44 @@ +// META: title=Delete range +// META: script=resources/support.js + +"use strict"; + +let entries = [ + { lower: 3, upper: 8, lowerOpen: false, upperOpen: false, expected: [1, 2, 9, 10]}, + { lower: 3, upper: 8, lowerOpen: true, upperOpen: false, expected: [1, 2, 3, 9, 10]}, + { lower: 3, upper: 8, lowerOpen: false, upperOpen: true, expected: [1, 2, 8, 9, 10]}, + { lower: 3, upper: 8, lowerOpen: true, upperOpen: true, expected: [1, 2, 3, 8, 9, 10]} +]; + +for (const entry of entries) { + indexeddb_test( + function upgrade_func(t, db) { + db.createObjectStore("store"); + }, + function open_func(t, db) { + const store = db.transaction("store", "readwrite", {durability: 'relaxed'}).objectStore("store"); + + for (let i = 1; i <= 10; ++i) { + store.put(i, i); + } + store.delete(IDBKeyRange.bound(entry.lower, + entry.upper, + entry.lowerOpen, + entry.upperOpen)); + + let keys = []; + const cursor_request = store.openCursor(); + cursor_request.onsuccess = t.step_func(function () { + const cursor = cursor_request.result; + if (cursor) { + keys.push(cursor.key); + cursor.continue(); + } else { + assert_array_equals(entry.expected, keys, `Expected: ${entry.expected}, got: ${keys}.`); + t.done(); + } + }); + cursor_request.onerror = t.unreached_func("Failed to open cursor for read request."); + } + ) +} |