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

Unified Diff: third_party/WebKit/LayoutTests/external/wpt/IndexedDB/parallel-overlapping-cursors.html

Issue 2781623008: More thorough overlapping cursor tests. (Closed)
Patch Set: Addressed feedback. Created 3 years, 8 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 | « third_party/WebKit/LayoutTests/external/wpt/IndexedDB/interleaved-overlapping-cursors.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/external/wpt/IndexedDB/parallel-overlapping-cursors.html
diff --git a/third_party/WebKit/LayoutTests/external/wpt/IndexedDB/parallel-overlapping-cursors.html b/third_party/WebKit/LayoutTests/external/wpt/IndexedDB/parallel-overlapping-cursors.html
new file mode 100644
index 0000000000000000000000000000000000000000..84674b65b66805795748f925732cbd23e17a6382
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/IndexedDB/parallel-overlapping-cursors.html
@@ -0,0 +1,73 @@
+<!doctype html>
+<meta charset="utf-8">
+<meta name="timeout" content="long">
+<title>IndexedDB: Parallel iteration of multiple overlapping cursors</title>
+<link rel="author" href="pwnall@chromium.org" title="Victor Costan">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="support-promises.js"></script>
+<script src="interleaved-cursors-support.js"></script>
+<script>
+'use strict';
+
+// Number of objects that each iterator goes over.
+const itemCount = 2;
+
+// Ratio of small objects to large objects.
+const largeObjectRatio = 5;
+
+function objectKey(cursorIndex, itemIndex) {
+ const itemString = itemIndex.toString().padStart(5, '0');
+ return `key-${itemString}`;
+}
+
+function objectValue(cursorIndex, itemIndex) {
+ if ((itemCount + itemIndex) % largeObjectRatio === 0)
+ return largeObjectValue(0, itemIndex);
+ return ['small', itemIndex];
+}
+
+// Reads all the cursors in parallel. Returns a promise that resolves when the
+// reading is done.
+function parallelCursors(testCase, store, cursorCount) {
+ const promises = [];
+ const cursors = new CursorBank(testCase, store, cursorCount);
+
+ for (let cursorIndex = 0; cursorIndex < cursorCount; ++cursorIndex) {
+ const promise = new Promise((resolve, reject) => {
+ let callback = resolve;
+ for (let itemIndex = itemCount; itemIndex >= 1; --itemIndex) {
+ callback = cursors.continueCursor.bind(
+ cursors, cursorIndex, itemIndex, callback);
+ }
+ cursors.openCursor(cursorIndex, callback);
+ });
+ promises.push(promise);
+ }
+ return Promise.all(promises);
+}
+
+for (let cursorCount of [1, 10, 100, 1000, 10000]) {
+ promise_test(testCase => {
+ return createDatabase(testCase, (database, transaction) => {
+ const store = database.createObjectStore('cache', { keyPath: 'key' });
+ }).then(database => {
+ return populateTestStore(testCase, database, 1).then(() => database);
+ }).then(database => {
+ database.close();
+ }).then(() => {
+ return openDatabase(testCase);
+ }).then(database => {
+ const transaction = database.transaction('cache', 'readonly');
+ transaction.onabort = () => { reject(transaction.error); };
+
+ const store = transaction.objectStore('cache');
+ return parallelCursors(testCase, store, cursorCount, itemCount).then(
+ () => database);
+ }).then(database => {
+ database.close();
+ });
+ }, `${cursorCount} cursors`);
+}
+
+</script>
« no previous file with comments | « third_party/WebKit/LayoutTests/external/wpt/IndexedDB/interleaved-overlapping-cursors.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698