<!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("Test whether WebSocket correctly responds to a ping message sent from the server.");

window.jsTestIsAsync = true;

var url = "ws://localhost:8880/websocket/tests/hybi/pong";
var ws = new WebSocket(url);
var closeEvent;
var message;

ws.onopen = function()
{
    debug("onopen() was called.");
};

ws.onmessage = function(event)
{
    message = event.data;
    debug("onmessage() was called. (message = \"" + message + "\")");
    shouldBeEqualToString("message", "PASS");
};

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

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