2 <script src=
"../../resources/js-test.js"></script>
3 <script src=
"resources/shared.js"></script>
6 description("Ensure IndexedDB's write operations invalidate cursor prefetch caches");
8 indexedDBTest(prepareDatabase
, onOpenSuccess
);
9 function prepareDatabase(evt
)
12 evalAndLog("db = event.target.result");
13 evalAndLog("store = db.createObjectStore('store')");
16 function onOpenSuccess(evt
)
19 evalAndLog("db = event.target.result");
26 (function nextStep() {
27 var step
= steps
.shift();
29 doPrefetchInvalidationTest(step
, nextStep
);
37 function doPrefetchInvalidationTest(operation
, callback
)
40 debug("-------------------------------------------");
42 evalAndLog("store = db.transaction('store', 'readwrite').objectStore('store')");
43 debug("Populate the store with 200 records.");
44 for (var i
= 0; i
< 200; ++i
)
46 evalAndLog("cursorRequest = store.openCursor()");
47 continue100Times(operation
, callback
);
50 function continue100Times(operation
, callback
)
55 cursorRequest
.onsuccess = function() {
56 var cursor
= cursorRequest
.result
;
62 shouldBeNonNull("cursorRequest.result");
63 doOperationAndContinue(operation
, callback
);
67 function doOperationAndContinue(operation
, callback
)
71 evalAndLog("cursor = cursorRequest.result");
72 evalAndLog("cursor.continue()")
73 cursorRequest
.onsuccess
= function onContinueSuccess() {
75 shouldBeNull("cursorRequest.result");
80 function deleteRange()
82 return evalAndLog("store.delete(IDBKeyRange.bound(-Infinity, +Infinity))");
87 return evalAndLog("store.clear()");