704d5a98961b30104b6932facc0bde7c8593a196
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hixie76 / handshake-error.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 error test");
11
12 window.jsTestIsAsync = true;
13
14 function endTest()
15 {
16     clearTimeout(timeoutID);
17     finishJSTest();
18 }
19
20 var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hixie76/handshake-error");
21
22 ws.onopen = function()
23 {
24     testFailed("Unexpectedly Connected.");
25 };
26
27 ws.onmessage = function(messageEvent)
28 {
29     testFailed("Unexpectedly Received: '" + messageEvent.data + "'");
30 };
31
32 ws.onclose = function()
33 {
34     debug("Closed.");
35     shouldBe("ws.readyState", "3")
36     endTest();
37 };
38
39 function timeOutCallback()
40 {
41     testFailed("Timed out in state: " + ws.readyState);
42     endTest();
43 }
44
45 var timeoutID = setTimeout(timeOutCallback, 3000);
46
47 </script>
48 <script src="../../../../js-test-resources/js-test-post.js"></script>
49 </body>
50 </html>