2 <title>IDBCursor.continue() - objectstore - delete 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});
13 var open_rq = createdb(t);
14 open_rq.onupgradeneeded = function(e) {
16 var objStore = db.createObjectStore("test", { keyPath: "key" });
18 for (var i = 0; i < 500; i++)
19 objStore.add({ key: i, val: "val_"+i });
21 var rq = objStore.add({ key: 500, val: "val_500" });
23 rq.onsuccess = t.step_func(function() {
24 for (var i = 999; i > 500; i--)
25 objStore.add({ key: i, val: "val_"+i });
28 objStore.createIndex('index', ['key', 'val']);
31 open_rq.onsuccess = function(e) {
32 var cursor_rq = db.transaction("test", "readwrite")
36 cursor_rq.onsuccess = t.step_func(function(e) {
37 var cursor = e.target.result,
38 store = e.target.source;
40 assert_equals(count, 997, "cursor run count");
42 var rq = e.target.source.count();
43 rq.onsuccess = t.step_func(function(e) {
44 assert_equals(e.target.result, 995, "object count");
52 assert_equals(count, cursor.key, "count");
60 assert_equals(count, cursor.key - 1, "count");
63 // Delete the next key
75 // Delete and add a new key
78 store.add({ key: 521, val: "new"});
82 assert_equals(cursor.value.val, "new");
85 // We should only be here once although we're basically making the index
86 // "heavier" with its new key.
88 assert_equals(cursor.value.val, "val_530");
89 cursor.update({ key: 530, val: "val_531" })
91 store.get(530).onsuccess = t.step_func(function(e) {
92 assert_equals(e.target.result.val, "val_531");
100 assert_unreached(cursor.key + " should be deleted and never run");
110 <div id="log"> </div>