<!DOCTYPE html>
<html>
<head>
<script src="../../../../js-test-resources/js-test-pre.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("WebSocket: Calling send() without arguments should raise SyntaxError.");

window.jsTestIsAsync = true;

var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/echo");

var closeEvent;
var receivedMessages = [];
var expectedMessages = ["Goodbye"];

ws.onopen = function()
{
    shouldThrow("ws.send()");
    ws.send("Goodbye");
};

ws.onmessage = function(event)
{
    receivedMessages.push(event.data);
};

ws.onclose = function(event)
{
    closeEvent = event;
    shouldBeTrue("closeEvent.wasClean");

    shouldEvaluateTo("receivedMessages.length", expectedMessages.length);
    for (var i = 0; i < expectedMessages.length; ++i)
        shouldBeEqualToString("receivedMessages[" + i + "]", expectedMessages[i]);
    finishJSTest();
};

</script>
<script src="../../../../js-test-resources/js-test-post.js"></script>
</body>
</html>
