0bb2f0199b0cddfde81def5e40d5531497c7d3fa
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / handshake-fail-by-no-cr.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
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 type="text/javascript">
11 description('Handshake should fail when the first line does not end with CRLF.');
12
13 window.jsTestIsAsync = true;
14
15 var connected = false;
16 var origin;
17
18 function endTest() {
19     shouldBeFalse('connected');
20     shouldBeUndefined('origin');
21     clearTimeout(timeoutID);
22     finishJSTest();
23 }
24
25 var url = 'ws://localhost:8880/websocket/tests/handshake-fail-by-no-cr';
26 var ws = new WebSocket(url);
27
28 ws.onopen = function()
29 {
30     debug('Connected');
31     connected = true;
32 }
33
34 ws.onmessage = function(messageEvent)
35 {
36     origin = messageEvent.data;
37     debug('origin = ' + origin);
38     ws.close();
39 }
40
41 ws.onclose = function()
42 {
43     endTest();
44 }
45
46 function timeoutCallback()
47 {
48     debug('Timed out (state = ' + ws.readyState + ')');
49     endTest();
50 }
51
52 var timeoutID = setTimeout(timeoutCallback, 3000);
53
54 var successfullyParsed = true;
55 </script>
56 <script src="../../../js-test-resources/js-test-post.js"></script>
57 </body>
58 </html>