Bug 1586981 [wpt PR 19563] - Turn on backpressure for blink::WebSocketStream sooner, a=testonly

Automatic update from web-platform-tests
Turn on backpressure for blink::WebSocketStream sooner

Apply backpressure to blink::WebSocketChannel before the WebSocketStream
handshake starts, rather than after it completes. This avoids a race
condition where more of the first message is read than should be.

Also fix flakiness in the
external/wpt/websockets/stream-tentative/backpressure-receive.any.js by
doubling the size of message used.

BUG=1002780

Change-Id: I915c71a4b81b95375b7c4c584f7782d5336cba85
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1844911
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Commit-Queue: Adam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703610}

--

wpt-commits: b3807b6ffe70db1bcaa28cf8b5aa8c6da025b5fa
wpt-pr: 19563
This commit is contained in:
Adam Rice 2019-10-14 13:39:47 +00:00 коммит произвёл moz-wptsync-bot
Родитель e758f9d448
Коммит 45fa71c261
2 изменённых файлов: 16 добавлений и 8 удалений

Просмотреть файл

@ -2,13 +2,18 @@
import time
# The amount of buffering a WebSocket connection has is not standardised, but
# it's reasonable to expect that it will not be as large as 8MB.
MESSAGE_SIZE = 8 * 1024 * 1024
# The amount of internal buffering a WebSocket connection has is not
# standardised, and varies depending upon the OS. Setting this number too small
# will result in false negatives, as the entire message gets buffered. Setting
# this number too large will result in false positives, when it takes more than
# 2 seconds to transmit the message anyway. This number was arrived at by
# trial-and-error.
MESSAGE_SIZE = 16 * 1024 * 1024
def web_socket_do_extra_handshake(request):
# Turn off permessage-deflate, otherwise it shrinks our 8MB buffer to 8KB.
# Turn off permessage-deflate, otherwise it shrinks our big message to a
# tiny message.
request.ws_extension_processors = []

Просмотреть файл

@ -3,11 +3,14 @@
// META: global=window,worker
// META: timeout=long
// This test works by using a server WebSocket handler which sends an 8MB
// Allow for this much timer jitter.
const JITTER_ALLOWANCE_MS = 200;
// This test works by using a server WebSocket handler which sends a large
// message, and then sends a second message with the time it measured the first
// message taking. On the browser side, we wait 2 seconds before reading from
// the socket. This should ensure it takes at least 2 seconds to finish sending
// the 8MB message.
// the large message.
promise_test(async t => {
const wss = new WebSocketStream(`${BASEURL}/send-backpressure`);
const { readable } = await wss.connection;
@ -16,7 +19,7 @@ promise_test(async t => {
// Create backpressure for 2 seconds.
await new Promise(resolve => t.step_timeout(resolve, 2000));
// Skip the 8MB message.
// Skip the large message.
await reader.read();
// Read the time it took.
@ -24,6 +27,6 @@ promise_test(async t => {
// A browser can pass this test simply by being slow. This may be a source of
// flakiness for browsers that do not implement backpressure properly.
assert_greater_than_equal(Number(value), 2,
assert_greater_than_equal(Number(value), 2 - JITTER_ALLOWANCE_MS / 1000,
'data send should have taken at least 2 seconds');
}, 'backpressure should be applied to received messages');