2 <script src=
"/js-test-resources/js-test.js"></script>
4 description("Test that WebSocket connections are throttled.");
6 window
.jsTestIsAsync
= true;
13 // 1. A handshake to "ws://127.0.0.1:8880/delayed-handshake" is started.
14 // This stays pending for 1 second.
15 // 2. Another 299 WebSockets to "ws://127.0.0.1:8880/echo" are created.
16 // 45 connections are rejected by per-renderer WebSocket throttling,
17 // and 254 connections to "ws://127.0.0.1:8880/echo" stay pending.
18 // 3. The handshake to "ws://127.0.0.1:8880/delayed-handshake"
19 // (started in Step 1) is completed.
20 // 4. The handshakes of 254 connections to "ws://127.0.0.1:8880/echo"
21 // (created in Step 2) are started and are completed without delay.
23 for (i
= 0; i
< socketCount
; ++i
) {
24 var ws
= new WebSocket(i
== 0 ?
25 "ws://127.0.0.1:8880/delayed-handshake" :
26 "ws://127.0.0.1:8880/echo");
28 ws
.onopen = function(ws
) {
31 }.bind(undefined, ws
);
33 ws
.onclose = function() {
35 if (closedCount
=== socketCount
) {
36 shouldBeEqualToNumber("openedCount", 255);