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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!doctype html>
2 <meta charset="utf-8">
3 <meta name="timeout" content="long">
4 <title>IndexedDB: Parallel iteration of multiple overlapping cursors</title>
5 <link rel="author" href="pwnall@chromium.org" title="Victor Costan">
6 <script src="/resources/testharness.js"></script>
7 <script src="/resources/testharnessreport.js"></script>
8 <script src="support-promises.js"></script>
9 <script src="interleaved-cursors-support.js"></script>
10 <script>
11 'use strict';
12
13 // Number of objects that each iterator goes over.
14 const itemCount = 2;
15
16 // Ratio of small objects to large objects.
17 const largeObjectRatio = 5;
18
19 function objectKey(cursorIndex, itemIndex) {
20 const itemString = itemIndex.toString().padStart(5, '0');
21 return `key-${itemString}`;
22 }
23
24 function objectValue(cursorIndex, itemIndex) {
25 if ((itemCount + itemIndex) % largeObjectRatio === 0)
26 return largeObjectValue(0, itemIndex);
27 return ['small', itemIndex];
28 }
29
30 // Reads all the cursors in parallel. Returns a promise that resolves when the
31 // reading is done.
32 function parallelCursors(testCase, store, cursorCount) {
33 const promises = [];
34 const cursors = new CursorBank(testCase, store, cursorCount);
35
36 for (let cursorIndex = 0; cursorIndex < cursorCount; ++cursorIndex) {
37 const promise = new Promise((resolve, reject) => {
38 let callback = resolve;
39 for (let itemIndex = itemCount; itemIndex >= 1; --itemIndex) {
40 callback = cursors.continueCursor.bind(
41 cursors, cursorIndex, itemIndex, callback);
42 }
43 cursors.openCursor(cursorIndex, callback);
44 });
45 promises.push(promise);
46 }
47 return Promise.all(promises);
48 }
49
50 for (let cursorCount of [1, 10, 100, 1000, 10000]) {
51 promise_test(testCase => {
52 return createDatabase(testCase, (database, transaction) => {
53 const store = database.createObjectStore('cache', { keyPath: 'key' });
54 }).then(database => {
55 return populateTestStore(testCase, database, 1).then(() => database);
56 }).then(database => {
57 database.close();
58 }).then(() => {
59 return openDatabase(testCase);
60 }).then(database => {
61 const transaction = database.transaction('cache', 'readonly');
62 transaction.onabort = () => { reject(transaction.error); };
63
64 const store = transaction.objectStore('cache');
65 return parallelCursors(testCase, store, cursorCount, itemCount).then(
66 () => database);
67 }).then(database => {
68 database.close();
69 });
70 }, `${cursorCount} cursors`);
71 }
72
73 </script>
OLDNEW
« 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