summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/IndexedDB/blob-valid-before-commit.any.js
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/blob-valid-before-commit.any.js
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/blob-valid-before-commit.any.js')
-rw-r--r--testing/web-platform/tests/IndexedDB/blob-valid-before-commit.any.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/testing/web-platform/tests/IndexedDB/blob-valid-before-commit.any.js b/testing/web-platform/tests/IndexedDB/blob-valid-before-commit.any.js
new file mode 100644
index 0000000000..ad8b2a1be2
--- /dev/null
+++ b/testing/web-platform/tests/IndexedDB/blob-valid-before-commit.any.js
@@ -0,0 +1,41 @@
+// META: title=Blob Valid Before Commit
+// META: script=resources/support.js
+
+let key = "key";
+
+indexeddb_test(
+ function upgrade(t, db) {
+ db.createObjectStore('store');
+ },
+ function success(t, db) {
+ const blobAContent = "Blob A content";
+ const blobBContent = "Blob B content";
+ const blobA = new Blob([blobAContent], {"type" : "text/plain"});
+ const blobB = new Blob([blobBContent], {"type" : "text/plain"});
+ const value = { a0: blobA, a1: blobA, b0: blobB };
+
+ const tx = db.transaction('store', 'readwrite', {durability: 'relaxed'});
+ const store = tx.objectStore('store');
+
+ store.put(value, key);
+ const request = store.get(key);
+
+ request.onsuccess = t.step_func(function() {
+ const record = request.result;
+
+ const promise1 = record.a0.text().then(t.step_func(text => { assert_equals(text, blobAContent); },
+ t.unreached_func()));
+
+ const promise2 = record.a1.text().then(t.step_func(text => { assert_equals(text, blobAContent); },
+ t.unreached_func()));
+
+ const promise3 = record.b0.text().then(t.step_func(text => { assert_equals(text, blobBContent); },
+ t.unreached_func()));
+
+ Promise.all([promise1, promise2, promise3]).then(function() {
+ // The test passes if it successfully completes.
+ t.done();
+ });
+ });
+ },
+ "Blobs can be read back before their records are committed.");