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 if WebSocket is closed when navigating to new location.");
12 window
.jsTestIsAsync
= true;
18 document
.wsUrl
= "ws://127.0.0.1:8880/close-on-unload?p=close-on-navigate-new-location.html";
19 var ws
= new WebSocket(document
.wsUrl
);
20 ws
.onopen = function()
22 debug("PASS ws on master document is ready.");
23 frameDiv
= document
.createElement("iframe");
24 frameDiv
.src
= "resources/close-on-unload-iframe.html";
25 document
.body
.appendChild(frameDiv
);
26 debug("PASS insert a iframe, where open ws called 'socket1'");
28 ws
.onmessage = function(evt
)
30 var messageData
= JSON
.parse(evt
.data
);
31 closedSocket
= messageData
.message
;
32 closeCode
= messageData
.closeCode
;
35 ws
.onclose = function()
37 shouldBe("closedSocket", '"socket1"');
38 shouldBe("closeCode", '"1001"');
42 document
.iframeReady = function()
44 debug("PASS 'socket1' is sent to the server. navigate to new location. expect receiving 'socket1' on ws...");
45 frameDiv
.src
= "../handler_map.txt";