1 [Worker] Test IndexedDB cursor.advance().
3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
6 Starting worker: resources/cursor-advance.js
7 [Worker] dbname = "cursor-advance.js"
8 [Worker] indexedDB.deleteDatabase(dbname)
9 [Worker] indexedDB.open(dbname)
11 [Worker] prepareDatabase():
12 [Worker] objectStore = db.createObjectStore(objectStoreName);
13 [Worker] Now create the indexes.
14 [Worker] objectStore.createIndex(indexData[i].name, indexData[i].keyPath, indexData[i].options);
15 [Worker] objectStore.createIndex(indexData[i].name, indexData[i].keyPath, indexData[i].options);
16 [Worker] objectStore.createIndex(indexData[i].name, indexData[i].keyPath, indexData[i].options);
17 [Worker] trans = db.transaction(objectStoreName, 'readwrite')
18 [Worker] objectStore = trans.objectStore(objectStoreName)
19 [Worker] First, add all our data to the object store.
20 [Worker] request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
21 [Worker] request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
22 [Worker] request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
23 [Worker] request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
24 [Worker] request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
25 [Worker] request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
26 [Worker] request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
27 [Worker] request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
28 [Worker] request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
29 [Worker] request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
30 [Worker] request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
31 [Worker] request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
32 [Worker] request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
34 [Worker] trans = db.transaction(objectStoreName)
35 [Worker] store = trans.objectStore(objectStoreName)
36 [Worker] request = store.openCursor()
37 [Worker] cursor.advance(1)
38 PASS [Worker] expected is "{\"key\":\"237-23-7733\",\"value\":{\"name\":\"Ann\",\"height\":52,\"weight\":110},\"primaryKey\":\"237-23-7733\"}"
39 [Worker] testContinueThenAdvance()
40 [Worker] trans = db.transaction(objectStoreName)
41 [Worker] store = trans.objectStore(objectStoreName)
42 [Worker] request = store.openCursor()
43 [Worker] cursor.continue();
44 [Worker] cursor.continue();
45 [Worker] cursor.continue();
46 [Worker] cursor.advance(1)
47 PASS [Worker] expected is "{\"key\":\"237-23-7736\",\"value\":{\"name\":\"Joe\",\"height\":65,\"weight\":150},\"primaryKey\":\"237-23-7736\"}"
48 [Worker] testAdvanceMultiple()
49 [Worker] trans = db.transaction(objectStoreName)
50 [Worker] store = trans.objectStore(objectStoreName)
51 [Worker] request = store.openCursor()
52 [Worker] cursor.advance(3)
53 PASS [Worker] expected is "{\"key\":\"237-23-7735\",\"value\":{\"name\":\"Sue\",\"height\":58,\"weight\":130},\"primaryKey\":\"237-23-7735\"}"
54 [Worker] testAdvanceIndex()
55 [Worker] trans = db.transaction(objectStoreName)
56 [Worker] store = trans.objectStore(objectStoreName)
57 [Worker] request = store.openCursor()
58 [Worker] cursor.advance(3)
59 PASS [Worker] expected is "{\"key\":\"Jef\",\"value\":{\"name\":\"Jef\",\"height\":65,\"weight\":120},\"primaryKey\":\"237-23-7739\"}"
60 [Worker] testAdvanceIndexNoDupe()
61 [Worker] trans = db.transaction(objectStoreName)
62 [Worker] store = trans.objectStore(objectStoreName)
63 [Worker] request = store.openCursor(null, 'nextunique')
64 [Worker] cursor.advance(3)
65 PASS [Worker] expected is "{\"key\":130,\"value\":{\"name\":\"Sue\",\"height\":58,\"weight\":130},\"primaryKey\":\"237-23-7735\"}"
66 [Worker] testAdvanceIndexPrev()
67 [Worker] trans = db.transaction(objectStoreName)
68 [Worker] store = trans.objectStore(objectStoreName)
69 [Worker] request = store.openCursor(null, 'prev')
70 [Worker] cursor.advance(3)
71 PASS [Worker] expected is "{\"key\":150,\"value\":{\"name\":\"Joe\",\"height\":65,\"weight\":150},\"primaryKey\":\"237-23-7736\"}"
72 [Worker] testAdvanceIndexPrevNoDupe()
73 [Worker] trans = db.transaction(objectStoreName)
74 [Worker] store = trans.objectStore(objectStoreName)
75 [Worker] request = store.openCursor(null, 'prevunique')
76 [Worker] cursor.advance(3)
77 PASS [Worker] expected is "{\"key\":120,\"value\":{\"name\":\"Bob\",\"height\":60,\"weight\":120},\"primaryKey\":\"237-23-7732\"}"
78 [Worker] testAdvanceToEnd()
79 [Worker] trans = db.transaction(objectStoreName)
80 [Worker] store = trans.objectStore(objectStoreName)
81 [Worker] request = store.openCursor()
82 [Worker] cursor.advance(100)
83 PASS [Worker] expected is "null"
84 [Worker] testPrefetchInRange()
85 [Worker] trans = db.transaction(objectStoreName)
86 [Worker] objectStore = trans.objectStore(objectStoreName)
87 [Worker] request = objectStore.openCursor()
90 PASS [Worker] expected is "{\"key\":\"237-23-7732\",\"value\":{\"name\":\"Bob\",\"height\":60,\"weight\":120},\"primaryKey\":\"237-23-7732\"}"
91 [Worker] cursor.continue()
94 PASS [Worker] expected is "{\"key\":\"237-23-7733\",\"value\":{\"name\":\"Ann\",\"height\":52,\"weight\":110},\"primaryKey\":\"237-23-7733\"}"
95 [Worker] cursor.continue()
98 PASS [Worker] expected is "{\"key\":\"237-23-7734\",\"value\":{\"name\":\"Ron\",\"height\":73,\"weight\":180},\"primaryKey\":\"237-23-7734\"}"
99 [Worker] cursor.continue()
102 PASS [Worker] expected is "{\"key\":\"237-23-7735\",\"value\":{\"name\":\"Sue\",\"height\":58,\"weight\":130},\"primaryKey\":\"237-23-7735\"}"
103 [Worker] cursor.advance(2)
106 PASS [Worker] expected is "{\"key\":\"237-23-7737\",\"value\":{\"name\":\"Pat\",\"height\":65,\"weight\":100},\"primaryKey\":\"237-23-7737\"}"
107 [Worker] cursor.continue()
110 PASS [Worker] expected is "{\"key\":\"237-23-7738\",\"value\":{\"name\":\"Leo\",\"height\":65,\"weight\":180},\"primaryKey\":\"237-23-7738\"}"
111 [Worker] cursor.continue()
114 PASS [Worker] expected is "{\"key\":\"237-23-7739\",\"value\":{\"name\":\"Jef\",\"height\":65,\"weight\":120},\"primaryKey\":\"237-23-7739\"}"
115 [Worker] cursor.continue()
118 PASS [Worker] expected is "{\"key\":\"237-23-7740\",\"value\":{\"name\":\"Sam\",\"height\":71,\"weight\":110},\"primaryKey\":\"237-23-7740\"}"
119 [Worker] cursor.continue()
122 PASS [Worker] expected is "{\"key\":\"237-23-7741\",\"value\":{\"name\":\"Bug\",\"height\":63,\"weight\":100},\"primaryKey\":\"237-23-7741\"}"
123 [Worker] cursor.continue()
126 PASS [Worker] expected is "{\"key\":\"237-23-7742\",\"value\":{\"name\":\"Tub\",\"height\":69,\"weight\":180},\"primaryKey\":\"237-23-7742\"}"
127 [Worker] cursor.continue()
130 PASS [Worker] expected is "{\"key\":\"237-23-7743\",\"value\":{\"name\":\"Rug\",\"height\":77,\"weight\":120},\"primaryKey\":\"237-23-7743\"}"
131 [Worker] cursor.continue()
134 PASS [Worker] expected is "{\"key\":\"237-23-7744\",\"value\":{\"name\":\"Pug\",\"height\":66,\"weight\":110},\"primaryKey\":\"237-23-7744\"}"
135 [Worker] cursor.continue()
138 [Worker] testPrefetchOutOfRange()
139 [Worker] trans = db.transaction(objectStoreName)
140 [Worker] objectStore = trans.objectStore(objectStoreName)
141 [Worker] request = objectStore.openCursor()
144 PASS [Worker] expected is "{\"key\":\"237-23-7732\",\"value\":{\"name\":\"Bob\",\"height\":60,\"weight\":120},\"primaryKey\":\"237-23-7732\"}"
145 [Worker] cursor.continue()
148 PASS [Worker] expected is "{\"key\":\"237-23-7733\",\"value\":{\"name\":\"Ann\",\"height\":52,\"weight\":110},\"primaryKey\":\"237-23-7733\"}"
149 [Worker] cursor.continue()
152 PASS [Worker] expected is "{\"key\":\"237-23-7734\",\"value\":{\"name\":\"Ron\",\"height\":73,\"weight\":180},\"primaryKey\":\"237-23-7734\"}"
153 [Worker] cursor.continue()
156 PASS [Worker] expected is "{\"key\":\"237-23-7735\",\"value\":{\"name\":\"Sue\",\"height\":58,\"weight\":130},\"primaryKey\":\"237-23-7735\"}"
157 [Worker] cursor.advance(7)
160 PASS [Worker] expected is "{\"key\":\"237-23-7742\",\"value\":{\"name\":\"Tub\",\"height\":69,\"weight\":180},\"primaryKey\":\"237-23-7742\"}"
161 [Worker] cursor.continue()
164 PASS [Worker] expected is "{\"key\":\"237-23-7743\",\"value\":{\"name\":\"Rug\",\"height\":77,\"weight\":120},\"primaryKey\":\"237-23-7743\"}"
165 [Worker] cursor.continue()
168 PASS [Worker] expected is "{\"key\":\"237-23-7744\",\"value\":{\"name\":\"Pug\",\"height\":66,\"weight\":110},\"primaryKey\":\"237-23-7744\"}"
169 [Worker] cursor.continue()
172 [Worker] testBadAdvance()
173 [Worker] trans = db.transaction(objectStoreName, 'readwrite')
174 [Worker] objectStore = trans.objectStore(objectStoreName)
175 [Worker] request = objectStore.openCursor()
177 [Worker] advanceBadly():
178 [Worker] Expecting TypeError exception from cursor.advance(0)
179 PASS [Worker] Exception was thrown.
180 PASS [Worker] cursor.advance(0) threw TypeError: Failed to execute 'advance' on 'IDBCursor': A count argument with value 0 (zero) was supplied, must be greater than 0.
181 [Worker] Expecting TypeError exception from cursor.advance(-1)
182 PASS [Worker] Exception was thrown.
183 PASS [Worker] cursor.advance(-1) threw TypeError: Failed to execute 'advance' on 'IDBCursor': Value is outside the 'unsigned long' value range.
184 [Worker] Expecting TypeError exception from cursor.advance(0x100000000)
185 PASS [Worker] Exception was thrown.
186 PASS [Worker] cursor.advance(0x100000000) threw TypeError: Failed to execute 'advance' on 'IDBCursor': Value is outside the 'unsigned long' value range.
187 [Worker] Expecting TypeError exception from cursor.advance(0x20000000000000)
188 PASS [Worker] Exception was thrown.
189 PASS [Worker] cursor.advance(0x20000000000000) threw TypeError: Failed to execute 'advance' on 'IDBCursor': Value is outside the 'unsigned long' value range.
191 [Worker] testEdges():
192 [Worker] trans = db.transaction(objectStoreName, 'readonly')
193 [Worker] objectStore = trans.objectStore(objectStoreName)
194 [Worker] request = objectStore.openCursor()
196 [Worker] onSuccess():
197 [Worker] cursor = event.target.result
198 PASS [Worker] cursor is non-null.
199 [Worker] cursor.advance(0xffffffff)
201 [Worker] onSuccess():
202 [Worker] cursor = event.target.result
203 PASS [Worker] cursor is null
204 [Worker] testDelete()
205 [Worker] trans = db.transaction(objectStoreName, 'readwrite')
206 [Worker] objectStore = trans.objectStore(objectStoreName)
207 [Worker] request = objectStore.openCursor()
209 [Worker] deleteSecond():
210 PASS [Worker] expected is "{\"key\":\"237-23-7732\",\"value\":{\"name\":\"Bob\",\"height\":60,\"weight\":120},\"primaryKey\":\"237-23-7732\"}"
211 [Worker] cursor.advance(1)
213 [Worker] deleteSecond():
214 PASS [Worker] expected is "{\"key\":\"237-23-7733\",\"value\":{\"name\":\"Ann\",\"height\":52,\"weight\":110},\"primaryKey\":\"237-23-7733\"}"
215 [Worker] cursor.advance(1)
217 [Worker] deleteSecond():
218 PASS [Worker] expected is "{\"key\":\"237-23-7734\",\"value\":{\"name\":\"Ron\",\"height\":73,\"weight\":180},\"primaryKey\":\"237-23-7734\"}"
219 [Worker] cursor.delete()
221 [Worker] deleteSecond():
222 PASS [Worker] expected is "{\"key\":\"237-23-7738\",\"value\":{\"name\":\"Leo\",\"height\":65,\"weight\":180},\"primaryKey\":\"237-23-7738\"}"
223 [Worker] cursor.advance(1)
225 [Worker] deleteSecond():
226 PASS [Worker] expected is "{\"key\":\"237-23-7739\",\"value\":{\"name\":\"Jef\",\"height\":65,\"weight\":120},\"primaryKey\":\"237-23-7739\"}"
227 [Worker] cursor.advance(1)
229 [Worker] deleteSecond():
230 PASS [Worker] expected is "{\"key\":\"237-23-7740\",\"value\":{\"name\":\"Sam\",\"height\":71,\"weight\":110},\"primaryKey\":\"237-23-7740\"}"
231 [Worker] cursor.advance(1)
233 [Worker] deleteSecond():
234 PASS [Worker] expected is "{\"key\":\"237-23-7741\",\"value\":{\"name\":\"Bug\",\"height\":63,\"weight\":100},\"primaryKey\":\"237-23-7741\"}"
235 [Worker] cursor.advance(1)
237 [Worker] deleteSecond():
238 PASS [Worker] expected is "{\"key\":\"237-23-7742\",\"value\":{\"name\":\"Tub\",\"height\":69,\"weight\":180},\"primaryKey\":\"237-23-7742\"}"
239 [Worker] cursor.advance(1)
241 [Worker] deleteSecond():
242 PASS [Worker] expected is "{\"key\":\"237-23-7743\",\"value\":{\"name\":\"Rug\",\"height\":77,\"weight\":120},\"primaryKey\":\"237-23-7743\"}"
243 [Worker] cursor.advance(1)
245 [Worker] deleteSecond():
246 PASS [Worker] expected is "{\"key\":\"237-23-7744\",\"value\":{\"name\":\"Pug\",\"height\":66,\"weight\":110},\"primaryKey\":\"237-23-7744\"}"
247 [Worker] cursor.advance(1)
249 [Worker] deleteSecond():
250 PASS successfullyParsed is true