| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <title>IDBCursor.primaryKey</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> | |
| 7 | |
| 8 <script> | |
| 9 | |
| 10 function cursor_primarykey(key) | |
| 11 { | |
| 12 var db, | |
| 13 t = async_test(document.title + " - " + key); | |
| 14 | |
| 15 var open_rq = createdb(t); | |
| 16 open_rq.onupgradeneeded = function(e) { | |
| 17 db = e.target.result; | |
| 18 var objStore = db.createObjectStore("test"); | |
| 19 objStore.createIndex("index", ""); | |
| 20 | |
| 21 objStore.add("data", key); | |
| 22 }; | |
| 23 | |
| 24 open_rq.onsuccess = t.step_func(function(e) { | |
| 25 var cursor_rq = db.transaction("test") | |
| 26 .objectStore("test") | |
| 27 .index("index") | |
| 28 .openCursor(); | |
| 29 | |
| 30 cursor_rq.onsuccess = t.step_func(function(e) { | |
| 31 var cursor = e.target.result; | |
| 32 | |
| 33 assert_equals(cursor.value, "data", "prequisite cursor.value"); | |
| 34 assert_equals(cursor.key, "data", "prequisite cursor.key"); | |
| 35 | |
| 36 assert_key_equals(cursor.primaryKey, key, 'primaryKey'); | |
| 37 assert_readonly(cursor, 'primaryKey'); | |
| 38 | |
| 39 if (key instanceof Array) { | |
| 40 cursor.primaryKey.push("new"); | |
| 41 key.push("new"); | |
| 42 | |
| 43 assert_key_equals(cursor.primaryKey, key, 'primaryKey after
array push'); | |
| 44 | |
| 45 // But we can not change key (like readonly, just a bit diff
erent) | |
| 46 cursor.key = 10; | |
| 47 assert_key_equals(cursor.primaryKey, key, 'key after assignm
ent'); | |
| 48 } | |
| 49 | |
| 50 t.done(); | |
| 51 }); | |
| 52 }); | |
| 53 } | |
| 54 | |
| 55 cursor_primarykey(1); | |
| 56 cursor_primarykey("key"); | |
| 57 cursor_primarykey(["my", "key"]); | |
| 58 | |
| 59 </script> | |
| 60 | |
| 61 <div id="log"></div> | |
| OLD | NEW |