summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fs/FileSystemSyncAccessHandle-flush.https.tentative.worker.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/fs/FileSystemSyncAccessHandle-flush.https.tentative.worker.js
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/fs/FileSystemSyncAccessHandle-flush.https.tentative.worker.js')
-rw-r--r--testing/web-platform/tests/fs/FileSystemSyncAccessHandle-flush.https.tentative.worker.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/testing/web-platform/tests/fs/FileSystemSyncAccessHandle-flush.https.tentative.worker.js b/testing/web-platform/tests/fs/FileSystemSyncAccessHandle-flush.https.tentative.worker.js
new file mode 100644
index 0000000000..96953a88f2
--- /dev/null
+++ b/testing/web-platform/tests/fs/FileSystemSyncAccessHandle-flush.https.tentative.worker.js
@@ -0,0 +1,29 @@
+importScripts('/resources/testharness.js');
+importScripts('resources/sync-access-handle-test.js');
+
+'use strict';
+
+sync_access_handle_test((t, handle) => {
+ handle.flush();
+}, 'Test flush on an empty file.');
+
+sync_access_handle_test((t, handle) => {
+ if (!('TextEncoder' in self)) {
+ return;
+ }
+ const encoder = new TextEncoder();
+ const decoder = new TextDecoder();
+
+ const text = 'Hello Storage Foundation';
+ const writeBuffer = new TextEncoder().encode(text);
+ handle.write(writeBuffer, {at: 0});
+ handle.flush();
+ let readBuffer = new Uint8Array(text.length);
+ handle.read(readBuffer, {at: 0});
+ assert_equals(
+ text, new TextDecoder().decode(readBuffer),
+ 'Check that the written bytes and the read bytes match');
+}, 'SyncAccessHandle.read returns bytes written by SyncAccessHandle.write' +
+ ' after SyncAccessHandle.flush');
+
+done();