2009-12-02 Fumitoshi Ukai <ukai@chromium.org>
[WebKit-https.git] / LayoutTests / websocket / tests / script-tests / url-with-empty-query.js
1 description("Make sure handshake with URL with empty query components success.");
2
3 if (window.layoutTestController)
4     layoutTestController.waitUntilDone();
5
6 var url = "ws://127.0.0.1:8880/websocket/tests/echo-location?";
7 var handshake_success = false;
8 var ws_location;
9
10 function endTest()
11 {
12     clearTimeout(timeoutID);
13     shouldBeTrue("handshake_success");
14     shouldBe("ws_location", "url");
15     isSuccessfullyParsed();
16     if (window.layoutTestController)
17         layoutTestController.notifyDone();
18 }
19
20 debug("url=" + url);
21 var ws = new WebSocket(url);
22 ws.onopen = function () {
23     debug("WebSocket is open");
24     handshake_success = true;
25 };
26 ws.onmessage = function (evt) {
27     ws_location = evt.data;
28     debug("received:" + ws_location);
29     ws.close();
30 };
31 ws.onclose = function () {
32     debug("WebSocket is closed");
33     endTest();
34 };
35 var timeoutID = setTimeout("endTest()", 2000);
36
37 var successfullyParsed = true;