tizen beta release
[profile/ivi/webkit-efl.git] / LayoutTests / http / tests / websocket / tests / hybi / set-protocol.html
1 <!DOCTYPE html>
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("WebSocket.protocol should not be modified.");
11
12 window.jsTestIsAsync = true;
13 if (window.layoutTestController)
14     layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 0);
15
16 var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/accept-first-subprotocol", "chat");
17 var closeEvent;
18
19 shouldBeEqualToString("ws.protocol", "");
20 ws.protocol = "superchat";
21 shouldBeEqualToString("ws.protocol", "");
22
23 ws.onopen = function()
24 {
25     debug("Connected");
26     shouldBeEqualToString("ws.protocol", "chat");
27     ws.protocol = "superchat";
28     shouldBeEqualToString("ws.protocol", "chat");
29 };
30
31 ws.onclose = function(event)
32 {
33     debug("Closed");
34     shouldBeEqualToString("ws.protocol", "chat");
35     ws.protocol = "superchat";
36     shouldBeEqualToString("ws.protocol", "chat");
37     closeEvent = event;
38     shouldBeTrue("closeEvent.wasClean");
39     setTimeout("checkAfterOnClose()", 0);
40 };
41
42 function checkAfterOnClose()
43 {
44     debug("Exited onclose handler");
45     shouldBeEqualToString("ws.protocol", "chat");
46     ws.protocol = "superchat";
47     shouldBeEqualToString("ws.protocol", "chat");
48     finishJSTest();
49 }
50
51 </script>
52 <script src="../../../../js-test-resources/js-test-post.js"></script>
53 </body>
54 </html>