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 /dom/media/webrtc/tests/mochitests/test_peerConnection_constructedStream.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 'dom/media/webrtc/tests/mochitests/test_peerConnection_constructedStream.html')
-rw-r--r-- | dom/media/webrtc/tests/mochitests/test_peerConnection_constructedStream.html | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/dom/media/webrtc/tests/mochitests/test_peerConnection_constructedStream.html b/dom/media/webrtc/tests/mochitests/test_peerConnection_constructedStream.html new file mode 100644 index 0000000000..8431b7534e --- /dev/null +++ b/dom/media/webrtc/tests/mochitests/test_peerConnection_constructedStream.html @@ -0,0 +1,67 @@ +<!DOCTYPE HTML> +<html> +<head> + <script type="application/javascript" src="pc.js"></script> +</head> +<body> +<pre id="test"> +<script type="application/javascript"> +createHTML({ + bug: "1271669", + title: "Test that pc.addTrack() accepts any MediaStream", + visible: true +}); + +runNetworkTest(() => { + var test = new PeerConnectionTest(); + var constructedStream; + var dummyStream = new MediaStream(); + var dummyStreamTracks = []; + + test.setMediaConstraints([ {audio: true, video: true} + , {audio: true} + , {video: true} + ], []); + test.chain.replace("PC_LOCAL_GUM", [ + function PC_LOCAL_GUM_CONSTRUCTED_STREAM(test) { + return getUserMedia(test.pcLocal.constraints[0]).then(stream => { + constructedStream = new MediaStream(stream.getTracks()); + test.pcLocal.attachLocalStream(constructedStream); + }); + }, + function PC_LOCAL_GUM_DUMMY_STREAM(test) { + return getUserMedia(test.pcLocal.constraints[1]) + .then(stream => dummyStreamTracks.push(...stream.getTracks())) + .then(() => getUserMedia(test.pcLocal.constraints[2])) + .then(stream => dummyStreamTracks.push(...stream.getTracks())) + .then(() => dummyStreamTracks.forEach(t => + test.pcLocal.attachLocalTrack(t, dummyStream))); + }, + ]); + + let checkSentTracksReceived = (sentStreamId, sentTracks) => { + let receivedStream = + test.pcRemote._pc.getRemoteStreams().find(s => s.id == sentStreamId); + ok(receivedStream, "We should receive a stream with with the sent stream's id (" + sentStreamId + ")"); + if (!receivedStream) { + return; + } + + is(receivedStream.getTracks().length, sentTracks.length, + "Should receive same number of tracks as were sent"); + }; + + test.chain.append([ + function PC_REMOTE_CHECK_RECEIVED_CONSTRUCTED_STREAM() { + checkSentTracksReceived(constructedStream.id, constructedStream.getTracks()); + }, + function PC_REMOTE_CHECK_RECEIVED_DUMMY_STREAM() { + checkSentTracksReceived(dummyStream.id, dummyStreamTracks); + }, + ]); + return test.run(); +}); +</script> +</pre> +</body> +</html> |