tizen beta release
[profile/ivi/webkit-efl.git] / LayoutTests / http / tests / websocket / tests / hixie76 / close-event.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../../../js-test-resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <div id="description"></div>
8 <div id="console"></div>
9 <script type="text/javascript">
10 description("Make sure WebSocket fires CloseEvent when closed.");
11
12 window.jsTestIsAsync = true;
13
14 var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hixie76/simple");
15
16 ws.onopen = function()
17 {
18     debug("WebSocket is open");
19 };
20
21 ws.onmessage = function(messageEvent)
22 {
23     debug("Received: '" + messageEvent.data + "'");
24 };
25
26 var closeEvent;
27 var closeEventType;
28 ws.onclose = function(event)
29 {
30     debug("Closed");
31     closeEvent = event;
32     closeEventType = closeEvent.type;
33     shouldBe("closeEventType", '"close"')
34     shouldBeTrue("'wasClean' in closeEvent");
35     shouldBeTrue("closeEvent.wasClean");
36     shouldBeTrue("Object.getPrototypeOf(closeEvent) === CloseEvent.prototype");
37     shouldBeTrue("Object.getPrototypeOf(closeEvent) !== Event.prototype");
38     finishJSTest();
39 };
40
41 </script>
42 <script src="../../../../js-test-resources/js-test-post.js"></script>
43 </body>
44 </html>