OLD | NEW |
---|---|
(Empty) | |
1 <!doctype html> | |
2 <meta charset="utf-8"> | |
3 <meta name="timeout" content="long"> | |
4 <title>IndexedDB: Interleaved iteration of multiple overlapping cursors</title> | |
dmurph
2017/03/29 23:35:20
How is this one different from the the one above?
jsbell
2017/04/04 22:59:41
+1
pwnall
2017/04/04 23:08:11
Done.
Thanks for the suggestion! I bet it will be
| |
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 = 8; | |
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 for (let cursorCount of [1, 10, 100, 1000]) { | |
31 promise_test(testCase => { | |
32 return createDatabase(testCase, (database, transaction) => { | |
33 const store = database.createObjectStore('cache', { keyPath: 'key' }); | |
34 }).then(database => { | |
35 return populateTestStore(testCase, database, 1).then(() => database); | |
36 }).then(database => { | |
37 database.close(); | |
38 }).then(() => { | |
39 return openDatabase(testCase); | |
40 }).then(database => { | |
41 const transaction = database.transaction('cache', 'readonly'); | |
42 transaction.onabort = () => { reject(transaction.error); }; | |
43 | |
44 const store = transaction.objectStore('cache'); | |
45 return interleaveCursors(testCase, store, cursorCount, itemCount).then( | |
46 () => database); | |
47 }).then(database => { | |
48 database.close(); | |
49 }); | |
50 }, `${cursorCount} cursors`); | |
51 } | |
52 | |
53 </script> | |
OLD | NEW |