Remove LayoutTestController and WebKitTestRunner support for Hixie76 WebSockets
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hybi / multiple-subprotocols.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("Test WebSocket subprotocol negotiation.");
11
12 window.jsTestIsAsync = true;
13
14 var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/protocol-test?protocol=superchat", ["chat", "superchat"]);
15 var closeEvent;
16 var receivedMessage;
17
18 shouldBeEqualToString("ws.protocol", "");
19
20 ws.onopen = function()
21 {
22     debug("Connected");
23     shouldBeEqualToString("ws.protocol", "superchat");
24 };
25
26 ws.onmessage = function(event)
27 {
28     receivedMessage = event.data;
29     debug("Received: " + receivedMessage);
30     shouldBeEqualToString("receivedMessage", "superchat");
31 };
32
33 ws.onclose = function(event)
34 {
35     debug("Closed");
36     shouldBeEqualToString("ws.protocol", "superchat");
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", "superchat");
46     finishJSTest();
47 }
48
49 </script>
50 <script src="../../../../js-test-resources/js-test-post.js"></script>
51 </body>
52 </html>