Skip to content

Commit

Permalink
Bug 1535797 [wpt PR 15438] - Update RTCDataChannel bufferedamountlow …
Browse files Browse the repository at this point in the history
…implementation., a=testonly

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 <marinacioceachromium.org>
Reviewed-by: Henrik Boström <hboschromium.org>
Cr-Commit-Position: refs/heads/master{#639846}

--

wpt-commits: 791052bb65a653296c9fe414e94f5ee1bfb88864
wpt-pr: 15438

UltraBlame original commit: 9b779595e781991c16f9e9314fdbd4fb653e2df2
  • Loading branch information
marco-c committed Oct 4, 2019
1 parent b523c57 commit 897d8a3
Showing 1 changed file with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');

</script>

0 comments on commit 897d8a3

Please sign in to comment.