mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
e1e683a5e9
--HG-- rename : content/base/public/nsIMozWebSocket.idl => content/base/public/nsIWebSocket.idl
83 lines
1.7 KiB
HTML
83 lines
1.7 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script type="text/javascript" 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 debug(msg) {
|
|
ok(1, msg);
|
|
}
|
|
|
|
function startsWith(target, prefix)
|
|
{
|
|
return target.indexOf(prefix) === 0;
|
|
}
|
|
|
|
function createArrayBufferContainingHelloWorld()
|
|
{
|
|
var hello = "Hello, world!";
|
|
var array = new Uint8Array(hello.length);
|
|
for (var i = 0; i < hello.length; ++i)
|
|
array[i] = hello.charCodeAt(i);
|
|
return array.buffer;
|
|
}
|
|
|
|
function createEmptyArrayBuffer()
|
|
{
|
|
return new ArrayBuffer(0);
|
|
}
|
|
|
|
function createArrayBufferContainingAllDistinctBytes()
|
|
{
|
|
var array = new Uint8Array(256);
|
|
for (var i = 0; i < 256; ++i)
|
|
array[i] = i;
|
|
return array.buffer;
|
|
}
|
|
|
|
var ws = new WebSocket("ws://mochi.test:8888/tests/content/base/test/websocket_hybi/file_check-binary-messages");
|
|
var closeEvent;
|
|
|
|
ws.onopen = function()
|
|
{
|
|
ok(true, "onopen reached");
|
|
ws.send(createArrayBufferContainingHelloWorld());
|
|
ws.send(createEmptyArrayBuffer());
|
|
ws.send(createArrayBufferContainingAllDistinctBytes());
|
|
};
|
|
|
|
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();
|
|
};
|
|
|
|
ws.onerror = function(event)
|
|
{
|
|
ok(false, "onerror should not have been called");
|
|
};
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|