2011-07-05 Yuta Kitamura <yutak@chromium.org>
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hixie76 / handshake-fail-by-sub-protocol-mismatch.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("Test WebSocket handshake fail if sub protocol name mismatches.");
12
13 window.jsTestIsAsync = true;
14
15 var protocol;
16
17 function endTest()
18 {
19     shouldBeUndefined("protocol");
20     clearTimeout(timeoutID);
21     finishJSTest();
22 }
23
24 var url = "ws://localhost:8880/websocket/tests/hixie76/protocol-test?protocol=available-protocol";
25 var ws = new WebSocket(url, "requestting-protocol");
26
27 ws.onopen = function()
28 {
29     debug("Connected");
30 };
31
32 ws.onmessage = function (messageEvent)
33 {
34     protocol = messageEvent.data;
35     ws.close();
36 };
37
38 ws.onclose = function()
39 {
40     endTest();
41 };
42
43 function timeOutCallback()
44 {
45     debug("Timed out in state: " + ws.readyState);
46     endTest();
47 }
48
49 var timeoutID = setTimeout(timeOutCallback, 3000);
50
51 var successfullyParsed = true;
52 </script>
53 <script src="../../../../js-test-resources/js-test-post.js"></script>
54 </body>
55 </html>