Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Unified Diff: LayoutTests/storage/indexeddb/prefetch-invalidation.html

Issue 101503003: Test for prefetch cache resetting on IDBObjectStore.clear() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/storage/indexeddb/prefetch-invalidation-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
« no previous file with comments | « no previous file | LayoutTests/storage/indexeddb/prefetch-invalidation-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698