<script src="../../../../../js-test-resources/js-test-pre.js"></script>
<script>
window.jsTestIsAsync = true;

var ws;

function onSocketOpened() {
    console.log("WebSocket connection opened.");
    finishJSTest();
}

function onSocketError() {
    console.log("WebSocket connection failed.");
    ws.close();
    finishJSTest();
}

function onSocketClosed() {
    console.log("WebSocket closed.");
    finishJSTest();
}

try {
    ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/echo");
    ws.onopen = onSocketOpened;
    ws.onerror = onSocketError;
    ws.onclose = onSocketClosed;
} catch (e) {
    console.log("Test failed: exception thrown");
    finishJSTest();
}
</script>
<script src="../../../../js-test-resources/js-test-post.js"></script>
