From 897d8a330309500f895cc3920c53839d9fe0db53 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Fri, 4 Oct 2019 03:32:09 +0000 Subject: [PATCH] Bug 1535797 [wpt PR 15438] - Update RTCDataChannel bufferedamountlow implementation., a=testonly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automatic update from web-platform-tests Update RTCDataChannel bufferedamountlow implementation. Maintain bufferedamount value in blink layer. Increase bufferedamount on send and decrease it on OnBufferedAmountChange updates from webrtc layer. Fire bufferedamountlow when bufferedamount goes below bufferedamountlowthreshold. This change builds upon the corresponding webrtc change: https://webrtc-review.googlesource.com/c/src/+/123237 Design doc: http://doc/1lorHBn-GMn5U0T0RQANxrsW0pXhw8XGZM-xZyVUOW90 Standard: https://w3c.github.io/webrtc-pc/#event-datachannel-bufferedamountlow Bug: 878682 Change-Id: Ifebc79f71f924ecb5cedce1c94e18440663337f5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1474764 Commit-Queue: Marina Ciocea Reviewed-by: Henrik Boström Cr-Commit-Position: refs/heads/master{#639846} -- wpt-commits: 791052bb65a653296c9fe414e94f5ee1bfb88864 wpt-pr: 15438 UltraBlame original commit: 9b779595e781991c16f9e9314fdbd4fb653e2df2 --- .../webrtc/RTCDataChannel-bufferedAmount.html | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/testing/web-platform/tests/webrtc/RTCDataChannel-bufferedAmount.html b/testing/web-platform/tests/webrtc/RTCDataChannel-bufferedAmount.html index 2c37cc278f57c..f4a7104a4e5f3 100644 --- a/testing/web-platform/tests/webrtc/RTCDataChannel-bufferedAmount.html +++ b/testing/web-platform/tests/webrtc/RTCDataChannel-bufferedAmount.html @@ -166,4 +166,59 @@ assert_unreached(`Unexpected promise rejection: ${err}`))); }, 'bufferedAmount should increase by byte length for each message sent'); + promise_test(async t => { + const [channel1, channel2] = await createDataChannelPair(); + channel1.addEventListener('bufferedamountlow', t.step_func_done(() => { + assert_true(channel1.bufferedAmount <= channel1.bufferedAmountLowThreshold); + })); + const eventWatcher = new EventWatcher(t, channel1, ['bufferedamountlow']); + channel1.send(helloString); + await eventWatcher.wait_for(['bufferedamountlow']); + }, 'Data channel bufferedamountlow event fires after send() is complete'); + + promise_test(async t => { + const [channel1, channel2] = await createDataChannelPair(); + channel1.send(helloString); + assert_equals(channel1.bufferedAmount, helloString.length); + await awaitMessage(channel2); + assert_equals(channel1.bufferedAmount, 0); + }, 'Data channel bufferedamount is data.length on send(data)'); + + promise_test(async t => { + const [channel1, channel2] = await createDataChannelPair(); + channel1.send(helloString); + assert_equals(channel1.bufferedAmount, helloString.length); + assert_equals(channel1.bufferedAmount, helloString.length); + }, 'Data channel bufferedamount returns the same amount if no more data is' + + ' sent on the channel'); + + promise_test(async t => { + const [channel1, channel2] = await createDataChannelPair(); + let eventFireCount = 0; + channel1.addEventListener('bufferedamountlow', t.step_func(() => { + assert_true(channel1.bufferedAmount <= channel1.bufferedAmountLowThreshold); + assert_equals(++eventFireCount, 1); + })); + const eventWatcher = new EventWatcher(t, channel1, ['bufferedamountlow']); + channel1.send(helloString); + assert_equals(channel1.bufferedAmount, helloString.length); + channel1.send(helloString); + assert_equals(channel1.bufferedAmount, 2 * helloString.length); + await eventWatcher.wait_for(['bufferedamountlow']); + }, 'Data channel bufferedamountlow event fires only once after multiple' + + ' consecutive send() calls'); + + promise_test(async t => { + const [channel1, channel2] = await createDataChannelPair(); + const eventWatcher = new EventWatcher(t, channel1, ['bufferedamountlow']); + channel1.send(helloString); + assert_equals(channel1.bufferedAmount, helloString.length); + await eventWatcher.wait_for(['bufferedamountlow']); + assert_equals(await awaitMessage(channel2), helloString); + channel1.send(helloString); + assert_equals(channel1.bufferedAmount, helloString.length); + await eventWatcher.wait_for(['bufferedamountlow']); + assert_equals(await awaitMessage(channel2), helloString); + }, 'Data channel bufferedamountlow event fires after each sent message'); +