2009-12-08 Fumitoshi Ukai <ukai@chromium.org>
[WebKit-https.git] / LayoutTests / websocket / tests / script-tests / sub-protocol-with-space.js
1 description("Test WebSocket handshake success with sub protocol contains space.");
2
3 if (window.layoutTestController)
4     layoutTestController.waitUntilDone();
5
6 var protocol;
7
8 function endTest()
9 {
10     shouldBe("protocol", '"sub protocol"');
11     clearTimeout(timeoutID);
12     isSuccessfullyParsed();
13     if (window.layoutTestController)
14         layoutTestController.notifyDone();
15 }
16
17 var url = "ws://localhost:8880/websocket/tests/protocol-test?protocol=sub%20protocol";
18 var ws = new WebSocket(url, "sub protocol");
19
20 ws.onopen = function()
21 {
22     debug("Connected");
23 };
24
25 ws.onmessage = function (messageEvent)
26 {
27     protocol = messageEvent.data;
28     ws.close();
29 };
30
31 ws.onclose = function()
32 {
33     endTest();
34 };
35
36 function timeOutCallback()
37 {
38     debug("Timed out in state: " + ws.readyState);
39     endTest();
40 }
41
42 var timeoutID = setTimeout(timeOutCallback, 3000);
43
44 var successfullyParsed = true;