Update V8 to version 4.7.42.
[chromium-blink-merge.git] / net / data / websocket / multiple-connections.html
blob0fe9e973347479f8d211352408a1f0468da24efa
1 <title>WebSocket is not subject to HTTP(S) connection limit</title>
2 <script>
3 var protocol = location.protocol.replace('http', 'ws');
4 var url = protocol + '//' + location.host + '/echo-with-no-extension';
6 // TODO(ricea): The limit for ws: is 255, but wss: gets a limit of 30
7 // (per-host:port, not ip:port!) because it still uses the HTTP pool code. This
8 // should be fixed at some point. When it is, change this number back to 50 (or
9 // even larger, if it works).
10 const SOCKETS_TO_OPEN = 30;
12 // PARALLELISM limits the number of connections we try to open simultaneously.
13 // This avoids triggering the throttling added in http://crrev.com/972963002,
14 // which otherwise slows the test down considerably.
15 const PARALLELISM = 2;
17 var created = 0;
18 var connected = 0;
20 function createNewWebSocket()
22 var ws = new WebSocket(url);
23 ++created;
25 ws.onopen = function() {
26 if (created < SOCKETS_TO_OPEN) {
27 createNewWebSocket();
29 ++connected;
30 if (connected == SOCKETS_TO_OPEN) {
31 document.title = "PASS";
34 ws.onclose = function() {
35 document.title = "FAIL";
39 for (var i = 0; i < PARALLELISM; ++i) {
40 createNewWebSocket();
43 setTimeout(function() {
44 console.log("Got stuck after " + connected + " socket(s) connected");
45 document.title = "FAIL";
46 }, 5000);
47 </script>