summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/IndexedDB/idbcursor-direction-objectstore-keyrange.htm
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/IndexedDB/idbcursor-direction-objectstore-keyrange.htm
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/IndexedDB/idbcursor-direction-objectstore-keyrange.htm')
-rw-r--r--testing/web-platform/tests/IndexedDB/idbcursor-direction-objectstore-keyrange.htm77
1 files changed, 77 insertions, 0 deletions
diff --git a/testing/web-platform/tests/IndexedDB/idbcursor-direction-objectstore-keyrange.htm b/testing/web-platform/tests/IndexedDB/idbcursor-direction-objectstore-keyrange.htm
new file mode 100644
index 000000000..2b2bf04bf
--- /dev/null
+++ b/testing/web-platform/tests/IndexedDB/idbcursor-direction-objectstore-keyrange.htm
@@ -0,0 +1,77 @@
+<!DOCTYPE html>
+<title>IDBCursor direction - object store with keyrange</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 direction is "prev", let found record be the last record in records which satisfy all of the following requirements'>
+<link rel=assert title="If range is defined, the record's key is in range.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="support.js"></script>
+
+<script>
+ var records = [ 1337, "Alice", "Bob", "Greg", "Åke", ["Anne"] ];
+ var directions = ["next", "prev", "nextunique", "prevunique"];
+ var tests = {};
+
+ directions.forEach(function(dir) {
+ tests[dir] = async_test(document.title + ' - ' + dir);
+ });
+
+ var open_rq = indexedDB.open("testdb-" + new Date().getTime() + Math.random());
+
+ open_rq.onupgradeneeded = function(e) {
+ var objStore = e.target.result.createObjectStore("test");
+
+ for (var i = 0; i < records.length; i++)
+ objStore.add(records[i], records[i]);
+ };
+
+ open_rq.onsuccess = function(e) {
+ var db = e.target.result;
+ db.onerror = fail_helper("db.onerror");
+
+
+ // The tests
+ testdir('next', ['Alice', 'Bob', 'Greg']);
+ testdir('prev', ['Greg', 'Bob', 'Alice']);
+ testdir('nextunique', ['Alice', 'Bob', 'Greg']);
+ testdir('prevunique', ['Greg', 'Bob', 'Alice']);
+
+
+ // Test function
+ function testdir(dir, expect) {
+ var count = 0;
+ var t = tests[dir];
+ var rq = db.transaction("test").objectStore("test").openCursor(IDBKeyRange.bound("AA", "ZZ"), 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);
+ });
+ }
+ };
+
+ // Fail handling
+ function fail_helper(name) {
+ return function() {
+ directions.forEach(function(dir) {
+ tests[dir].step(function() { assert_unreached(name); });
+ });
+ };
+ }
+ open_rq.onblocked = fail_helper('open_rq.onblocked');
+ open_rq.onerror = fail_helper('open_rq.onerror');
+</script>
+
+<div id=log> </div>