summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/IndexedDB/delete-range.any.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/IndexedDB/delete-range.any.js
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
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.js44
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.");
+ }
+ )
+}