multiple-connections.html 921 B

1234567891011121314151617181920212223242526272829303132333435363738
  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';
  5. const SOCKETS_TO_OPEN = 255;
  6. // PARALLELISM limits the number of connections we try to open simultaneously.
  7. // This avoids triggering the throttling added in http://crrev.com/972963002,
  8. // which otherwise slows the test down considerably.
  9. const PARALLELISM = 2;
  10. var created = 0;
  11. var connected = 0;
  12. function createNewWebSocket()
  13. {
  14. var ws = new WebSocket(url);
  15. ++created;
  16. ws.onopen = function() {
  17. if (created < SOCKETS_TO_OPEN) {
  18. createNewWebSocket();
  19. }
  20. ++connected;
  21. if (connected == SOCKETS_TO_OPEN) {
  22. document.title = "PASS";
  23. }
  24. };
  25. ws.onclose = function() {
  26. document.title = "FAIL";
  27. };
  28. }
  29. for (var i = 0; i < PARALLELISM; ++i) {
  30. createNewWebSocket();
  31. }
  32. </script>