OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>IDBCursor.advance() - index - attempt to advance backwards</title> |
| 3 <link rel="author" href="mailto:odinho@opera.com" title="Odin Hørthe Omdal"> |
| 4 <link rel=help href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#
widl-IDBCursor-advance-void-unsigned-long-count"> |
| 5 <link rel=assert title="The value passed into the count parameter was zero or a
negative number."> |
| 6 <script src="../../../resources/testharness.js"></script> |
| 7 <script src="../../../resources/testharnessreport.js"></script> |
| 8 <script src="support.js"></script> |
| 9 |
| 10 <script type="text/javascript"> |
| 11 |
| 12 var db, |
| 13 t = async_test(document.title, {timeout: 10000}), |
| 14 records = [ { pKey: "primaryKey_0", iKey: "indexKey_0" }, |
| 15 { pKey: "primaryKey_1", iKey: "indexKey_1" } ]; |
| 16 |
| 17 var open_rq = createdb(t); |
| 18 open_rq.onupgradeneeded = function(e) { |
| 19 db = e.target.result; |
| 20 var objStore = db.createObjectStore("test", { keyPath:"pKey" }); |
| 21 |
| 22 objStore.createIndex("index", "iKey"); |
| 23 |
| 24 for (var i = 0; i < records.length; i++) |
| 25 objStore.add(records[i]); |
| 26 }; |
| 27 |
| 28 open_rq.onsuccess = function(e) { |
| 29 var cursor_rq = db.transaction("test") |
| 30 .objectStore("test") |
| 31 .index("index") |
| 32 .openCursor(undefined, "next"); |
| 33 |
| 34 cursor_rq.onsuccess = t.step_func(function(e) { |
| 35 var cursor = e.target.result; |
| 36 |
| 37 assert_true(cursor != null, "cursor exist"); |
| 38 assert_throws(new TypeError(), |
| 39 function() { cursor.advance(-1); }); |
| 40 |
| 41 t.done(); |
| 42 }); |
| 43 }; |
| 44 |
| 45 </script> |
| 46 |
| 47 <div id="log"></div> |
OLD | NEW |