2011-07-05 Yuta Kitamura <yutak@chromium.org>
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hixie76 / close-event.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("Make sure WebSocket fires CloseEvent when closed.");
12
13 window.jsTestIsAsync = true;
14
15 var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hixie76/simple");
16
17 ws.onopen = function()
18 {
19     debug("WebSocket is open");
20 };
21
22 ws.onmessage = function(messageEvent)
23 {
24     debug("Received: '" + messageEvent.data + "'");
25 };
26
27 var closeEvent;
28 var closeEventType;
29 ws.onclose = function(event)
30 {
31     debug("Closed");
32     closeEvent = event;
33     closeEventType = closeEvent.type;
34     shouldBe("closeEventType", '"close"')
35     shouldBeTrue("'wasClean' in closeEvent");
36     shouldBeTrue("closeEvent.wasClean");
37     shouldBeTrue("Object.getPrototypeOf(closeEvent) === CloseEvent.prototype");
38     shouldBeTrue("Object.getPrototypeOf(closeEvent) !== Event.prototype");
39     finishJSTest();
40 };
41
42 var successfullyParsed = true;
43 </script>
44 <script src="../../../../js-test-resources/js-test-post.js"></script>
45 </body>
46 </html>