[Mac][Win][WK2] Switch to RFC 6455 protocol for WebSockets
[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 <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 fail if sub protocol name mismatches.");
11
12 window.jsTestIsAsync = true;
13 if (window.layoutTestController)
14     layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 1);
15
16 var protocol;
17
18 function endTest()
19 {
20     shouldBeUndefined("protocol");
21     clearTimeout(timeoutID);
22     finishJSTest();
23 }
24
25 var url = "ws://localhost:8880/websocket/tests/hixie76/protocol-test?protocol=available-protocol";
26 var ws = new WebSocket(url, "requestting-protocol");
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>