summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/FileAPI/FileReaderSync.worker.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/FileAPI/FileReaderSync.worker.js
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/FileAPI/FileReaderSync.worker.js')
-rw-r--r--testing/web-platform/tests/FileAPI/FileReaderSync.worker.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/testing/web-platform/tests/FileAPI/FileReaderSync.worker.js b/testing/web-platform/tests/FileAPI/FileReaderSync.worker.js
new file mode 100644
index 0000000000..3d7a0222f3
--- /dev/null
+++ b/testing/web-platform/tests/FileAPI/FileReaderSync.worker.js
@@ -0,0 +1,56 @@
+importScripts("/resources/testharness.js");
+
+var blob, empty_blob, readerSync;
+setup(() => {
+ readerSync = new FileReaderSync();
+ blob = new Blob(["test"]);
+ empty_blob = new Blob();
+});
+
+test(() => {
+ assert_true(readerSync instanceof FileReaderSync);
+}, "Interface");
+
+test(() => {
+ var text = readerSync.readAsText(blob);
+ assert_equals(text, "test");
+}, "readAsText");
+
+test(() => {
+ var text = readerSync.readAsText(empty_blob);
+ assert_equals(text, "");
+}, "readAsText with empty blob");
+
+test(() => {
+ var data = readerSync.readAsDataURL(blob);
+ assert_equals(data.indexOf("data:"), 0);
+}, "readAsDataURL");
+
+test(() => {
+ var data = readerSync.readAsDataURL(empty_blob);
+ assert_equals(data.indexOf("data:"), 0);
+}, "readAsDataURL with empty blob");
+
+test(() => {
+ var data = readerSync.readAsBinaryString(blob);
+ assert_equals(data, "test");
+}, "readAsBinaryString");
+
+test(() => {
+ var data = readerSync.readAsBinaryString(empty_blob);
+ assert_equals(data, "");
+}, "readAsBinaryString with empty blob");
+
+test(() => {
+ var data = readerSync.readAsArrayBuffer(blob);
+ assert_true(data instanceof ArrayBuffer);
+ assert_equals(data.byteLength, "test".length);
+}, "readAsArrayBuffer");
+
+test(() => {
+ var data = readerSync.readAsArrayBuffer(empty_blob);
+ assert_true(data instanceof ArrayBuffer);
+ assert_equals(data.byteLength, 0);
+}, "readAsArrayBuffer with empty blob");
+
+done();