summaryrefslogtreecommitdiffstats
path: root/dom/media/webrtc/tests/mochitests/test_peerConnection_replaceNullTrackThenRenegotiateVideo.html
diff options
context:
space:
mode:
Diffstat (limited to 'dom/media/webrtc/tests/mochitests/test_peerConnection_replaceNullTrackThenRenegotiateVideo.html')
-rw-r--r--dom/media/webrtc/tests/mochitests/test_peerConnection_replaceNullTrackThenRenegotiateVideo.html63
1 files changed, 63 insertions, 0 deletions
diff --git a/dom/media/webrtc/tests/mochitests/test_peerConnection_replaceNullTrackThenRenegotiateVideo.html b/dom/media/webrtc/tests/mochitests/test_peerConnection_replaceNullTrackThenRenegotiateVideo.html
new file mode 100644
index 0000000000..d7bd6d8a37
--- /dev/null
+++ b/dom/media/webrtc/tests/mochitests/test_peerConnection_replaceNullTrackThenRenegotiateVideo.html
@@ -0,0 +1,63 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <script type="application/javascript" src="pc.js"></script>
+ <script type="application/javascript" src="/tests/dom/canvas/test/captureStream_common.js"></script>
+ <script type="application/javascript" src="simulcast.js"></script></head>
+<body>
+<pre id="test">
+<script type="application/javascript">
+ createHTML({
+ bug: "1763832",
+ title: "Renegotiation (video): Start with no track and recvonly, then replace and set direction to sendrecv, then renegotiate"
+ });
+
+ runNetworkTest(async () => {
+ await pushPrefs(
+ ['media.video_loopback_dev', ''],
+ ['media.navigator.streams.fake', true]);
+ // [TODO] re-enable HW decoder after bug 1526207 is fixed.
+ if (navigator.userAgent.includes("Android")) {
+ await pushPrefs(["media.navigator.mediadatadecoder_vpx_enabled", false],
+ ["media.webrtc.hw.h264.enabled", false]);
+ }
+
+ const offerer = new RTCPeerConnection();
+ const answerer = new RTCPeerConnection();
+ const transceiverSend = offerer.addTransceiver('video', {direction: 'recvonly'});
+
+ const add = (pc, can, failed) => can && pc.addIceCandidate(can).catch(failed);
+ offerer.onicecandidate = e => add(answerer, e.candidate, generateErrorCallback());
+ answerer.onicecandidate = e => add(offerer, e.candidate, generateErrorCallback());
+
+ await offerer.setLocalDescription();
+ await answerer.setRemoteDescription(offerer.localDescription);
+ await answerer.setLocalDescription();
+ await offerer.setRemoteDescription(answerer.localDescription);
+
+ // add video with replaceTrack, set send bit, and renegotiate
+ const stream = await navigator.mediaDevices.getUserMedia({video: true});
+ const [track] = stream.getVideoTracks();
+ transceiverSend.sender.replaceTrack(track);
+ transceiverSend.direction = "sendrecv";
+ const metadataToBeLoaded = [];
+ answerer.ontrack = (e) => {
+ metadataToBeLoaded.push(getPlaybackWithLoadedMetadata(e.track));
+ };
+
+ await offerer.setLocalDescription();
+ await answerer.setRemoteDescription(offerer.localDescription);
+ await answerer.setLocalDescription();
+ await offerer.setRemoteDescription(answerer.localDescription);
+
+ const elems = await Promise.all(metadataToBeLoaded);
+ is(elems.length, 1, "Should have one video element");
+
+ const helper = new VideoStreamHelper();
+ await helper.checkVideoPlaying(elems[0]);
+ });
+
+</script>
+</pre>
+</body>
+</html>