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

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

Issue 105213009: IndexedDB: Tests for cursor prefetch edge cases (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 months 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-race-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/storage/indexeddb/prefetch-race.html
diff --git a/LayoutTests/storage/indexeddb/prefetch-race.html b/LayoutTests/storage/indexeddb/prefetch-race.html
new file mode 100644
index 0000000000000000000000000000000000000000..ec1b7afe5d49a73be044f8d4ba346caf83dc2c96
--- /dev/null
+++ b/LayoutTests/storage/indexeddb/prefetch-race.html
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<script src="../../resources/js-test.js"></script>
+<script src="resources/shared.js"></script>
+<script>
+
+description("Ensure IndexedDB's cursor prefetch cache requests are invalidated");
+
+indexedDBTest(prepareDatabase, onOpenSuccess);
+function prepareDatabase(evt)
+{
+ preamble(evt);
+ evalAndLog("db = event.target.result");
+ evalAndLog("store = db.createObjectStore('store')");
+ debug("Populate with even records...");
+ for (var i = 0; i < 10; i += 2)
+ store.put(i, i);
+}
+
+function onOpenSuccess(evt)
+{
+ preamble(evt);
+ evalAndLog("db = event.target.result");
+
+ evalAndLog("tx = db.transaction('store', 'readwrite')");
+ evalAndLog("store = tx.objectStore('store')");
+ evalAndLog("request = store.openCursor()");
+
+ kPrefetchThreshold = 3;
+
+ expected = ["0", "2", "4", "6", "7", "8", "9"];
+ continueCount = 0;
+ request.onsuccess = function cursorSuccess() {
+ preamble();
+ cursor = request.result;
+ if (!cursor)
+ return;
+ ++continueCount;
+
+ expect = expected.shift();
+ shouldBe("cursor.key", expect);
+ evalAndLog("cursor.continue()");
+
+ if (continueCount === kPrefetchThreshold) {
+ debug("\nThat should have triggered a prefetch, injecting odd records...");
+ for (var i = 1; i < 10; i += 2)
+ store.put(i, i);
+ }
+ };
+
+ tx.oncomplete = function() {
+ shouldBe("continueCount", "7");
+ finishJSTest();
+ };
+}
+</script>
« no previous file with comments | « no previous file | LayoutTests/storage/indexeddb/prefetch-race-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698