diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/IndexedDB/idbcursor-direction-objectstore.htm | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/IndexedDB/idbcursor-direction-objectstore.htm')
-rw-r--r-- | testing/web-platform/tests/IndexedDB/idbcursor-direction-objectstore.htm | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/testing/web-platform/tests/IndexedDB/idbcursor-direction-objectstore.htm b/testing/web-platform/tests/IndexedDB/idbcursor-direction-objectstore.htm new file mode 100644 index 0000000000..c099651a29 --- /dev/null +++ b/testing/web-platform/tests/IndexedDB/idbcursor-direction-objectstore.htm @@ -0,0 +1,56 @@ +<!DOCTYPE html> +<title>IDBCursor direction - object store</title> +<link rel="author" href="mailto:odinho@opera.com" title="Odin Hørthe Omdal"> +<link rel=help href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#cursor-iteration-operation"> +<link rel=assert title='If direction is "next", let found record be the first record in records which satisfy all of the following requirements'> +<link rel=assert title="If position is defined, and source is an object store, the record's key is greater than position."> +<link rel=assert title='If direction is "prev", let found record be the last record in records which satisfy all of the following requirements'> +<link rel=assert title="If position is defined, and source is an object store, the record's key is less than position."> +<link rel=assert title="Set cursor's position to found record's key. If source is an index, set cursor's object store position to found record's value."> +<link rel=assert title="Set cursor's key to found record's key."> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="resources/support.js"></script> + +<script> +var records = [ "Alice", "Bob", "Greg" ]; +var directions = ["next", "prev", "nextunique", "prevunique"]; +var cases = [ + {dir: 'next', expect: ['Alice', 'Bob', 'Greg']}, + {dir: 'prev', expect: ['Greg', 'Bob', 'Alice']}, + {dir: 'nextunique', expect: ['Alice', 'Bob', 'Greg']}, + {dir: 'prevunique', expect: ['Greg', 'Bob', 'Alice']}, +]; + +cases.forEach(function(testcase) { + var dir = testcase.dir; + var expect = testcase.expect; + indexeddb_test( + function(t, db, tx) { + var objStore = db.createObjectStore("test"); + for (var i = 0; i < records.length; i++) + objStore.add(records[i], records[i]); + }, + function(t, db) { + var count = 0; + var rq = db.transaction("test", "readonly", {durability: 'relaxed'}).objectStore("test").openCursor(undefined, dir); + rq.onsuccess = t.step_func(function(e) { + var cursor = e.target.result; + if (!cursor) { + assert_equals(count, expect.length, "cursor runs"); + t.done(); + } + assert_equals(cursor.value, expect[count], "cursor.value"); + count++; + cursor.continue(); + }); + rq.onerror = t.step_func(function(e) { + e.preventDefault(); + e.stopPropagation(); + assert_unreached("rq.onerror - " + e.message); + }); + }, + document.title + ' - ' + dir + ); +}); +</script> |