2 <title>IDBCursor.continue() - index - add next element, and iterate to it</title>
3 <link rel="author" href="mailto:odinho@opera.com" title="Odin Hørthe Omdal">
4 <script src="../../../resources/testharness.js"></script>
5 <script src="../../../resources/testharnessreport.js"></script>
6 <script src="support.js"></script>
11 t = async_test(document.title, {timeout: 10000}),
12 records = [ { pKey: "primaryKey_0", obj: { iKey: "iKey_0" }},
13 { pKey: "primaryKey_2", obj: { iKey: "iKey_2" }} ],
15 expected = [ [ "primaryKey_2", "iKey_2" ],
16 [ "primaryKey_1", "iKey_1" ],
17 [ "primaryKey_0", "iKey_0" ] ];
19 var open_rq = createdb(t);
20 open_rq.onupgradeneeded = function(e) {
22 var objStore = db.createObjectStore("test", {keyPath:"pKey"});
23 objStore.createIndex("index", [ "pKey", "obj.iKey" ]);
25 for (var i = 0; i < records.length; i++)
26 objStore.add(records[i]);
29 open_rq.onsuccess = function(e) {
30 var cursor_rq = db.transaction("test", "readwrite")
33 .openCursor(null, "prev");
35 cursor_rq.onsuccess = t.step_func(function(e) {
36 var cursor = e.target.result;
38 assert_equals(count, 3, "cursor run count");
43 e.target.source.objectStore.add({ pKey: "primaryKey_1", obj: { iKey: "iKey_1" } });
45 assert_array_equals(cursor.key, expected[count], "primary key");