summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/IndexedDB/parallel-cursors-upgrade.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/IndexedDB/parallel-cursors-upgrade.html
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/IndexedDB/parallel-cursors-upgrade.html')
-rw-r--r--testing/web-platform/tests/IndexedDB/parallel-cursors-upgrade.html52
1 files changed, 52 insertions, 0 deletions
diff --git a/testing/web-platform/tests/IndexedDB/parallel-cursors-upgrade.html b/testing/web-platform/tests/IndexedDB/parallel-cursors-upgrade.html
new file mode 100644
index 0000000000..99ea65d9d6
--- /dev/null
+++ b/testing/web-platform/tests/IndexedDB/parallel-cursors-upgrade.html
@@ -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="resources/support-promises.js"></script>
+<script>
+'use strict';
+
+for (let cursorCount of [2, 20, 200, 2000]) {
+ 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>