summaryrefslogtreecommitdiffstats
path: root/dom/media/webrtc/tests/mochitests/test_peerConnection_capturedVideo.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_capturedVideo.html
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/webrtc/tests/mochitests/test_peerConnection_capturedVideo.html')
-rw-r--r--dom/media/webrtc/tests/mochitests/test_peerConnection_capturedVideo.html81
1 files changed, 81 insertions, 0 deletions
diff --git a/dom/media/webrtc/tests/mochitests/test_peerConnection_capturedVideo.html b/dom/media/webrtc/tests/mochitests/test_peerConnection_capturedVideo.html
new file mode 100644
index 0000000000..f6f48ba429
--- /dev/null
+++ b/dom/media/webrtc/tests/mochitests/test_peerConnection_capturedVideo.html
@@ -0,0 +1,81 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <script src="pc.js"></script>
+ <script src="../../../test/manifest.js"></script>
+</head>
+<body>
+<pre id="test">
+<script type="application/javascript">
+(async () => {
+ await createHTML({
+ bug: "1081409",
+ title: "Captured video-only over peer connection",
+ visible: true
+ });
+
+ // Run tests in sequence for log readability.
+ PARALLEL_TESTS = 1;
+ const manager = new MediaTestManager;
+
+ async function startTest(media, token) {
+ manager.started(token);
+ info(`Starting test for ${media.name}`);
+ const video = document.createElement('video');
+ video.id = "id_" + media.name;
+ video.width = 160;
+ video.height = 120;
+ video.muted = true;
+ video.controls = true;
+ video.preload = "metadata";
+ video.src = "../../../test/" + media.name;
+
+ document.getElementById("content").appendChild(video);
+
+ const onerror = new Promise(r => video.onerror = r).then(_ =>
+ new Error(`${media.name} failed in playback. code=${video.error.code}`));
+
+ await Promise.race([
+ new Promise(res => video.onloadedmetadata = res),
+ onerror,
+ ]);
+ onerror.catch(e => ok(false, e));
+ setupEnvironment();
+ await testConfigured;
+ const stream = video.mozCaptureStream();
+ const test = new PeerConnectionTest(
+ {
+ config_local: { label_suffix: media.name },
+ config_remote: { label_suffix: media.name },
+ }
+ );
+ test.setOfferOptions(
+ {
+ offerToReceiveVideo: false,
+ offerToReceiveAudio: false,
+ }
+ );
+ const hasVideo = !!stream.getVideoTracks().length;
+ const hasAudio = !!stream.getAudioTracks().length;
+ test.setMediaConstraints([{ video: hasVideo, audio: hasAudio }], []);
+ test.chain.replace("PC_LOCAL_GUM", [
+ function PC_LOCAL_CAPTUREVIDEO(test) {
+ test.pcLocal.attachLocalStream(stream);
+ },
+ ]);
+ test.chain.insertBefore("PC_LOCAL_WAIT_FOR_MEDIA_FLOW", [
+ function PC_LOCAL_START_MEDIA(test) {
+ video.play();
+ },
+ ]);
+ await test.run();
+ removeNodeAndSource(video);
+ manager.finished(token);
+ }
+
+ manager.runTests(getPlayableVideos(gLongerTests), startTest);
+})();
+</script>
+</pre>
+</body>
+</html>