1 Test IndexedDB's cursor update. 2 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 4 5 6 webkitIndexedDB.open('cursor-update') 7 db = event.target.result 8 db.setVersion('new version') 9 setVersionSuccess(): 10 trans = event.target.result 11 PASS trans !== null is true 12 Deleted all object stores. 13 objectStore = db.createObjectStore('basicStore') 14 objectStore.add('myValue1', 'myKey1').onerror = unexpectedErrorCallback 15 objectStore.add('myValue2', 'myKey2').onerror = unexpectedErrorCallback 16 objectStore.add('myValue3', 'myKey3').onerror = unexpectedErrorCallback 17 objectStore.add('myValue4', 'myKey4').onerror = unexpectedErrorCallback 18 objectStore = db.createObjectStore('autoIncrementStore', {autoIncrement: true}) 19 objectStore.add('foo1').onerror = unexpectedErrorCallback 20 objectStore.add('foo2').onerror = unexpectedErrorCallback 21 objectStore.add('foo3').onerror = unexpectedErrorCallback 22 objectStore.add('foo4').onerror = unexpectedErrorCallback 23 objectStore = db.createObjectStore('keyPathStore', {keyPath: 'id'}) 24 objectStore.createIndex('numberIndex', 'number') 25 objectStore.add({number: 1, id: 1}).onerror = unexpectedErrorCallback 26 objectStore.add({number: 2, id: 2}).onerror = unexpectedErrorCallback 27 objectStore.add({number: 3, id: 3}).onerror = unexpectedErrorCallback 28 objectStore.add({number: 4, id: 4}).onerror = unexpectedErrorCallback 29 openBasicCursor() 30 trans = db.transaction([], webkitIDBTransaction.READ_WRITE) 31 trans.objectStore('basicStore') 32 objectStore.openCursor(keyRange) 33 basicUpdateCursor() 34 PASS event.target.source is objectStore 35 event.target.result.update('myUpdatedValue' + counter++) 36 event.target.source.continue() 37 basicUpdateCursor() 38 PASS event.target.source is objectStore 39 event.target.result.update('myUpdatedValue' + counter++) 40 event.target.source.continue() 41 basicUpdateCursor() 42 PASS event.target.source is objectStore 43 event.target.result.update('myUpdatedValue' + counter++) 44 event.target.source.continue() 45 basicUpdateCursor() 46 PASS event.target.source is objectStore 47 event.target.result.update('myUpdatedValue' + counter++) 48 event.target.source.continue() 49 basicUpdateCursor() 50 PASS event.target.source is objectStore 51 PASS counter is 5 52 trans.objectStore('basicStore').openCursor(keyRange) 53 basicCheckCursor() 54 PASS event.target.result.key is "myKey1" 55 PASS event.target.result.value is "myUpdatedValue1" 56 event.target.result.continue() 57 basicCheckCursor() 58 PASS event.target.result.key is "myKey2" 59 PASS event.target.result.value is "myUpdatedValue2" 60 event.target.result.continue() 61 basicCheckCursor() 62 PASS event.target.result.key is "myKey3" 63 PASS event.target.result.value is "myUpdatedValue3" 64 event.target.result.continue() 65 basicCheckCursor() 66 PASS event.target.result.key is "myKey4" 67 PASS event.target.result.value is "myUpdatedValue4" 68 event.target.result.continue() 69 basicCheckCursor() 70 PASS counter is 5 71 trans.objectStore('autoIncrementStore').openCursor(keyRange) 72 autoIncrementUpdateCursor() 73 event.target.result.update('myUpdatedFoo' + counter++) 74 event.target.source.continue() 75 autoIncrementUpdateCursor() 76 event.target.result.update('myUpdatedFoo' + counter++) 77 event.target.source.continue() 78 autoIncrementUpdateCursor() 79 event.target.result.update('myUpdatedFoo' + counter++) 80 event.target.source.continue() 81 autoIncrementUpdateCursor() 82 event.target.result.update('myUpdatedFoo' + counter++) 83 event.target.source.continue() 84 autoIncrementUpdateCursor() 85 PASS counter is 5 86 trans.objectStore('autoIncrementStore').openCursor(keyRange) 87 autoIncrementCheckCursor() 88 PASS event.target.result.key is counter 89 PASS event.target.result.value is "myUpdatedFoo1" 90 event.target.result.continue() 91 autoIncrementCheckCursor() 92 PASS event.target.result.key is counter 93 PASS event.target.result.value is "myUpdatedFoo2" 94 event.target.result.continue() 95 autoIncrementCheckCursor() 96 PASS event.target.result.key is counter 97 PASS event.target.result.value is "myUpdatedFoo3" 98 event.target.result.continue() 99 autoIncrementCheckCursor() 100 PASS event.target.result.key is counter 101 PASS event.target.result.value is "myUpdatedFoo4" 102 event.target.result.continue() 103 autoIncrementCheckCursor() 104 PASS counter is 5 105 trans.objectStore('keyPathStore').openCursor(keyRange) 106 keyPathUpdateCursor() 107 event.target.result.update({id: 100 + counter, number: 100 + counter}) 108 PASS event.target.errorCode is webkitIDBDatabaseException.DATA_ERR 109 event.preventDefault() 110 event.target.source.update({id: counter, number: 100 + counter++}) 111 event.target.source.continue() 112 keyPathUpdateCursor() 113 event.target.result.update({id: 100 + counter, number: 100 + counter}) 114 PASS event.target.errorCode is webkitIDBDatabaseException.DATA_ERR 115 event.preventDefault() 116 event.target.source.update({id: counter, number: 100 + counter++}) 117 event.target.source.continue() 118 keyPathUpdateCursor() 119 event.target.result.update({id: 100 + counter, number: 100 + counter}) 120 PASS event.target.errorCode is webkitIDBDatabaseException.DATA_ERR 121 event.preventDefault() 122 event.target.source.update({id: counter, number: 100 + counter++}) 123 event.target.source.continue() 124 keyPathUpdateCursor() 125 event.target.result.update({id: 100 + counter, number: 100 + counter}) 126 PASS event.target.errorCode is webkitIDBDatabaseException.DATA_ERR 127 event.preventDefault() 128 event.target.source.update({id: counter, number: 100 + counter++}) 129 event.target.source.continue() 130 keyPathUpdateCursor() 131 PASS counter is 5 132 trans.objectStore('keyPathStore').openCursor(keyRange) 133 keyPathCheckCursor() 134 PASS event.target.result.key is counter 135 PASS event.target.result.value.id is counter 136 PASS event.target.result.value.number is 101 137 event.target.result.continue() 138 keyPathCheckCursor() 139 PASS event.target.result.key is counter 140 PASS event.target.result.value.id is counter 141 PASS event.target.result.value.number is 102 142 event.target.result.continue() 143 keyPathCheckCursor() 144 PASS event.target.result.key is counter 145 PASS event.target.result.value.id is counter 146 PASS event.target.result.value.number is 103 147 event.target.result.continue() 148 keyPathCheckCursor() 149 PASS event.target.result.key is counter 150 PASS event.target.result.value.id is counter 151 PASS event.target.result.value.number is 104 152 event.target.result.continue() 153 keyPathCheckCursor() 154 PASS counter is 5 155 trans.objectStore('keyPathStore').index('numberIndex').openKeyCursor(keyRange) 156 keyCursor() 157 PASS event.target.result.key is counter + 100 158 PASS event.target.result.primaryKey is counter 159 event.target.result.update({id: counter, number: counter + 200}) 160 PASS code is webkitIDBDatabaseException.NOT_ALLOWED_ERR 161 keyCursor() 162 PASS event.target.result.key is counter + 100 163 PASS event.target.result.primaryKey is counter 164 event.target.result.update({id: counter, number: counter + 200}) 165 PASS code is webkitIDBDatabaseException.NOT_ALLOWED_ERR 166 keyCursor() 167 PASS event.target.result.key is counter + 100 168 PASS event.target.result.primaryKey is counter 169 event.target.result.update({id: counter, number: counter + 200}) 170 PASS code is webkitIDBDatabaseException.NOT_ALLOWED_ERR 171 keyCursor() 172 PASS event.target.result.key is counter + 100 173 PASS event.target.result.primaryKey is counter 174 event.target.result.update({id: counter, number: counter + 200}) 175 PASS code is webkitIDBDatabaseException.NOT_ALLOWED_ERR 176 keyCursor() 177 PASS counter is 5 178 transactionComplete() 179 PASS successfullyParsed is true 180 181 TEST COMPLETE 182 183