commit 3fbe1276ac4d884c85ac0b9640e6b568641464c8
parent 8afa8e259b67268b1f38860b1e557f4d8ae52971
Author: Philipp Hancke <philipp.hancke@googlemail.com>
Date: Thu, 9 Oct 2025 20:34:54 +0000
Bug 1992261 [wpt PR 55192] - webrtc wpt: make mute/unmute tests more robust, a=testonly
Automatic update from web-platform-tests
webrtc wpt: make mute/unmute tests more robust
Bug: webrtc:42226009, chromium:40115293
Change-Id: I40cebcf31267a697d3a5d4dc4c4f8b32bb9b5dc7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6999937
Reviewed-by: Guido Urdaneta <guidou@chromium.org>
Commit-Queue: Philipp Hancke <philipp.hancke@googlemail.com>
Reviewed-by: Henrik Boström <hbos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1524073}
--
wpt-commits: ced062fdf60092e68ca1e89a70cea6e7b58fcb39
wpt-pr: 55192
Diffstat:
1 file changed, 46 insertions(+), 27 deletions(-)
diff --git a/testing/web-platform/tests/webrtc/RTCPeerConnection-remote-track-mute.https.html b/testing/web-platform/tests/webrtc/RTCPeerConnection-remote-track-mute.https.html
@@ -8,6 +8,10 @@
<script>
'use strict';
+async function waitForTimeout(t, timeout_ms = 5000) {
+ return new Promise(r => t.step_timeout(r, timeout_ms));
+}
+
// The following helper functions are called from RTCPeerConnection-helper.js:
// exchangeOffer
// exchangeOfferAndListenToOntrack
@@ -24,23 +28,21 @@ promise_test(async t => {
const pc2 = createPeerConnectionWithCleanup(t);
exchangeIceCandidates(pc1, pc2);
- const unmuteResolver = new Resolver();
- let remoteTrack = null;
+ let muteWatcher;
+ let unmutePromise;
// The unmuting it timing sensitive so we hook up to the event directly
// instead of wrapping it in an EventWatcher which uses promises.
pc2.ontrack = t.step_func(e => {
- remoteTrack = e.track;
- assert_true(remoteTrack.muted, 'track is muted in ontrack');
- remoteTrack.onunmute = t.step_func(e => {
- assert_false(remoteTrack.muted, 'track is unmuted in onunmute');
- unmuteResolver.resolve();
- });
+ assert_true(e.track.muted, 'track is muted in ontrack');
+ muteWatcher = new EventWatcher(t, e.track, ['unmute'],
+ () => waitForTimeout(t));
+ unmutePromise = muteWatcher.wait_for('unmute');
pc2.ontrack = t.step_func(e => {
assert_unreached('ontrack fired unexpectedly');
});
});
await exchangeOfferAnswer(pc1, pc2);
- await unmuteResolver;
+ await unmutePromise;
}, 'ontrack: track goes from muted to unmuted');
promise_test(async t => {
@@ -50,12 +52,16 @@ promise_test(async t => {
const pc2 = createPeerConnectionWithCleanup(t);
exchangeIceCandidates(pc1, pc2);
- const e = await exchangeOfferAndListenToOntrack(t, pc1, pc2);
+ let muteWatcher;
+ let unmutePromise;
+ pc2.ontrack = t.step_func(e => {
+ muteWatcher = new EventWatcher(t, e.track, ['mute', 'unmute'],
+ () => waitForTimeout(t));
+ unmutePromise = muteWatcher.wait_for('unmute');
+ });
+ await exchangeOfferAnswer(pc1, pc2);
// Need to wait for the initial unmute event before renegotiating, otherwise
// there will be no transition from unmuted->muted.
- const muteWatcher = new EventWatcher(t, e.track, ['mute', 'unmute']);
- const unmutePromise = muteWatcher.wait_for('unmute');
- await exchangeAnswer(pc1, pc2);
await unmutePromise;
const mutePromise = muteWatcher.wait_for('mute');
@@ -72,17 +78,22 @@ promise_test(async t => {
const pc2 = createPeerConnectionWithCleanup(t);
exchangeIceCandidates(pc1, pc2);
- const e = await exchangeOfferAndListenToOntrack(t, pc1, pc2);
- const muteWatcher = new EventWatcher(t, e.track, ['mute', 'unmute']);
- await exchangeAnswer(pc1, pc2);
- await muteWatcher.wait_for('unmute');
+ let muteWatcher;
+ let unmutePromise;
+ pc2.ontrack = t.step_func(e => {
+ muteWatcher = new EventWatcher(t, e.track, ['mute', 'unmute'],
+ () => waitForTimeout(t));
+ unmutePromise = muteWatcher.wait_for('unmute');
+ });
+ await exchangeOfferAnswer(pc1, pc2);
+ await unmutePromise;
const mutePromise = muteWatcher.wait_for('mute');
localTransceiver.direction = 'inactive';
await exchangeOfferAnswer(pc1, pc2);
await mutePromise;
- const unmutePromise = muteWatcher.wait_for('unmute');
+ unmutePromise = muteWatcher.wait_for('unmute');
localTransceiver.direction = 'sendrecv';
await exchangeOfferAnswer(pc1, pc2);
@@ -96,14 +107,19 @@ promise_test(async t => {
const pc2 = createPeerConnectionWithCleanup(t);
exchangeIceCandidates(pc1, pc2);
- const e = await exchangeOfferAndListenToOntrack(t, pc1, pc2);
+ let muteWatcher;
+ let unmutePromise;
+ pc2.ontrack = t.step_func(e => {
+ muteWatcher = new EventWatcher(t, e.track, ['mute', 'unmute'],
+ () => waitForTimeout(t));
+ unmutePromise = muteWatcher.wait_for('unmute');
+ });
+ await exchangeOfferAnswer(pc1, pc2);
// Need to wait for the initial unmute event before closing, otherwise
// there will be no transition from unmuted->muted.
- const muteWatcher = new EventWatcher(t, e.track, ['mute', 'unmute']);
- const unmutePromise = muteWatcher.wait_for('unmute');
- await exchangeAnswer(pc1, pc2);
await unmutePromise;
+ // This will send an RTCP BYE which causes the remote side to mute.
const mutePromise = muteWatcher.wait_for('mute');
localTransceiver.stop();
await mutePromise;
@@ -116,17 +132,20 @@ promise_test(async t => {
const pc2 = createPeerConnectionWithCleanup(t);
exchangeIceCandidates(pc1, pc2);
- const e = await exchangeOfferAndListenToOntrack(t, pc1, pc2);
+ let muteWatcher;
+ let unmutePromise;
+ pc2.ontrack = t.step_func(e => {
+ muteWatcher = new EventWatcher(t, e.track, ['mute', 'unmute'],
+ () => waitForTimeout(t));
+ unmutePromise = muteWatcher.wait_for('unmute');
+ });
+ await exchangeOfferAnswer(pc1, pc2);
// Need to wait for the initial unmute event before closing, otherwise
// there will be no transition from unmuted->muted.
- const muteWatcher = new EventWatcher(t, e.track, ['mute', 'unmute']);
- const unmutePromise = muteWatcher.wait_for('unmute');
- await exchangeAnswer(pc1, pc2);
await unmutePromise;
const mutePromise = muteWatcher.wait_for('mute');
pc1.close();
await mutePromise;
}, 'pc.close() on one side causes mute events on the other');
-
</script>