1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <script src=
"/js-test-resources/js-test.js"></script>
7 <div id=
"description"></div>
8 <div id=
"console"></div>
9 <script type=
"text/javascript">
10 description("Test that WebSocket opened in iframe is closed when the iframe is unloaded even if the WebSocket is referred by the parent frame.");
12 window
.jsTestIsAsync
= true;
17 document
.childWebSocket
= null;
19 document
.wsUrl
= "ws://127.0.0.1:8880/close-on-unload?p=close-on-unload-reference-in-parent.html";
20 var ws
= new WebSocket(document
.wsUrl
);
21 ws
.onopen = function()
23 debug("PASS ws on master document is ready.");
24 frameDiv
= document
.createElement("iframe");
25 frameDiv
.src
= "resources/close-on-unload-iframe-reference-in-parent.html";
26 document
.body
.appendChild(frameDiv
);
27 debug("PASS insert a iframe, where open ws called 'socket1'");
29 ws
.onmessage = function(evt
)
31 var messageData
= JSON
.parse(evt
.data
);
32 closedSocket
= messageData
.message
;
33 closeCode
= messageData
.closeCode
;
36 ws
.onclose = function()
38 shouldBe("closedSocket", '"socket1"');
39 shouldBe("closeCode", '"1001"');
40 shouldBe("document.childWebSocket.readyState", "3");
44 document
.iframeReady = function()
46 shouldBeNonNull("document.childWebSocket");
47 debug("PASS 'socket1' is sent to the server. unload the iframe. expect receiving 'socket1' on ws...");
48 document
.body
.removeChild(frameDiv
);