Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / websocket / multiple-connections.html
blobe55e1fa469f8b02b178f3c26c2ecf92467240b5f
1 <!DOCTYPE html>
2 <script src="/js-test-resources/js-test.js"></script>
3 <script>
4 description("Test that WebSockets are not subject to the HTTP connection limit.");
6 window.jsTestIsAsync = true;
8 const SOCKETS_TO_OPEN = 50;
9 // PARALLELISM limits the number of connections we try to open simultaneously.
10 // This avoids triggering the throttling added in http://crrev.com/972963002,
11 // which slows the test down considerably. 4 is the maximum number of
12 // simultaneous pending connections guaranteeed to have zero throttling delay
13 // applied, but parallelism of 2 seems to give the best performance in practice.
14 const PARALLELISM = 2;
16 var socketsOpened = 0;
17 var sockets = [];
19 function createNewWebSocket()
21 var ws = new WebSocket("ws://127.0.0.1:8880/echo");
22 sockets.push(ws);
23 ws.onopen = function() {
24 if (sockets.length < SOCKETS_TO_OPEN) {
25 createNewWebSocket();
27 ++socketsOpened;
28 if (socketsOpened == SOCKETS_TO_OPEN) {
29 cleanUpSocketsAndFinish();
32 ws.onclose = function() {
33 testFailed("unexpected close event");
34 cleanUpSocketsAndFinish();
38 function cleanUpSocketsAndFinish()
40 for (var ws of sockets) {
41 ws.onclose = null;
42 ws.close();
44 shouldBeEqualToNumber("socketsOpened", SOCKETS_TO_OPEN);
45 finishJSTest();
48 for (var i = 0; i < PARALLELISM; ++i) {
49 createNewWebSocket();
51 </script>