Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Errors
- This test gets skipped with pattern: http3 OR http2
- This test failed 1 times in the preceding 30 days. quicksearch this test
- Manifest: dom/websocket/tests/mochitest.toml
<!DOCTYPE HTML>
<html>
<!--
-->
<head>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="testWebSocket()">
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
var ws;
function forcegc()
{
SpecialPowers.forceGC();
SpecialPowers.gc();
setTimeout(function()
{
SpecialPowers.gc();
}, 0);
}
function testWebSocket () {
ws.onopen = function() {
ws.send("data");
}
ws.onclose = function() {
forcegc();
setTimeout(function() {
is(ws.readyState, 3, 'WebSocket is closed');
is(ws.bufferedAmount, 0, 'WebSocket.bufferedAmount should be empty.');
is(ws.binaryType, 'blob', 'WebSocket.binaryType is blob');
ws.binaryType = 'arraybuffer';
is(ws.binaryType, 'arraybuffer', 'WebSocket.binaryType is arraybuffer');
is(ws.url, 'ws://mochi.test:8888/tests/dom/websocket/tests/file_websocket_hello', 'WebSocket.url is correct');
ws.close();
ws.send('foobar');
SimpleTest.finish();
}, 1000);
}
ws.onerror = function() {
ok(false, "onerror called!");
SimpleTest.finish();
}
ws.onmessage = function(e) {
is(e.data, "Hello world!", "Wrong data");
ws.close();
}
}
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");
</script>
</pre>
<div>
</div>
</body>
</html>