9632ed1112360631837c020248395a5f8de78394
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hybi / handshake-fail-by-more-protocol-header.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>
10 description("Test that WebSocket handshake fails if there are more than one Sec-WebSocket-Protocol header field in the response.");
11
12 window.jsTestIsAsync = true;
13 if (window.testRunner)
14     testRunner.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 0);
15
16 function endTest()
17 {
18     clearTimeout(timeoutID);
19     finishJSTest();
20 }
21
22 var url = "ws://localhost:8880/websocket/tests/hybi/handshake-fail-by-more-protocol-header";
23 var ws = new WebSocket(url, "MatchProtocol");
24
25 ws.onopen = function()
26 {
27     testFailed("Unexpectedly Connected.");
28 };
29
30 ws.onmessage = function(messageEvent)
31 {
32     testFailed("Unexpectedly Received: '" + messageEvent.data + "'");
33 };
34
35 ws.onclose = function()
36 {
37     endTest();
38 };
39
40 function timeOutCallback()
41 {
42     debug("Timed out in state: " + ws.readyState);
43     endTest();
44 }
45
46 var timeoutID = setTimeout(timeOutCallback, 3000);
47
48 </script>
49 <script src="../../../../js-test-resources/js-test-post.js"></script>
50 </body>
51 </html>