5b01e07e37e776ea48c25349f842557cf65c3e90
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / handshake-error.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 error test");
12
13 window.jsTestIsAsync = true;
14
15 function endTest()
16 {
17     clearTimeout(timeoutID);
18     finishJSTest();
19 }
20
21 var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/handshake-error");
22
23 ws.onopen = function()
24 {
25     testFailed("Unexpectedly Connected.");
26 };
27
28 ws.onmessage = function(messageEvent)
29 {
30     testFailed("Unexpectedly Received: '" + messageEvent.data + "'");
31 };
32
33 ws.onclose = function()
34 {
35     debug("Closed.");
36     shouldBe("ws.readyState", "3")
37     endTest();
38 };
39
40 function timeOutCallback()
41 {
42     testFailed("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>