1
0
Fork 0
firefox/dom/websocket/tests/websocket_sharedWorker.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

35 lines
738 B
JavaScript

/* global onconnect:true */
onconnect = function (evt) {
var ws = new WebSocket(
"ws://mochi.test:8888/tests/dom/websocket/tests/file_websocket_hello"
);
ws.onopen = function () {
evt.ports[0].postMessage({
type: "status",
status: true,
msg: "OnOpen called",
});
ws.send("data");
};
ws.onclose = function () {};
ws.onerror = function () {
evt.ports[0].postMessage({
type: "status",
status: false,
msg: "onerror called!",
});
};
ws.onmessage = function (e) {
evt.ports[0].postMessage({
type: "status",
status: e.data == "Hello world!",
msg: "Wrong data",
});
ws.close();
evt.ports[0].postMessage({ type: "finish" });
};
};