c04c9c3fc7d61301c1a14bfdb9140f164e1bcce5
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hixie76 / websocket-protocol-ignored.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("Test WebSocket handshake success without protocol and ignore WebSocket-Protocol from server.");
11
12 window.jsTestIsAsync = true;
13
14 var protocol;
15
16 function endTest()
17 {
18     shouldBe("protocol", '"sub-protocol"');
19     clearTimeout(timeoutID);
20     finishJSTest();
21 }
22
23 var url = "ws://localhost:8880/websocket/tests/hixie76/protocol-test?protocol=sub-protocol";
24 var ws = new WebSocket(url);
25
26 ws.onopen = function()
27 {
28     debug("Connected");
29 };
30
31 ws.onmessage = function (messageEvent)
32 {
33     protocol = messageEvent.data;
34     ws.close();
35 };
36
37 ws.onclose = function()
38 {
39     endTest();
40 };
41
42 function timeOutCallback()
43 {
44     debug("Timed out in state: " + ws.readyState);
45     endTest();
46 }
47
48 var timeoutID = setTimeout(timeOutCallback, 3000);
49
50 </script>
51 <script src="../../../../js-test-resources/js-test-post.js"></script>
52 </body>
53 </html>