• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<title>WebSocket is not subject to HTTP(S) connection limit</title>
2<script>
3var protocol = location.protocol.replace('http', 'ws');
4var url = protocol + '//' + location.host + '/echo-with-no-extension';
5
6const SOCKETS_TO_OPEN = 255;
7
8// PARALLELISM limits the number of connections we try to open simultaneously.
9// This avoids triggering the throttling added in http://crrev.com/972963002,
10// which otherwise slows the test down considerably.
11const PARALLELISM = 2;
12
13var created = 0;
14var connected = 0;
15
16function createNewWebSocket()
17{
18  var ws = new WebSocket(url);
19  ++created;
20
21  ws.onopen = function() {
22    if (created < SOCKETS_TO_OPEN) {
23      createNewWebSocket();
24    }
25    ++connected;
26    if (connected == SOCKETS_TO_OPEN) {
27      document.title = "PASS";
28    }
29  };
30  ws.onclose = function() {
31    document.title = "FAIL";
32  };
33}
34
35for (var i = 0; i < PARALLELISM; ++i) {
36  createNewWebSocket();
37}
38</script>
39