<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../../js-test-resources/js-test-pre.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script type="text/javascript">
description("Checks whether SyntaxError is thrown when attempting to send too long reason.");

window.jsTestIsAsync = true;

var ws = new WebSocket("ws://localhost:8880/websocket/tests/hybi/echo");
var message;
var longReason = '';
for (var i = 0; i < 124; ++i)
    longReason += 'a';

ws.onopen = function()
{
    debug("Connected.");
    try {
        ws.close(1000, longReason);
        testFailed('SyntaxError should be thrown.');
    } catch (e) {
        if (e.name == 'SyntaxError')
            testPassed('SyntaxError was thrown.');
        else
            testFailed('Unexpected exception: ' + e);
    }
    ws.close();
};

ws.onmessage = function (event)
{
    message = event.data;
    testFailed("onmessage() was called. (message = \"" + message + "\")");
};

ws.onclose = function()
{
    finishJSTest();
};

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