2 <title>IDBCursor.continue() - objectstore - 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" },
13 { pKey: "primaryKey_2" } ],
14 expected_records = [ { pKey: "primaryKey_0" },
15 { pKey: "primaryKey_1" },
16 { pKey: "primaryKey_2" } ];
18 var open_rq = createdb(t);
19 open_rq.onupgradeneeded = function(e) {
21 var objStore = db.createObjectStore("test", {keyPath:"pKey"});
23 for (var i = 0; i < records.length; i++)
24 objStore.add(records[i]);
27 open_rq.onsuccess = function(e) {
28 var cursor_rq = db.transaction("test", "readwrite")
32 cursor_rq.onsuccess = t.step_func(function(e) {
33 var cursor = e.target.result;
35 assert_equals(count, 3, "cursor run count");
39 var record = cursor.value;
40 if (record.pKey == "primaryKey_0") {
41 e.target.source.add({ pKey: "primaryKey_1" });
43 assert_equals(record.pKey, expected_records[count].pKey, "primary key");