<!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("Make sure event handler called serially.");

window.jsTestIsAsync = true;

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

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

ws.onmessage = function(messageEvent)
{
    debug("Enter onmessage: " + messageEvent.data);
    // alert() will suspend/resume WebSocket.
    alert("message handled." + messageEvent.data);
    debug("Leave onmessage: " + messageEvent.data);
};

ws.onclose = function()
{
    debug("Closed");
    finishJSTest();
};

debug("alert will suspend/resume WebSocket.");
alert("waiting for open");
debug("onopen should fire later.");
</script>
<script src="../../../../js-test-resources/js-test-post.js"></script>
</body>
</html>
