JS Test Harness: Remove more link tags
[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 if (window.layoutTestController)
14     layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 0);
15
16 var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/protocol-test?protocol=superchat", ["chat", "superchat"]);
17 var closeEvent;
18 var receivedMessage;
19
20 shouldBeEqualToString("ws.protocol", "");
21
22 ws.onopen = function()
23 {
24     debug("Connected");
25     shouldBeEqualToString("ws.protocol", "superchat");
26 };
27
28 ws.onmessage = function(event)
29 {
30     receivedMessage = event.data;
31     debug("Received: " + receivedMessage);
32     shouldBeEqualToString("receivedMessage", "superchat");
33 };
34
35 ws.onclose = function(event)
36 {
37     debug("Closed");
38     shouldBeEqualToString("ws.protocol", "superchat");
39     closeEvent = event;
40     shouldBeTrue("closeEvent.wasClean");
41     setTimeout("checkAfterOnClose()", 0);
42 };
43
44 function checkAfterOnClose()
45 {
46     debug("Exited onclose handler");
47     shouldBeEqualToString("ws.protocol", "superchat");
48     finishJSTest();
49 }
50
51 var successfullyParsed = true;
52 </script>
53 <script src="../../../../js-test-resources/js-test-post.js"></script>
54 </body>
55 </html>