9f35e41cddb4c71ea9b9bb2d580a598918c08682
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / client-close.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("WebSocket: Test client-initiated close.");
12
13 window.jsTestIsAsync = true;
14
15 var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/client-close");
16 var closeEvent;
17 var receivedMessage;
18
19 ws.onopen = function()
20 {
21     debug("Connected");
22     ws.close();
23 };
24
25 ws.onmessage = function(messageEvent)
26 {
27     debug("Received: " + messageEvent.data);
28     receivedMessage = messageEvent.data;
29 };
30
31 ws.onclose = function(event)
32 {
33     debug("Closed");
34     closeEvent = event;
35     shouldBeEqualToString("receivedMessage", "close_frame='\\xff\\x00'");
36     shouldBeTrue("closeEvent.wasClean");
37     finishJSTest();
38 };
39
40 var successfullyParsed = true;
41 </script>
42 <script src="../../../js-test-resources/js-test-post.js"></script>
43 </body>
44 </html>