forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test for IndexedDB crashing bug found by clusterfuzz.
BUG=705837 Review-Url: https://codereview.chromium.org/2779273004 Cr-Commit-Position: refs/heads/master@{#461495}
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<!doctype html> | ||
<meta charset="utf-8"> | ||
<meta name="timeout" content="long"> | ||
<title>IndexedDB: Parallel iteration of cursors in upgradeneeded</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> | ||
'use strict'; | ||
|
||
for (let cursorCount of [2, 10, 100, 1000, 10000]) { | ||
promise_test(testCase => { | ||
return createDatabase(testCase, (database, transaction) => { | ||
const store = database.createObjectStore('cache', { keyPath: 'key' }); | ||
store.put({ key: '42' }); | ||
|
||
const promises = []; | ||
|
||
for (let j = 0; j < 2; j += 1) { | ||
const promise = new Promise((resolve, reject) => { | ||
let request = null; | ||
for (let i = 0; i < cursorCount / 2; i += 1) { | ||
request = store.openCursor(); | ||
} | ||
|
||
let continued = false; | ||
request.onsuccess = testCase.step_func(() => { | ||
const cursor = request.result; | ||
|
||
if (!continued) { | ||
assert_equals(cursor.key, '42'); | ||
assert_equals(cursor.value.key, '42'); | ||
continued = true; | ||
cursor.continue(); | ||
} else { | ||
assert_equals(cursor, null); | ||
resolve(); | ||
} | ||
}); | ||
request.onerror = () => reject(request.error); | ||
}); | ||
promises.push(promise); | ||
} | ||
return Promise.all(promises); | ||
}).then(database => { | ||
database.close(); | ||
}); | ||
}, `${cursorCount} cursors`); | ||
} | ||
|
||
</script> |