714cb495e18fd5a129b7198ac0cb2bbbf8d8eea0
[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.testRunner) {
5     testRunner.dumpAsText();
6     testRunner.waitUntilDone();
7     testRunner.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 1);
8 }
9
10 var socketCount = 50;
11 var result = document.getElementById("result");
12 var sockets = [];
13
14 for (i = 0; i < socketCount; ++i) {
15     var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hixie76/echo");
16     sockets[i] = ws;
17     ws.onopen = function() {
18         var num = parseInt(result.innerHTML);
19         if (!num)
20             num = 0;
21         if (num != socketCount - 1)
22             result.innerHTML = num + 1;
23         else {
24             result.innerHTML = "PASS";
25             for (j = 0; j < socketCount; ++j) {
26                 sockets[j].onclose = null;
27                 sockets[j].close();
28             }
29             if (window.testRunner)
30                 testRunner.notifyDone();
31         }
32     }
33     ws.onclose = function() { alert("FAIL: unexpected close event") }
34 }
35 </script>