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/test/test_mediarecorder_multipletracks.html | |
parent | Initial commit. (diff) | |
download | firefox-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/test/test_mediarecorder_multipletracks.html')
-rw-r--r-- | dom/media/test/test_mediarecorder_multipletracks.html | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/dom/media/test/test_mediarecorder_multipletracks.html b/dom/media/test/test_mediarecorder_multipletracks.html new file mode 100644 index 0000000000..40fbfb92ce --- /dev/null +++ b/dom/media/test/test_mediarecorder_multipletracks.html @@ -0,0 +1,68 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test that MediaRecorder fires an error event when started with >1 track of a kind</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <script src="/tests/dom/media/webrtc/tests/mochitests/head.js"></script> +</head> +<body> +<script class="testbody"> +"use strict"; + +(async () => { + SimpleTest.waitForExplicitFinish(); + SimpleTest.requestFlakyTimeout("Failure timeouts"); + + try { + const stream = new MediaStream; + const recorder = new MediaRecorder(stream); + + { + info("Testing with two audio tracks"); + const ac = new AudioContext; + const track = ac.createMediaStreamDestination().stream.getTracks()[0]; + stream.addTrack(track); + stream.addTrack(track.clone()); + mustThrowWith("Starting with multiple audio tracks", + "NotSupportedError", + () => recorder.start()); + await Promise.all([ + haveNoEvent(recorder, "start"), + haveNoEvent(recorder, "error"), + haveNoEvent(recorder, "stop"), + ]); + for (let t of stream.getTracks()) { + stream.removeTrack(t); + t.stop(); + } + } + + { + info("Testing with two video tracks"); + const canvas = document.createElement("canvas"); + canvas.getContext("2d"); + const track = canvas.captureStream().getTracks()[0]; + stream.addTrack(track); + stream.addTrack(track.clone()); + mustThrowWith("Starting with multiple video tracks", + "NotSupportedError", + () => recorder.start()); + await Promise.all([ + haveNoEvent(recorder, "start"), + haveNoEvent(recorder, "error"), + haveNoEvent(recorder, "stop"), + ]); + for (let t of stream.getTracks()) { + stream.removeTrack(t); + t.stop(); + } + } + } catch(e) { + ok(false, `${e}\n${e.stack}`); + } finally { + SimpleTest.finish(); + } +})(); +</script> +</body> +</html> |