diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/webrtc/RTCPeerConnection-setRemoteDescription-replaceTrack.https.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webrtc/RTCPeerConnection-setRemoteDescription-replaceTrack.https.html')
-rw-r--r-- | testing/web-platform/tests/webrtc/RTCPeerConnection-setRemoteDescription-replaceTrack.https.html | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webrtc/RTCPeerConnection-setRemoteDescription-replaceTrack.https.html b/testing/web-platform/tests/webrtc/RTCPeerConnection-setRemoteDescription-replaceTrack.https.html new file mode 100644 index 0000000000..217326bfae --- /dev/null +++ b/testing/web-platform/tests/webrtc/RTCPeerConnection-setRemoteDescription-replaceTrack.https.html @@ -0,0 +1,115 @@ +<!doctype html> +<meta charset=utf-8> +<title>RTCPeerConnection.prototype.setRemoteDescription - replaceTrack</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="RTCPeerConnection-helper.js"></script> +<script> + 'use strict'; + + // The following helper functions are called from RTCPeerConnection-helper.js: + // getUserMediaTracksAndStreams + + async_test(t => { + const caller = new RTCPeerConnection(); + t.add_cleanup(() => caller.close()); + getUserMediaTracksAndStreams(2) + .then(t.step_func(([tracks, streams]) => { + const sender = caller.addTrack(tracks[0], streams[0]); + return sender.replaceTrack(tracks[1]) + .then(t.step_func(() => { + assert_equals(sender.track, tracks[1]); + t.done(); + })); + })) + .catch(t.step_func(reason => { + assert_unreached(reason); + })); + }, 'replaceTrack() sets the track attribute to a new track.'); + + async_test(t => { + const caller = new RTCPeerConnection(); + t.add_cleanup(() => caller.close()); + getUserMediaTracksAndStreams(1) + .then(t.step_func(([tracks, streams]) => { + const sender = caller.addTrack(tracks[0], streams[0]); + return sender.replaceTrack(null) + .then(t.step_func(() => { + assert_equals(sender.track, null); + t.done(); + })); + })) + .catch(t.step_func(reason => { + assert_unreached(reason); + })); + }, 'replaceTrack() sets the track attribute to null.'); + + async_test(t => { + const caller = new RTCPeerConnection(); + t.add_cleanup(() => caller.close()); + getUserMediaTracksAndStreams(2) + .then(t.step_func(([tracks, streams]) => { + const sender = caller.addTrack(tracks[0], streams[0]); + assert_equals(sender.track, tracks[0]); + sender.replaceTrack(tracks[1]); + // replaceTrack() is asynchronous, there should be no synchronously + // observable effects. + assert_equals(sender.track, tracks[0]); + t.done(); + })) + .catch(t.step_func(reason => { + assert_unreached(reason); + })); + }, 'replaceTrack() does not set the track synchronously.'); + + async_test(t => { + const expectedException = 'InvalidStateError'; + const caller = new RTCPeerConnection(); + t.add_cleanup(() => caller.close()); + getUserMediaTracksAndStreams(2) + .then(t.step_func(([tracks, streams]) => { + const sender = caller.addTrack(tracks[0], streams[0]); + caller.close(); + return sender.replaceTrack(tracks[1]) + .then(t.step_func(() => { + assert_unreached('Expected replaceTrack() to be rejected with ' + + expectedException + ' but the promise was resolved.'); + }), + t.step_func(e => { + assert_equals(e.name, expectedException); + t.done(); + })); + })) + .catch(t.step_func(reason => { + assert_unreached(reason); + })); + }, 'replaceTrack() rejects when the peer connection is closed.'); + + promise_test(async t => { + const caller = new RTCPeerConnection(); + t.add_cleanup(() => caller.close()); + const [tracks, streams] = await getUserMediaTracksAndStreams(2); + const sender = caller.addTrack(tracks[0], streams[0]); + caller.removeTrack(sender); + await sender.replaceTrack(tracks[1]); + assert_equals(sender.track, tracks[1], "Make sure track gets updated"); + }, 'replaceTrack() does not reject when invoked after removeTrack().'); + + + promise_test(async t => { + const caller = new RTCPeerConnection(); + t.add_cleanup(() => caller.close()); + const [tracks, streams] = await getUserMediaTracksAndStreams(2); + const sender = caller.addTrack(tracks[0], streams[0]); + let p = sender.replaceTrack(tracks[1]) + caller.removeTrack(sender); + await p; + assert_equals(sender.track, tracks[1], "Make sure track gets updated"); + }, 'replaceTrack() does not reject after a subsequent removeTrack().'); + + // TODO(hbos): Verify that replaceTrack() changes what media is received on + // the remote end of two connected peer connections. For video tracks, this + // requires Chromium's video tag to update on receiving frames when running + // content_shell. https://crbug.com/793808 + +</script> |