| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <title>IDBCursor.source</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 setup({ explicit_done: true }); | |
| 10 | |
| 11 var db; | |
| 12 var open_rq = indexedDB.open('testdb-' + new Date().getTime()); | |
| 13 open_rq.onupgradeneeded = function(e) { | |
| 14 db = e.target.result; | |
| 15 var objStore = db.createObjectStore("my_objectstore"); | |
| 16 objStore.createIndex("my_index", ""); | |
| 17 | |
| 18 objStore.add("data", 1); | |
| 19 objStore.add("data2", 2); | |
| 20 }; | |
| 21 | |
| 22 function cursor_source(name, stringified_object, cursor_rq) { | |
| 23 var cursor; | |
| 24 | |
| 25 cursor_rq.onsuccess = this.step_func(function(e) { | |
| 26 if (!e.target.result) { | |
| 27 return; | |
| 28 } | |
| 29 cursor = e.target.result; | |
| 30 assert_readonly(cursor, 'source'); | |
| 31 | |
| 32 // Direct try | |
| 33 assert_true(cursor.source instanceof Object, "source isobject"); | |
| 34 assert_equals(cursor.source + "", stringified_object, "source"); | |
| 35 assert_equals(cursor.source.name, name, "name"); | |
| 36 | |
| 37 cursor.continue(); | |
| 38 }); | |
| 39 | |
| 40 cursor_rq.transaction.oncomplete = this.step_func(function(e) { | |
| 41 this.done(); | |
| 42 }); | |
| 43 | |
| 44 cursor_rq.transaction.onerror = this.step_func(function(e) { | |
| 45 assert_unreached("Transaction got error. " + (e.target.error ? e.tar
get.error.name : "unknown")); | |
| 46 }); | |
| 47 } | |
| 48 | |
| 49 open_rq.onsuccess = function() { | |
| 50 async_test(document.title + ' - IDBObjectStore').step(function() { | |
| 51 cursor_source.call(this, "my_objectstore", "[object IDBObjectStore]"
, db.transaction("my_objectstore") | |
| 52 .objectStore("my_objectst
ore") | |
| 53 .openCursor()); | |
| 54 }); | |
| 55 | |
| 56 async_test(document.title + ' - IDBIndex').step(function() { | |
| 57 cursor_source.call(this, "my_index", "[object IDBIndex]", db.transac
tion("my_objectstore") | |
| 58 .objectStore("my_objectstore") | |
| 59 .index("my_index") | |
| 60 .openCursor()); | |
| 61 }); | |
| 62 | |
| 63 done(); | |
| 64 }; | |
| 65 | |
| 66 </script> | |
| 67 | |
| 68 <div id="log"></div> | |
| OLD | NEW |