| OLD | NEW | 
| (Empty) |  | 
 |   1 <!DOCTYPE html> | 
 |   2 <title>IDBCursor.continue() - index - iterate using nextunique</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#
    cursor-iteration-operation"> | 
 |   5 <link rel=assert title='If direction is "nextunique", let found record be the fi
    rst record in records which satisfy all of the following requirements:'> | 
 |   6 <link rel=assert title="If position is defined, the record's key is greater than
     position."> | 
 |   7 <script src="../../../resources/testharness.js"></script> | 
 |   8 <script src="../../../resources/testharnessreport.js"></script> | 
 |   9 <script src="support.js"></script> | 
 |  10  | 
 |  11 <script> | 
 |  12  | 
 |  13     var db, | 
 |  14       t = async_test(document.title, {timeout: 10000}), | 
 |  15       records = [ { pKey: "primaryKey_0",   iKey: "indexKey_0" }, | 
 |  16                   { pKey: "primaryKey_1",   iKey: "indexKey_1" }, | 
 |  17                   { pKey: "primaryKey_1-2", iKey: "indexKey_1" }, | 
 |  18                   { pKey: "primaryKey_2",   iKey: "indexKey_2" } ], | 
 |  19  | 
 |  20       expected = [ { pKey: "primaryKey_0",   iKey: "indexKey_0" }, | 
 |  21                  { pKey: "primaryKey_1",   iKey: "indexKey_1" }, | 
 |  22                  { pKey: "primaryKey_2",   iKey: "indexKey_2" } ]; | 
 |  23  | 
 |  24     var open_rq = createdb(t); | 
 |  25     open_rq.onupgradeneeded = function(e) { | 
 |  26         db = e.target.result; | 
 |  27         var objStore = db.createObjectStore("test", { keyPath: "pKey" }); | 
 |  28  | 
 |  29         objStore.createIndex("index", "iKey"); | 
 |  30  | 
 |  31         for (var i = 0; i < records.length; i++) | 
 |  32             objStore.add(records[i]); | 
 |  33     }; | 
 |  34  | 
 |  35     open_rq.onsuccess = function(e) { | 
 |  36         var count = 0, | 
 |  37           cursor_rq = db.transaction("test") | 
 |  38                         .objectStore("test") | 
 |  39                         .index("index") | 
 |  40                         .openCursor(undefined, "nextunique"); | 
 |  41  | 
 |  42         cursor_rq.onsuccess = t.step_func(function(e) { | 
 |  43             if (!e.target.result) { | 
 |  44                 assert_equals(count, expected.length, 'count'); | 
 |  45                 t.done(); | 
 |  46                 return; | 
 |  47             } | 
 |  48             var cursor = e.target.result, | 
 |  49               record = cursor.value; | 
 |  50  | 
 |  51             assert_equals(record.pKey, expected[count].pKey, "pKey #" + count); | 
 |  52             assert_equals(record.iKey, expected[count].iKey, "iKey #" + count); | 
 |  53  | 
 |  54             assert_equals(cursor.key,  expected[count].iKey, "cursor.key #" + co
    unt); | 
 |  55             assert_equals(cursor.primaryKey, expected[count].pKey, "cursor.prima
    ryKey #" + count); | 
 |  56  | 
 |  57             count++; | 
 |  58             cursor.continue(expected[count] ? expected[count].iKey : undefined); | 
 |  59         }); | 
 |  60     }; | 
 |  61  | 
 |  62 </script> | 
 |  63  | 
 |  64 <div id="log"></div> | 
| OLD | NEW |