fune/dom/websocket/tests/websocket_sharedWorker.js
Andrew Creskey d97f212992 Bug 1748005 - Getting Uncaught DOMException: The operation is insecure while opening Websocket using 'wss' protocol r=smaug
Use the 'IsSecure' field from windowContexts where possible to determine WebSockets mixed content behaviour.

Differential Revision: https://phabricator.services.mozilla.com/D153105
2022-08-26 12:23:36 +00:00

34 lines
708 B
JavaScript

onconnect = function(evt) {
var ws = new WebSocket(
"ws://mochi.test:8888/tests/dom/websocket/tests/file_websocket_hello"
);
ws.onopen = function(e) {
evt.ports[0].postMessage({
type: "status",
status: true,
msg: "OnOpen called",
});
ws.send("data");
};
ws.onclose = function(e) {};
ws.onerror = function(e) {
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" });
};
};