812ddf7d28149d457114ecb8880bfc9e469a4061
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / close-on-navigate-new-location.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <link rel="stylesheet" href="../../../js-test-resources/js-test-style.css">
5 <script src="../../../js-test-resources/js-test-pre.js"></script>
6 </head>
7 <body>
8 <div id="description"></div>
9 <div id="console"></div>
10 <script type="text/javascript">
11 description("Test if Web Socket is closed when navigating to new location.");
12
13 window.jsTestIsAsync = true;
14
15 var frameDiv;
16 var closedSocket;
17
18 var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/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.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     finishJSTest();
36 };
37
38 document.iframeReady = function()
39 {
40     debug("PASS 'socket1' is sent to the server. navigate to new location. expect receiving 'socket1' on ws...");
41     frameDiv.src = "handler_map.txt";
42 };
43
44 var successfullyParsed = true;
45 </script>
46 <script src="../../../js-test-resources/js-test-post.js"></script>
47 </body>
48 </html>