OLD | NEW |
1 Test the basics of IndexedDB's IDBObjectStore. | 1 Test the basics of IndexedDB's IDBObjectStore. |
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 = "objectstore-basics.html" | 8 dbname = "objectstore-basics.html" |
9 indexedDB.deleteDatabase(dbname) | 9 indexedDB.deleteDatabase(dbname) |
10 indexedDB.open(dbname) | 10 indexedDB.open(dbname) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 PASS store.autoIncrement is false | 44 PASS store.autoIncrement is false |
45 PASS storeNames.contains('storeName') is true | 45 PASS storeNames.contains('storeName') is true |
46 PASS storeNames.length is 1 | 46 PASS storeNames.length is 1 |
47 PASS db.createObjectStore('storeWithKeyPath', {keyPath: 'path'}).keyPath is "pat
h" | 47 PASS db.createObjectStore('storeWithKeyPath', {keyPath: 'path'}).keyPath is "pat
h" |
48 PASS db.createObjectStore('storeWithKeyGenerator', {autoIncrement: true}).autoIn
crement is true | 48 PASS db.createObjectStore('storeWithKeyGenerator', {autoIncrement: true}).autoIn
crement is true |
49 Ask for an index that doesn't exist: | 49 Ask for an index that doesn't exist: |
50 Expecting exception from store.index('asdf') | 50 Expecting exception from store.index('asdf') |
51 PASS Exception was thrown. | 51 PASS Exception was thrown. |
52 PASS code is DOMException.NOT_FOUND_ERR | 52 PASS code is DOMException.NOT_FOUND_ERR |
53 PASS ename is 'NotFoundError' | 53 PASS ename is 'NotFoundError' |
54 Exception message: The specified index was not found. | 54 Exception message: Failed to execute 'index' on 'IDBObjectStore': The specified
index was not found. |
55 createIndex(): | 55 createIndex(): |
56 index = store.createIndex('indexName', 'x', {unique: true}) | 56 index = store.createIndex('indexName', 'x', {unique: true}) |
57 PASS index is non-null. | 57 PASS index is non-null. |
58 PASS store.indexNames.contains('indexName') is true | 58 PASS store.indexNames.contains('indexName') is true |
59 index = store.index('indexName') | 59 index = store.index('indexName') |
60 PASS index is non-null. | 60 PASS index is non-null. |
61 Ask for an index that doesn't exist: | 61 Ask for an index that doesn't exist: |
62 Expecting exception from store.index('asdf') | 62 Expecting exception from store.index('asdf') |
63 PASS Exception was thrown. | 63 PASS Exception was thrown. |
64 PASS code is DOMException.NOT_FOUND_ERR | 64 PASS code is DOMException.NOT_FOUND_ERR |
65 PASS ename is 'NotFoundError' | 65 PASS ename is 'NotFoundError' |
66 Exception message: The specified index was not found. | 66 Exception message: Failed to execute 'index' on 'IDBObjectStore': The specified
index was not found. |
67 indexedDB.open(dbname, 2) | 67 indexedDB.open(dbname, 2) |
68 db.close() | 68 db.close() |
69 PASS db.version is 2 | 69 PASS db.version is 2 |
70 setVersionTrans = event.target.transaction | 70 setVersionTrans = event.target.transaction |
71 PASS setVersionTrans is non-null. | 71 PASS setVersionTrans is non-null. |
72 store = setVersionTrans.objectStore('storeName') | 72 store = setVersionTrans.objectStore('storeName') |
73 index = store.createIndex('indexFail', 'x') | 73 index = store.createIndex('indexFail', 'x') |
74 PASS db.version is 1 | 74 PASS db.version is 1 |
75 PASS store.transaction is setVersionTrans | 75 PASS store.transaction is setVersionTrans |
76 PASS store.indexNames is ['indexName'] | 76 PASS store.indexNames is ['indexName'] |
(...skipping 29 matching lines...) Expand all Loading... |
106 addAgainFailure(): | 106 addAgainFailure(): |
107 PASS event.target.error.name is 'ConstraintError' | 107 PASS event.target.error.name is 'ConstraintError' |
108 event.preventDefault() | 108 event.preventDefault() |
109 db.transaction(['storeName'], 'readwrite') | 109 db.transaction(['storeName'], 'readwrite') |
110 store = transaction.objectStore('storeName') | 110 store = transaction.objectStore('storeName') |
111 store.add({x: 'somevalue'}, 'somekey') | 111 store.add({x: 'somevalue'}, 'somekey') |
112 Expecting exception from store.add({x: 'othervalue'}, null) | 112 Expecting exception from store.add({x: 'othervalue'}, null) |
113 PASS Exception was thrown. | 113 PASS Exception was thrown. |
114 PASS code is 0 | 114 PASS code is 0 |
115 PASS ename is 'DataError' | 115 PASS ename is 'DataError' |
116 Exception message: The parameter is not a valid key. | 116 Exception message: Failed to execute 'add' on 'IDBObjectStore': The parameter is
not a valid key. |
117 db.transaction(['storeName'], 'readwrite') | 117 db.transaction(['storeName'], 'readwrite') |
118 store = transaction.objectStore('storeName') | 118 store = transaction.objectStore('storeName') |
119 Ensure invalid key pointed at by index keyPath is ignored | 119 Ensure invalid key pointed at by index keyPath is ignored |
120 store.add({x: null}, 'validkey') | 120 store.add({x: null}, 'validkey') |
121 db.transaction(['storeName'], 'readwrite') | 121 db.transaction(['storeName'], 'readwrite') |
122 store = transaction.objectStore('storeName') | 122 store = transaction.objectStore('storeName') |
123 store.get('key') | 123 store.get('key') |
124 getSuccess(): | 124 getSuccess(): |
125 PASS event.target.result.y is "value" | 125 PASS event.target.result.y is "value" |
126 store = event.target.source | 126 store = event.target.source |
127 store.get(testDate) | 127 store.get(testDate) |
128 getSuccessDateKey(): | 128 getSuccessDateKey(): |
129 PASS event.target.result.x is "foo" | 129 PASS event.target.result.x is "foo" |
130 store.delete('key') | 130 store.delete('key') |
131 removeSuccess(): | 131 removeSuccess(): |
132 PASS event.target.result is undefined | 132 PASS event.target.result is undefined |
133 store.delete('key') | 133 store.delete('key') |
134 removeSuccessButNotThere(): | 134 removeSuccessButNotThere(): |
135 PASS event.target.result is undefined | 135 PASS event.target.result is undefined |
136 store = event.target.source | 136 store = event.target.source |
137 Passing an invalid key into store.get(). | 137 Passing an invalid key into store.get(). |
138 Expecting exception from store.get({}) | 138 Expecting exception from store.get({}) |
139 PASS Exception was thrown. | 139 PASS Exception was thrown. |
140 PASS code is 0 | 140 PASS code is 0 |
141 PASS ename is 'DataError' | 141 PASS ename is 'DataError' |
142 Exception message: The parameter is not a valid key. | 142 Exception message: Failed to execute 'get' on 'IDBObjectStore': The parameter is
not a valid key. |
143 Passing an invalid key into store.delete(). | 143 Passing an invalid key into store.delete(). |
144 Expecting exception from store.delete({}) | 144 Expecting exception from store.delete({}) |
145 PASS Exception was thrown. | 145 PASS Exception was thrown. |
146 PASS code is 0 | 146 PASS code is 0 |
147 PASS ename is 'DataError' | 147 PASS ename is 'DataError' |
148 Exception message: The parameter is not a valid key. | 148 Exception message: Failed to execute 'delete' on 'IDBObjectStore': The parameter
is not a valid key. |
149 Passing an invalid key into store.add(). | 149 Passing an invalid key into store.add(). |
150 Expecting exception from store.add(null, {}) | 150 Expecting exception from store.add(null, {}) |
151 PASS Exception was thrown. | 151 PASS Exception was thrown. |
152 PASS code is 0 | 152 PASS code is 0 |
153 PASS ename is 'DataError' | 153 PASS ename is 'DataError' |
154 Exception message: The parameter is not a valid key. | 154 Exception message: Failed to execute 'add' on 'IDBObjectStore': The parameter is
not a valid key. |
155 Passing an invalid key into store.put(). | 155 Passing an invalid key into store.put(). |
156 Expecting exception from store.put(null, {}) | 156 Expecting exception from store.put(null, {}) |
157 PASS Exception was thrown. | 157 PASS Exception was thrown. |
158 PASS code is 0 | 158 PASS code is 0 |
159 PASS ename is 'DataError' | 159 PASS ename is 'DataError' |
160 Exception message: The parameter is not a valid key. | 160 Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is
not a valid key. |
161 | 161 |
162 testPreConditions(): | 162 testPreConditions(): |
163 indexedDB.open(dbname, 3) | 163 indexedDB.open(dbname, 3) |
164 | 164 |
165 upgradeNeeded(): | 165 upgradeNeeded(): |
166 storeWithInLineKeys = db.createObjectStore('storeWithInLineKeys', {keyPath: 'key
'}) | 166 storeWithInLineKeys = db.createObjectStore('storeWithInLineKeys', {keyPath: 'key
'}) |
167 storeWithOutOfLineKeys = db.createObjectStore('storeWithOutIOfLineKeys') | 167 storeWithOutOfLineKeys = db.createObjectStore('storeWithOutIOfLineKeys') |
168 storeWithIndex = db.createObjectStore('storeWithIndex') | 168 storeWithIndex = db.createObjectStore('storeWithIndex') |
169 index = storeWithIndex.createIndex('indexName', 'indexKey') | 169 index = storeWithIndex.createIndex('indexName', 'indexKey') |
170 | 170 |
171 IDBObjectStore.put() | 171 IDBObjectStore.put() |
172 The object store uses in-line keys and the key parameter was provided. | 172 The object store uses in-line keys and the key parameter was provided. |
173 Expecting exception from storeWithInLineKeys.put({key: 1}, 'key') | 173 Expecting exception from storeWithInLineKeys.put({key: 1}, 'key') |
174 PASS Exception was thrown. | 174 PASS Exception was thrown. |
175 PASS code is 0 | 175 PASS code is 0 |
176 PASS ename is 'DataError' | 176 PASS ename is 'DataError' |
177 Exception message: The object store uses in-line keys and the key parameter was
provided. | 177 Exception message: Failed to execute 'put' on 'IDBObjectStore': The object store
uses in-line keys and the key parameter was provided. |
178 The object store uses out-of-line keys and has no key generator and the key para
meter was not provided. | 178 The object store uses out-of-line keys and has no key generator and the key para
meter was not provided. |
179 Expecting exception from storeWithOutOfLineKeys.put({}) | 179 Expecting exception from storeWithOutOfLineKeys.put({}) |
180 PASS Exception was thrown. | 180 PASS Exception was thrown. |
181 PASS code is 0 | 181 PASS code is 0 |
182 PASS ename is 'DataError' | 182 PASS ename is 'DataError' |
183 Exception message: The object store uses out-of-line keys and has no key generat
or and the key parameter was not provided. | 183 Exception message: Failed to execute 'put' on 'IDBObjectStore': The object store
uses out-of-line keys and has no key generator and the key parameter was not pr
ovided. |
184 The object store uses in-line keys and the result of evaluating the object store
's key path yields a value and that value is not a valid key. | 184 The object store uses in-line keys and the result of evaluating the object store
's key path yields a value and that value is not a valid key. |
185 Expecting exception from storeWithInLineKeys.put({key: null}) | 185 Expecting exception from storeWithInLineKeys.put({key: null}) |
186 PASS Exception was thrown. | 186 PASS Exception was thrown. |
187 PASS code is 0 | 187 PASS code is 0 |
188 PASS ename is 'DataError' | 188 PASS ename is 'DataError' |
189 Exception message: Evaluating the object store's key path yielded a value that i
s not a valid key. | 189 Exception message: Failed to execute 'put' on 'IDBObjectStore': Evaluating the o
bject store's key path yielded a value that is not a valid key. |
190 The object store uses in-line keys but no key generator and the result of evalua
ting the object store's key path does not yield a value. | 190 The object store uses in-line keys but no key generator and the result of evalua
ting the object store's key path does not yield a value. |
191 Expecting exception from storeWithInLineKeys.put({}) | 191 Expecting exception from storeWithInLineKeys.put({}) |
192 PASS Exception was thrown. | 192 PASS Exception was thrown. |
193 PASS code is 0 | 193 PASS code is 0 |
194 PASS ename is 'DataError' | 194 PASS ename is 'DataError' |
195 Exception message: Evaluating the object store's key path did not yield a value. | 195 Exception message: Failed to execute 'put' on 'IDBObjectStore': Evaluating the o
bject store's key path did not yield a value. |
196 The key parameter was provided but does not contain a valid key. | 196 The key parameter was provided but does not contain a valid key. |
197 Expecting exception from storeWithOutOfLineKeys.put({}, null) | 197 Expecting exception from storeWithOutOfLineKeys.put({}, null) |
198 PASS Exception was thrown. | 198 PASS Exception was thrown. |
199 PASS code is 0 | 199 PASS code is 0 |
200 PASS ename is 'DataError' | 200 PASS ename is 'DataError' |
201 Exception message: The parameter is not a valid key. | 201 Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is
not a valid key. |
202 | 202 |
203 IDBObjectStore.add() | 203 IDBObjectStore.add() |
204 The object store uses in-line keys and the key parameter was provided. | 204 The object store uses in-line keys and the key parameter was provided. |
205 Expecting exception from storeWithInLineKeys.add({key: 1}, 'key') | 205 Expecting exception from storeWithInLineKeys.add({key: 1}, 'key') |
206 PASS Exception was thrown. | 206 PASS Exception was thrown. |
207 PASS code is 0 | 207 PASS code is 0 |
208 PASS ename is 'DataError' | 208 PASS ename is 'DataError' |
209 Exception message: The object store uses in-line keys and the key parameter was
provided. | 209 Exception message: Failed to execute 'add' on 'IDBObjectStore': The object store
uses in-line keys and the key parameter was provided. |
210 The object store uses out-of-line keys and has no key generator and the key para
meter was not provided. | 210 The object store uses out-of-line keys and has no key generator and the key para
meter was not provided. |
211 Expecting exception from storeWithOutOfLineKeys.add({}) | 211 Expecting exception from storeWithOutOfLineKeys.add({}) |
212 PASS Exception was thrown. | 212 PASS Exception was thrown. |
213 PASS code is 0 | 213 PASS code is 0 |
214 PASS ename is 'DataError' | 214 PASS ename is 'DataError' |
215 Exception message: The object store uses out-of-line keys and has no key generat
or and the key parameter was not provided. | 215 Exception message: Failed to execute 'add' on 'IDBObjectStore': The object store
uses out-of-line keys and has no key generator and the key parameter was not pr
ovided. |
216 The object store uses in-line keys and the result of evaluating the object store
's key path yields a value and that value is not a valid key. | 216 The object store uses in-line keys and the result of evaluating the object store
's key path yields a value and that value is not a valid key. |
217 Expecting exception from storeWithInLineKeys.add({key: null}) | 217 Expecting exception from storeWithInLineKeys.add({key: null}) |
218 PASS Exception was thrown. | 218 PASS Exception was thrown. |
219 PASS code is 0 | 219 PASS code is 0 |
220 PASS ename is 'DataError' | 220 PASS ename is 'DataError' |
221 Exception message: Evaluating the object store's key path yielded a value that i
s not a valid key. | 221 Exception message: Failed to execute 'add' on 'IDBObjectStore': Evaluating the o
bject store's key path yielded a value that is not a valid key. |
222 The object store uses in-line keys but no key generator and the result of evalua
ting the object store's key path does not yield a value. | 222 The object store uses in-line keys but no key generator and the result of evalua
ting the object store's key path does not yield a value. |
223 Expecting exception from storeWithInLineKeys.add({}) | 223 Expecting exception from storeWithInLineKeys.add({}) |
224 PASS Exception was thrown. | 224 PASS Exception was thrown. |
225 PASS code is 0 | 225 PASS code is 0 |
226 PASS ename is 'DataError' | 226 PASS ename is 'DataError' |
227 Exception message: Evaluating the object store's key path did not yield a value. | 227 Exception message: Failed to execute 'add' on 'IDBObjectStore': Evaluating the o
bject store's key path did not yield a value. |
228 The key parameter was provided but does not contain a valid key. | 228 The key parameter was provided but does not contain a valid key. |
229 Expecting exception from storeWithOutOfLineKeys.add({}, null) | 229 Expecting exception from storeWithOutOfLineKeys.add({}, null) |
230 PASS Exception was thrown. | 230 PASS Exception was thrown. |
231 PASS code is 0 | 231 PASS code is 0 |
232 PASS ename is 'DataError' | 232 PASS ename is 'DataError' |
233 Exception message: The parameter is not a valid key. | 233 Exception message: Failed to execute 'add' on 'IDBObjectStore': The parameter is
not a valid key. |
234 PASS successfullyParsed is true | 234 PASS successfullyParsed is true |
235 | 235 |
236 TEST COMPLETE | 236 TEST COMPLETE |
237 | 237 |
OLD | NEW |