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