4c06d7c3d6d8d662ac94385b457d297ad6840268
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hixie76 / handshake-fail-by-no-connection-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 Connection header field isn't reflected by the server.");
11
12 window.jsTestIsAsync = true;
13 if (window.layoutTestController)
14     layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 1);
15
16 function endTest()
17 {
18     clearTimeout(timeoutID);
19     finishJSTest();
20 }
21
22 var url = "ws://localhost:8880/websocket/tests/hixie76/handshake-fail-by-no-connection-header";
23 var ws = new WebSocket(url);
24
25 ws.onopen = function()
26 {
27     debug("FAIL: Connected");
28 };
29
30 ws.onmessage = function(messageEvent)
31 {
32     protocol = messageEvent.data;
33     ws.close();
34 };
35
36 ws.onclose = function()
37 {
38     endTest();
39 };
40
41 function timeOutCallback()
42 {
43     debug("Timed out in state: " + ws.readyState);
44     endTest();
45 }
46
47 var timeoutID = setTimeout(timeOutCallback, 3000);
48
49 </script>
50 <script src="../../../../js-test-resources/js-test-post.js"></script>
51 </body>
52 </html>