blob: 735fea365fb542c799ef013ce85df04ff6ce34b6 [file] [log] [blame]
<!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("Test if Web Socket is closed on unload and not crashed if garbage collected");
window.jsTestIsAsync = true;
var frameDiv;
var closedSocket;
var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/close-on-unload");
ws.onopen = function()
{
debug("PASS ws on master document is ready.");
frameDiv = document.createElement("iframe");
frameDiv.src = "resources/close-on-unload-iframe.html";
document.body.appendChild(frameDiv);
debug("PASS insert a iframe, where open ws called 'socket1'");
};
ws.onmessage = function(evt)
{
closedSocket = evt.data;
ws.close();
};
ws.onclose = function()
{
shouldBe("closedSocket", '"socket1"');
finishJSTest();
};
document.iframeReady = function()
{
debug("PASS 'socket1' is sent to the server. unload the iframe and force garbage collection. expect receiving 'socket1' on ws and no crash...");
document.body.removeChild(frameDiv);
gc();
};
</script>
<script src="../../../../js-test-resources/js-test-post.js"></script>
</body>
</html>