OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>IDBCursor.continue() - index - iterate to the next record</title> |
| 3 <link rel="author" title="Microsoft" href="http://www.microsoft.com"> |
| 4 <link rel=help href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#
widl-IDBCursor-continue-void-any-key"> |
| 5 <link rel=assert title="Otherwise this method runs the steps for asynchronously
executing a request."> |
| 6 <script src="../../../resources/testharness.js"></script> |
| 7 <script src="../../../resources/testharnessreport.js"></script> |
| 8 <script src="support.js"></script> |
| 9 |
| 10 <script> |
| 11 var db, |
| 12 count = 0, |
| 13 t = async_test(), |
| 14 records = [ { pKey: "primaryKey_0", iKey: "indexKey_0" }, |
| 15 { pKey: "primaryKey_1", iKey: "indexKey_1" }, |
| 16 { pKey: "primaryKey_1-2", iKey: "indexKey_1" } ]; |
| 17 |
| 18 var open_rq = createdb(t); |
| 19 open_rq.onupgradeneeded = function(e) { |
| 20 db = e.target.result; |
| 21 var objStore = db.createObjectStore("test", { keyPath:"pKey" }); |
| 22 |
| 23 objStore.createIndex("index", "iKey"); |
| 24 |
| 25 for (var i = 0; i < records.length; i++) |
| 26 objStore.add(records[i]); |
| 27 }; |
| 28 |
| 29 open_rq.onsuccess = function(e) { |
| 30 var cursor_rq = db.transaction("test") |
| 31 .objectStore("test") |
| 32 .index("index") |
| 33 .openCursor(); |
| 34 |
| 35 cursor_rq.onsuccess = t.step_func(function(e) { |
| 36 var cursor = e.target.result; |
| 37 if (!cursor) { |
| 38 assert_equals(count, records.length, "cursor run count"); |
| 39 t.done(); |
| 40 } |
| 41 |
| 42 var record = cursor.value; |
| 43 assert_equals(record.pKey, records[count].pKey, "primary key"); |
| 44 assert_equals(record.iKey, records[count].iKey, "index key"); |
| 45 |
| 46 cursor.continue(); |
| 47 count++; |
| 48 }); |
| 49 }; |
| 50 </script> |
| 51 |
| 52 <div id="log"></div> |
OLD | NEW |