2 <script src=
"../../resources/js-test.js"></script>
3 <script src=
"resources/shared.js"></script>
6 description("Ensure IndexedDB's cursor prefetch cache requests are invalidated");
8 indexedDBTest(prepareDatabase
, onOpenSuccess
);
9 function prepareDatabase(evt
)
12 evalAndLog("db = event.target.result");
13 evalAndLog("store = db.createObjectStore('store')");
14 debug("Populate with even records...");
15 for (var i
= 0; i
< 10; i
+= 2)
19 function onOpenSuccess(evt
)
22 evalAndLog("db = event.target.result");
24 evalAndLog("tx = db.transaction('store', 'readwrite')");
25 evalAndLog("store = tx.objectStore('store')");
26 evalAndLog("request = store.openCursor()");
28 kPrefetchThreshold
= 3;
30 expected
= ["0", "2", "4", "6", "7", "8", "9"];
32 request
.onsuccess
= function cursorSuccess() {
34 cursor
= request
.result
;
39 expect
= expected
.shift();
40 shouldBe("cursor.key", expect
);
41 evalAndLog("cursor.continue()");
43 if (continueCount
=== kPrefetchThreshold
) {
44 debug("\nThat should have triggered a prefetch, injecting odd records...");
45 for (var i
= 1; i
< 10; i
+= 2)
50 tx
.oncomplete = function() {
51 shouldBe("continueCount", "7");