2011-07-06 Adam Barth <abarth@webkit.org>
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hixie76 / multiple-connections.html
1 <p>Test that WebSocket is not subject to HTTP connection limit. Should say PASS:</p>
2 <p id=result>Running...</p>
3 <script>
4 if (window.layoutTestController) {
5     layoutTestController.dumpAsText();
6     layoutTestController.waitUntilDone();
7 }
8
9 var socketCount = 50;
10 var result = document.getElementById("result");
11 var sockets = [];
12
13 for (i = 0; i < socketCount; ++i) {
14     var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hixie76/echo");
15     sockets[i] = ws;
16     ws.onopen = function() {
17         var num = parseInt(result.innerHTML);
18         if (!num)
19             num = 0;
20         if (num != socketCount - 1)
21             result.innerHTML = num + 1;
22         else {
23             result.innerHTML = "PASS";
24             for (j = 0; j < socketCount; ++j) {
25                 sockets[j].onclose = null;
26                 sockets[j].close();
27             }
28             if (window.layoutTestController)
29                 layoutTestController.notifyDone();
30         }
31     }
32     ws.onclose = function() { alert("FAIL: unexpected close event") }
33 }
34 </script>