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