chromium/third_party/blink/web_tests/http/tests/websocket/close-event.html

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="/js-test-resources/js-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script type="text/javascript">
description("Make sure WebSocket fires CloseEvent when closed.");

window.jsTestIsAsync = true;

var ws = new WebSocket("ws://127.0.0.1:8880/simple");

ws.onopen = function()
{
    debug("WebSocket is open");
};

ws.onmessage = function(messageEvent)
{
    debug("Received: '" + messageEvent.data + "'");
};

var closeEvent;
var closeEventType;
ws.onclose = function(event)
{
    debug("Closed");
    closeEvent = event;
    closeEventType = closeEvent.type;
    shouldBe("closeEventType", '"close"')
    shouldBeTrue("'wasClean' in closeEvent");
    shouldBeTrue("closeEvent.wasClean");
    shouldBeTrue("Object.getPrototypeOf(closeEvent) === CloseEvent.prototype");
    shouldBeTrue("Object.getPrototypeOf(closeEvent) !== Event.prototype");
    finishJSTest();
};

</script>
</body>
</html>