summaryrefslogtreecommitdiffstats
path: root/dom/websocket/tests/websocket_hybi/test_send-blob.html
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 /dom/websocket/tests/websocket_hybi/test_send-blob.html
parentInitial commit. (diff)
downloadfirefox-esr-upstream/115.8.0esr.tar.xz
firefox-esr-upstream/115.8.0esr.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/websocket/tests/websocket_hybi/test_send-blob.html')
-rw-r--r--dom/websocket/tests/websocket_hybi/test_send-blob.html72
1 files changed, 72 insertions, 0 deletions
diff --git a/dom/websocket/tests/websocket_hybi/test_send-blob.html b/dom/websocket/tests/websocket_hybi/test_send-blob.html
new file mode 100644
index 0000000000..6af1e2df03
--- /dev/null
+++ b/dom/websocket/tests/websocket_hybi/test_send-blob.html
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+
+<p id="display">
+</p>
+<div id="content" style="display: none">
+</div>
+<pre id="test">
+
+<script class="testbody" type="text/javascript">
+
+function startsWith(target, prefix)
+{
+ return target.indexOf(prefix) === 0;
+}
+
+function distinctBytes()
+{
+ var array = new Array();
+ for (var i = 0; i < 256; ++i)
+ array[i] = i;
+ // Concatenates chars into a single binary string
+ return String.fromCharCode.apply(null, array);
+}
+
+var filesToCreate = [
+ {name: "hellofile", data: "Hello, world!"},
+ {name: "emptyfile"},
+ {name: "allchars", data: distinctBytes()},
+];
+
+SpecialPowers.createFiles(filesToCreate, function (files) {
+ var ws = new WebSocket("ws://mochi.test:8888/tests/dom/websocket/tests/websocket_hybi/file_check-binary-messages");
+ var closeEvent;
+
+ ws.onopen = function()
+ {
+ ws.send(files[0]);
+ ws.send(files[1]);
+ ws.send(files[2]);
+ };
+
+ ws.onmessage = function(event)
+ {
+ var message = event.data;
+ if (startsWith(message, "PASS"))
+ ok(true, message);
+ else
+ ok(false, message);
+ };
+
+ ws.onclose = function(event)
+ {
+ ok(event.wasClean, "should have closed cleanly");
+ SimpleTest.finish();
+ };
+},
+function (msg) {
+ ok(false, "Failed to create files: " + msg);
+ SimpleTest.finish();
+});
+
+SimpleTest.waitForExplicitFinish();
+
+</script>
+</body>
+</html>