summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/IndexedDB/idbcursor-direction-objectstore-keyrange.htm
diff options
context:
space:
mode:
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.htm54
1 files changed, 54 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 0000000000..b458ef0cbf
--- /dev/null
+++ b/testing/web-platform/tests/IndexedDB/idbcursor-direction-objectstore-keyrange.htm
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<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="resources/support.js"></script>
+
+<script>
+var records = [ 1337, "Alice", "Bob", "Greg", "Åke", ["Anne"] ];
+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(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);
+ });
+ },
+ document.title + ' - ' + dir
+ );
+});
+</script>