Index: LayoutTests/storage/indexeddb/prefetch-invalidation.html |
diff --git a/LayoutTests/storage/indexeddb/prefetch-invalidation.html b/LayoutTests/storage/indexeddb/prefetch-invalidation.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ef2c84320037d9f0ce0cde7e87fe6fd5e3ddf041 |
--- /dev/null |
+++ b/LayoutTests/storage/indexeddb/prefetch-invalidation.html |
@@ -0,0 +1,90 @@ |
+<!DOCTYPE html> |
+<script src="../../resources/js-test.js"></script> |
+<script src="resources/shared.js"></script> |
+<script> |
+ |
+description("Ensure IndexedDB's write operations invalidate cursor prefetch caches"); |
+ |
+indexedDBTest(prepareDatabase, onOpenSuccess); |
+function prepareDatabase(evt) |
+{ |
+ preamble(evt); |
+ evalAndLog("db = event.target.result"); |
+ evalAndLog("store = db.createObjectStore('store')"); |
+} |
+ |
+function onOpenSuccess(evt) |
+{ |
+ preamble(evt); |
+ evalAndLog("db = event.target.result"); |
+ |
+ var steps = [ |
+ deleteRange, |
+ clearStore |
+ ]; |
+ |
+ (function nextStep() { |
+ var step = steps.shift(); |
+ if (step) { |
+ doPrefetchInvalidationTest(step, nextStep); |
+ } else { |
+ finishJSTest(); |
+ return; |
+ } |
+ }()); |
dgrogan
2013/12/19 21:53:06
What's the advantage to the (function {...}()) pat
jsbell
2013/12/19 22:04:25
Not quite it's not quite an IIFE (http://en.wikipe
dgrogan
2013/12/19 23:00:16
No, it's fine.
|
+} |
+ |
+function doPrefetchInvalidationTest(operation, callback) |
+{ |
+ debug(""); |
+ debug("-------------------------------------------"); |
+ preamble(); |
+ evalAndLog("store = db.transaction('store', 'readwrite').objectStore('store')"); |
+ debug("Populate the store with 200 records."); |
+ for (var i = 0; i < 200; ++i) |
+ store.put(i, i); |
+ evalAndLog("cursorRequest = store.openCursor()"); |
+ continue100Times(operation, callback); |
+} |
+ |
+function continue100Times(operation, callback) |
+{ |
+ preamble(); |
+ var count = 0; |
+ |
+ cursorRequest.onsuccess = function() { |
+ var cursor = cursorRequest.result; |
+ ++count; |
+ if (count < 100) { |
+ cursor.continue(); |
+ return; |
+ } |
+ shouldBeNonNull("cursorRequest.result"); |
+ doOperationAndContinue(operation, callback); |
+ } |
+} |
+ |
+function doOperationAndContinue(operation, callback) |
+{ |
+ preamble(); |
+ operation(); |
+ evalAndLog("cursor = cursorRequest.result"); |
+ evalAndLog("cursor.continue()") |
+ cursorRequest.onsuccess = function onContinueSuccess() { |
+ preamble(); |
+ shouldBeNull("cursorRequest.result"); |
+ callback(); |
+ }; |
+} |
+ |
+function deleteRange() |
+{ |
+ return evalAndLog("store.delete(IDBKeyRange.bound(-Infinity, +Infinity))"); |
+} |
+ |
+function clearStore() |
+{ |
+ return evalAndLog("store.clear()"); |
+} |
+ |
+</script> |