Skip to content

Commit

Permalink
webrtc wpt: add test asserting the order of track events matches the SDP
Browse files Browse the repository at this point in the history
and is not dependent on the order of tracks in the MediaStream

See
  w3c/mediacapture-main#1028

Bug: None
Change-Id: I77ac10a078632bc9ae944a3254626ff30965c433
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6286091
Commit-Queue: Philipp Hancke <[email protected]>
Reviewed-by: Harald Alvestrand <[email protected]>
Reviewed-by: Guido Urdaneta <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1424488}
  • Loading branch information
fippo authored and chromium-wpt-export-bot committed Feb 25, 2025
1 parent 892b423 commit 436123f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions webrtc/RTCPeerConnection-ontrack.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,29 @@
await new Promise(resolve => t.step_timeout(resolve, 100));
}, `Using offerToReceiveAudio and offerToReceiveVideo should only cause a ${type} track event to fire, if ${type} was the only type negotiated`));

promise_test(async t => {
const pc1 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());

const stream = new MediaStream();
const stream2 = new MediaStream();
// audio-then-video.
pc1.addTransceiver('audio', {streams: [stream]});
pc1.addTransceiver('video', {streams: [stream]});
// video-then-audio
pc1.addTransceiver('video', {streams: [stream2]});
pc1.addTransceiver('audio', {streams: [stream2]});
const tracks = [];
pc2.ontrack = (e) => tracks.push(e.track)

await pc2.setRemoteDescription(await pc1.createOffer());
assert_equals(tracks.length, 4, 'ontrack should have fired twice');
assert_equals(tracks[0].kind, 'audio', 'first ontrack fires with an audio track');
assert_equals(tracks[1].kind, 'video', 'second ontrack fires with a video track');
assert_equals(tracks[2].kind, 'video', 'third ontrack fires with a video track');
assert_equals(tracks[3].kind, 'audio', 'fourth ontrack fires with an audio track');
}, `addTransceiver order of kinds is retained in ontrack at the receiver`);

</script>

0 comments on commit 436123f

Please sign in to comment.