| OLD | NEW |
| 1 Test IndexedDB's transaction and objectStore calls | 1 Test IndexedDB's transaction and objectStore calls |
| 2 | 2 |
| 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
". | 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
". |
| 4 | 4 |
| 5 | 5 |
| 6 indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.
msIndexedDB || self.OIndexedDB; | 6 indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.
msIndexedDB || self.OIndexedDB; |
| 7 | 7 |
| 8 dbname = "transaction-and-objectstore-calls.html" | 8 dbname = "transaction-and-objectstore-calls.html" |
| 9 indexedDB.deleteDatabase(dbname) | 9 indexedDB.deleteDatabase(dbname) |
| 10 indexedDB.open(dbname) | 10 indexedDB.open(dbname) |
| 11 db.createObjectStore('a') | 11 db.createObjectStore('a') |
| 12 db.createObjectStore('b') | 12 db.createObjectStore('b') |
| 13 db.createObjectStore('store').createIndex('index', 'some_path') | 13 db.createObjectStore('store').createIndex('index', 'some_path') |
| 14 | 14 |
| 15 trans = db.transaction(['a']) | 15 trans = db.transaction(['a']) |
| 16 trans.objectStore('a') | 16 trans.objectStore('a') |
| 17 Expecting exception from trans.objectStore('b') | 17 Expecting exception from trans.objectStore('b') |
| 18 PASS Exception was thrown. | 18 PASS Exception was thrown. |
| 19 PASS code is DOMException.NOT_FOUND_ERR | 19 PASS code is DOMException.NOT_FOUND_ERR |
| 20 PASS ename is 'NotFoundError' | 20 PASS ename is 'NotFoundError' |
| 21 Exception message: The specified object store was not found. |
| 21 Expecting exception from trans.objectStore('x') | 22 Expecting exception from trans.objectStore('x') |
| 22 PASS Exception was thrown. | 23 PASS Exception was thrown. |
| 23 PASS code is DOMException.NOT_FOUND_ERR | 24 PASS code is DOMException.NOT_FOUND_ERR |
| 24 PASS ename is 'NotFoundError' | 25 PASS ename is 'NotFoundError' |
| 26 Exception message: The specified object store was not found. |
| 25 | 27 |
| 26 trans = db.transaction(['a']) | 28 trans = db.transaction(['a']) |
| 27 trans.objectStore('a') | 29 trans.objectStore('a') |
| 28 Expecting exception from trans.objectStore('b') | 30 Expecting exception from trans.objectStore('b') |
| 29 PASS Exception was thrown. | 31 PASS Exception was thrown. |
| 30 PASS code is DOMException.NOT_FOUND_ERR | 32 PASS code is DOMException.NOT_FOUND_ERR |
| 31 PASS ename is 'NotFoundError' | 33 PASS ename is 'NotFoundError' |
| 34 Exception message: The specified object store was not found. |
| 32 Expecting exception from trans.objectStore('x') | 35 Expecting exception from trans.objectStore('x') |
| 33 PASS Exception was thrown. | 36 PASS Exception was thrown. |
| 34 PASS code is DOMException.NOT_FOUND_ERR | 37 PASS code is DOMException.NOT_FOUND_ERR |
| 35 PASS ename is 'NotFoundError' | 38 PASS ename is 'NotFoundError' |
| 39 Exception message: The specified object store was not found. |
| 36 | 40 |
| 37 trans = db.transaction(['b']) | 41 trans = db.transaction(['b']) |
| 38 trans.objectStore('b') | 42 trans.objectStore('b') |
| 39 Expecting exception from trans.objectStore('a') | 43 Expecting exception from trans.objectStore('a') |
| 40 PASS Exception was thrown. | 44 PASS Exception was thrown. |
| 41 PASS code is DOMException.NOT_FOUND_ERR | 45 PASS code is DOMException.NOT_FOUND_ERR |
| 42 PASS ename is 'NotFoundError' | 46 PASS ename is 'NotFoundError' |
| 47 Exception message: The specified object store was not found. |
| 43 Expecting exception from trans.objectStore('x') | 48 Expecting exception from trans.objectStore('x') |
| 44 PASS Exception was thrown. | 49 PASS Exception was thrown. |
| 45 PASS code is DOMException.NOT_FOUND_ERR | 50 PASS code is DOMException.NOT_FOUND_ERR |
| 46 PASS ename is 'NotFoundError' | 51 PASS ename is 'NotFoundError' |
| 52 Exception message: The specified object store was not found. |
| 47 | 53 |
| 48 trans = db.transaction(['a', 'b']) | 54 trans = db.transaction(['a', 'b']) |
| 49 trans.objectStore('a') | 55 trans.objectStore('a') |
| 50 trans.objectStore('b') | 56 trans.objectStore('b') |
| 51 Expecting exception from trans.objectStore('x') | 57 Expecting exception from trans.objectStore('x') |
| 52 PASS Exception was thrown. | 58 PASS Exception was thrown. |
| 53 PASS code is DOMException.NOT_FOUND_ERR | 59 PASS code is DOMException.NOT_FOUND_ERR |
| 54 PASS ename is 'NotFoundError' | 60 PASS ename is 'NotFoundError' |
| 61 Exception message: The specified object store was not found. |
| 55 | 62 |
| 56 trans = db.transaction(['b', 'a']) | 63 trans = db.transaction(['b', 'a']) |
| 57 trans.objectStore('a') | 64 trans.objectStore('a') |
| 58 trans.objectStore('b') | 65 trans.objectStore('b') |
| 59 Expecting exception from trans.objectStore('x') | 66 Expecting exception from trans.objectStore('x') |
| 60 PASS Exception was thrown. | 67 PASS Exception was thrown. |
| 61 PASS code is DOMException.NOT_FOUND_ERR | 68 PASS code is DOMException.NOT_FOUND_ERR |
| 62 PASS ename is 'NotFoundError' | 69 PASS ename is 'NotFoundError' |
| 70 Exception message: The specified object store was not found. |
| 63 | 71 |
| 64 Passing a string as the first argument is a shortcut for just one object store: | 72 Passing a string as the first argument is a shortcut for just one object store: |
| 65 trans = db.transaction('a') | 73 trans = db.transaction('a') |
| 66 trans.objectStore('a') | 74 trans.objectStore('a') |
| 67 Expecting exception from trans.objectStore('b') | 75 Expecting exception from trans.objectStore('b') |
| 68 PASS Exception was thrown. | 76 PASS Exception was thrown. |
| 69 PASS code is DOMException.NOT_FOUND_ERR | 77 PASS code is DOMException.NOT_FOUND_ERR |
| 70 PASS ename is 'NotFoundError' | 78 PASS ename is 'NotFoundError' |
| 79 Exception message: The specified object store was not found. |
| 71 Expecting exception from trans.objectStore('x') | 80 Expecting exception from trans.objectStore('x') |
| 72 PASS Exception was thrown. | 81 PASS Exception was thrown. |
| 73 PASS code is DOMException.NOT_FOUND_ERR | 82 PASS code is DOMException.NOT_FOUND_ERR |
| 74 PASS ename is 'NotFoundError' | 83 PASS ename is 'NotFoundError' |
| 84 Exception message: The specified object store was not found. |
| 75 | 85 |
| 76 PASS trans = db.transaction() threw exception TypeError: Not enough arguments. | 86 PASS trans = db.transaction() threw exception TypeError: Not enough arguments. |
| 77 | 87 |
| 78 Expecting exception from db.transaction(['x']) | 88 Expecting exception from db.transaction(['x']) |
| 79 PASS Exception was thrown. | 89 PASS Exception was thrown. |
| 80 PASS code is DOMException.NOT_FOUND_ERR | 90 PASS code is DOMException.NOT_FOUND_ERR |
| 81 PASS ename is 'NotFoundError' | 91 PASS ename is 'NotFoundError' |
| 92 Exception message: One of the specified object stores was not found. |
| 82 Expecting exception from db.transaction(['x']) | 93 Expecting exception from db.transaction(['x']) |
| 83 PASS Exception was thrown. | 94 PASS Exception was thrown. |
| 84 PASS code is DOMException.NOT_FOUND_ERR | 95 PASS code is DOMException.NOT_FOUND_ERR |
| 85 PASS ename is 'NotFoundError' | 96 PASS ename is 'NotFoundError' |
| 97 Exception message: One of the specified object stores was not found. |
| 86 Expecting exception from db.transaction(['a', 'x']) | 98 Expecting exception from db.transaction(['a', 'x']) |
| 87 PASS Exception was thrown. | 99 PASS Exception was thrown. |
| 88 PASS code is DOMException.NOT_FOUND_ERR | 100 PASS code is DOMException.NOT_FOUND_ERR |
| 89 PASS ename is 'NotFoundError' | 101 PASS ename is 'NotFoundError' |
| 102 Exception message: One of the specified object stores was not found. |
| 90 Expecting exception from db.transaction(['x', 'x']) | 103 Expecting exception from db.transaction(['x', 'x']) |
| 91 PASS Exception was thrown. | 104 PASS Exception was thrown. |
| 92 PASS code is DOMException.NOT_FOUND_ERR | 105 PASS code is DOMException.NOT_FOUND_ERR |
| 93 PASS ename is 'NotFoundError' | 106 PASS ename is 'NotFoundError' |
| 107 Exception message: One of the specified object stores was not found. |
| 94 Expecting exception from db.transaction(['a', 'x', 'b']) | 108 Expecting exception from db.transaction(['a', 'x', 'b']) |
| 95 PASS Exception was thrown. | 109 PASS Exception was thrown. |
| 96 PASS code is DOMException.NOT_FOUND_ERR | 110 PASS code is DOMException.NOT_FOUND_ERR |
| 97 PASS ename is 'NotFoundError' | 111 PASS ename is 'NotFoundError' |
| 112 Exception message: One of the specified object stores was not found. |
| 98 | 113 |
| 99 Exception thrown when no stores specified: | 114 Exception thrown when no stores specified: |
| 100 Expecting exception from db.transaction([]) | 115 Expecting exception from db.transaction([]) |
| 101 PASS Exception was thrown. | 116 PASS Exception was thrown. |
| 102 PASS code is DOMException.INVALID_ACCESS_ERR | 117 PASS code is DOMException.INVALID_ACCESS_ERR |
| 118 Exception message: The storeNames parameter was empty. |
| 103 | 119 |
| 104 {} coerces to a string - so no match, but not a type error: | 120 {} coerces to a string - so no match, but not a type error: |
| 105 Expecting exception from db.transaction({}) | 121 Expecting exception from db.transaction({}) |
| 106 PASS Exception was thrown. | 122 PASS Exception was thrown. |
| 107 PASS code is DOMException.NOT_FOUND_ERR | 123 PASS code is DOMException.NOT_FOUND_ERR |
| 108 PASS ename is 'NotFoundError' | 124 PASS ename is 'NotFoundError' |
| 125 Exception message: One of the specified object stores was not found. |
| 109 Expecting exception from db.transaction({mode:0}) | 126 Expecting exception from db.transaction({mode:0}) |
| 110 PASS Exception was thrown. | 127 PASS Exception was thrown. |
| 111 PASS code is DOMException.NOT_FOUND_ERR | 128 PASS code is DOMException.NOT_FOUND_ERR |
| 112 PASS ename is 'NotFoundError' | 129 PASS ename is 'NotFoundError' |
| 130 Exception message: One of the specified object stores was not found. |
| 113 | 131 |
| 114 Overriding the default string coercion makes these work: | 132 Overriding the default string coercion makes these work: |
| 115 db.transaction({toString:function(){return 'a';}}) | 133 db.transaction({toString:function(){return 'a';}}) |
| 116 db.transaction([{toString:function(){return 'a';}}]) | 134 db.transaction([{toString:function(){return 'a';}}]) |
| 117 ... but you still need to specify a real store: | 135 ... but you still need to specify a real store: |
| 118 Expecting exception from db.transaction([{toString:function(){return 'x';}}]) | 136 Expecting exception from db.transaction([{toString:function(){return 'x';}}]) |
| 119 PASS Exception was thrown. | 137 PASS Exception was thrown. |
| 120 PASS code is DOMException.NOT_FOUND_ERR | 138 PASS code is DOMException.NOT_FOUND_ERR |
| 121 PASS ename is 'NotFoundError' | 139 PASS ename is 'NotFoundError' |
| 140 Exception message: One of the specified object stores was not found. |
| 122 Expecting exception from db.transaction([{toString:function(){return 'x';}}]) | 141 Expecting exception from db.transaction([{toString:function(){return 'x';}}]) |
| 123 PASS Exception was thrown. | 142 PASS Exception was thrown. |
| 124 PASS code is DOMException.NOT_FOUND_ERR | 143 PASS code is DOMException.NOT_FOUND_ERR |
| 125 PASS ename is 'NotFoundError' | 144 PASS ename is 'NotFoundError' |
| 145 Exception message: One of the specified object stores was not found. |
| 126 | 146 |
| 127 trans = db.transaction(['store']) | 147 trans = db.transaction(['store']) |
| 128 PASS trans is non-null. | 148 PASS trans is non-null. |
| 129 store = trans.objectStore('store') | 149 store = trans.objectStore('store') |
| 130 PASS store is non-null. | 150 PASS store is non-null. |
| 131 store.get('some_key') | 151 store.get('some_key') |
| 132 transaction complete, ensuring methods fail | 152 transaction complete, ensuring methods fail |
| 133 PASS trans is non-null. | 153 PASS trans is non-null. |
| 134 PASS store is non-null. | 154 PASS store is non-null. |
| 135 Expecting exception from trans.objectStore('store') | 155 Expecting exception from trans.objectStore('store') |
| 136 PASS Exception was thrown. | 156 PASS Exception was thrown. |
| 137 PASS code is DOMException.INVALID_STATE_ERR | 157 PASS code is DOMException.INVALID_STATE_ERR |
| 138 PASS ename is 'InvalidStateError' | 158 PASS ename is 'InvalidStateError' |
| 159 Exception message: The transaction has finished. |
| 139 Expecting exception from store.index('index') | 160 Expecting exception from store.index('index') |
| 140 PASS Exception was thrown. | 161 PASS Exception was thrown. |
| 141 PASS code is DOMException.INVALID_STATE_ERR | 162 PASS code is DOMException.INVALID_STATE_ERR |
| 142 PASS ename is 'InvalidStateError' | 163 PASS ename is 'InvalidStateError' |
| 164 Exception message: The transaction has finished. |
| 143 PASS successfullyParsed is true | 165 PASS successfullyParsed is true |
| 144 | 166 |
| 145 TEST COMPLETE | 167 TEST COMPLETE |
| 146 | 168 |
| OLD | NEW |