ce75f957046702becbdfb5eb6d7b62552d207d8b
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / handshake-fail-by-no-connection-header.html
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <link rel="stylesheet" href="../../../js-test-resources/js-test-style.css">
5 <script src="../../../js-test-resources/js-test-pre.js"></script>
6 </head>
7 <body>
8 <div id="description"></div>
9 <div id="console"></div>
10 <script>
11 description("Test that WebSocket handshake fails if Connection header field isn't reflected by the server.");
12
13 window.jsTestIsAsync = true;
14
15 function endTest()
16 {
17     clearTimeout(timeoutID);
18     finishJSTest();
19 }
20
21 var url = "ws://localhost:8880/websocket/tests/handshake-fail-by-no-connection-header";
22 var ws = new WebSocket(url);
23
24 ws.onopen = function()
25 {
26     debug("FAIL: Connected");
27 };
28
29 ws.onmessage = function(messageEvent)
30 {
31     protocol = messageEvent.data;
32     ws.close();
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 var successfullyParsed = true;
49 </script>
50 <script src="../../../js-test-resources/js-test-post.js"></script>
51 </body>
52 </html>