efabdef60a20b1cc901cc4ef2fb8fc6877b43ce4
[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 if (window.testRunner)
14     testRunner.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 1);
15
16 var protocol;
17
18 function endTest()
19 {
20     shouldBe("protocol", '"sub-protocol"');
21     clearTimeout(timeoutID);
22     finishJSTest();
23 }
24
25 var url = "ws://localhost:8880/websocket/tests/hixie76/protocol-test?protocol=sub-protocol";
26 var ws = new WebSocket(url);
27
28 ws.onopen = function()
29 {
30     debug("Connected");
31 };
32
33 ws.onmessage = function (messageEvent)
34 {
35     protocol = messageEvent.data;
36     ws.close();
37 };
38
39 ws.onclose = function()
40 {
41     endTest();
42 };
43
44 function timeOutCallback()
45 {
46     debug("Timed out in state: " + ws.readyState);
47     endTest();
48 }
49
50 var timeoutID = setTimeout(timeOutCallback, 3000);
51
52 </script>
53 <script src="../../../../js-test-resources/js-test-post.js"></script>
54 </body>
55 </html>