3f38599003f62f2cb9599f31ad21109c9dd5676d
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hixie76 / close-on-unload-reference-in-parent.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../../../js-test-resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <div id="description"></div>
8 <div id="console"></div>
9 <script type="text/javascript">
10 description("Test if Web Socket opened in iframe but referred in parent document is closed on unloading the frame.");
11
12 window.jsTestIsAsync = true;
13
14 var frameDiv;
15 var closedSocket;
16 document.childWebSocket = null;
17
18 var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hixie76/close-on-unload");
19 ws.onopen = function()
20 {
21     debug("PASS ws on master document is ready.");
22     frameDiv = document.createElement("iframe");
23     frameDiv.src = "resources/close-on-unload-iframe-reference-in-parent.html";
24     document.body.appendChild(frameDiv);
25     debug("PASS insert a iframe, where open ws called 'socket1'");
26 };
27 ws.onmessage = function(evt)
28 {
29     closedSocket = evt.data;
30     ws.close();
31 };
32 ws.onclose = function()
33 {
34     shouldBe("closedSocket", '"socket1"');
35     shouldBe("document.childWebSocket.readyState", "3");
36     finishJSTest();
37 };
38
39 document.iframeReady = function()
40 {
41     shouldBeNonNull("document.childWebSocket");
42     debug("PASS 'socket1' is sent to the server. unload the iframe. expect receiving 'socket1' on ws...");
43     document.body.removeChild(frameDiv);
44 };
45
46 </script>
47 <script src="../../../../js-test-resources/js-test-post.js"></script>
48 </body>
49 </html>