summaryrefslogtreecommitdiffstats
path: root/dom/media/webrtc/tests/mochitests/test_peerConnection_verifyVideoAfterRenegotiation.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/media/webrtc/tests/mochitests/test_peerConnection_verifyVideoAfterRenegotiation.html
parentInitial commit. (diff)
downloadfirefox-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_verifyVideoAfterRenegotiation.html')
-rw-r--r--dom/media/webrtc/tests/mochitests/test_peerConnection_verifyVideoAfterRenegotiation.html123
1 files changed, 123 insertions, 0 deletions
diff --git a/dom/media/webrtc/tests/mochitests/test_peerConnection_verifyVideoAfterRenegotiation.html b/dom/media/webrtc/tests/mochitests/test_peerConnection_verifyVideoAfterRenegotiation.html
new file mode 100644
index 0000000000..8d4155ddff
--- /dev/null
+++ b/dom/media/webrtc/tests/mochitests/test_peerConnection_verifyVideoAfterRenegotiation.html
@@ -0,0 +1,123 @@
+<!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>
+</head>
+<body>
+<pre id="test">
+<script type="application/javascript">
+ createHTML({
+ bug: "1166832",
+ title: "Renegotiation: verify video after renegotiation"
+ });
+
+runNetworkTest(async () => {
+ // [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 test = new PeerConnectionTest();
+
+ const h1 = new CaptureStreamTestHelper2D(50, 50);
+ const canvas1 = h1.createAndAppendElement('canvas', 'source_canvas1');
+ let stream1;
+ let vremote1;
+
+ const h2 = new CaptureStreamTestHelper2D(50, 50);
+ let canvas2;
+ let stream2;
+ let vremote2;
+
+ test.setMediaConstraints([{video: true}], []);
+ test.chain.replace("PC_LOCAL_GUM", [
+ function DRAW_INITIAL_LOCAL_GREEN(test) {
+ h1.drawColor(canvas1, h1.green);
+ },
+ function PC_LOCAL_CANVAS_CAPTURESTREAM(test) {
+ stream1 = canvas1.captureStream(0);
+ test.pcLocal.attachLocalStream(stream1);
+ let i = 0;
+ return setInterval(function() {
+ try {
+ info("draw " + i ? "green" : "red");
+ h1.drawColor(canvas1, i ? h1.green : h1.red);
+ i = 1 - i;
+ stream1.requestFrame();
+ if (stream2 != null) {
+ h2.drawColor(canvas2, i ? h2.green : h2.blue);
+ stream2.requestFrame();
+ }
+ } catch (e) {
+ // ignore; stream might have shut down, and we don't bother clearing
+ // the setInterval.
+ }
+ }, 500);
+ }
+ ]);
+
+ test.chain.append([
+ function FIND_REMOTE_VIDEO() {
+ vremote1 = test.pcRemote.remoteMediaElements[0];
+ ok(!!vremote1, "Should have remote video element for pcRemote");
+ },
+ function WAIT_FOR_REMOTE_GREEN() {
+ return h1.pixelMustBecome(vremote1, h1.green, {
+ threshold: 128,
+ infoString: "pcRemote's remote should become green",
+ });
+ },
+ function WAIT_FOR_REMOTE_RED() {
+ return h1.pixelMustBecome(vremote1, h1.red, {
+ threshold: 128,
+ infoString: "pcRemote's remote should become red",
+ });
+ }
+ ]);
+
+ addRenegotiation(test.chain,
+ [
+ function PC_LOCAL_ADD_SECOND_STREAM(test) {
+ canvas2 = h2.createAndAppendElement('canvas', 'source_canvas2');
+ h2.drawColor(canvas2, h2.blue);
+ stream2 = canvas2.captureStream(0);
+
+ // can't use test.pcLocal.getAllUserMediaAndAddStreams([{video: true}]);
+ // because it doesn't let us substitute the capture stream
+ test.pcLocal.attachLocalStream(stream2);
+ }
+ ]
+ );
+
+ test.chain.append([
+ function FIND_REMOTE2_VIDEO() {
+ vremote2 = test.pcRemote.remoteMediaElements[1];
+ ok(!!vremote2, "Should have remote2 video element for pcRemote");
+ },
+ function WAIT_FOR_REMOTE2_BLUE() {
+ return h2.pixelMustBecome(vremote2, h2.blue, {
+ threshold: 128,
+ infoString: "pcRemote's remote2 should become blue",
+ });
+ },
+ function DRAW_NEW_LOCAL_GREEN(test) {
+ stream1.requestFrame();
+ h1.drawColor(canvas1, h1.green);
+ },
+ function WAIT_FOR_REMOTE1_GREEN() {
+ return h1.pixelMustBecome(vremote1, h1.green, {
+ threshold: 128,
+ infoString: "pcRemote's remote1 should become green",
+ });
+ }
+ ]);
+
+ await test.run();
+});
+
+</script>
+</pre>
+</body>
+</html>