3b4c90a99ef4302f11c132c82ac01e3955764b70
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / sub-protocol-with-space.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("Test WebSocket handshake success with sub protocol contains space.");
12
13 window.jsTestIsAsync = true;
14
15 var protocol;
16
17 function endTest()
18 {
19     shouldBe("protocol", '"sub protocol"');
20     finishJSTest();
21 }
22
23 var url = "ws://localhost:8880/websocket/tests/protocol-test?protocol=sub%20protocol";
24 var ws = new WebSocket(url, "sub protocol");
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 var successfullyParsed = true;
51 </script>
52 <script src="../../../js-test-resources/js-test-post.js"></script>
53 </body>
54 </html>