diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/mediacapture-streams/MediaStream-clone.https.html | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/mediacapture-streams/MediaStream-clone.https.html')
-rw-r--r-- | testing/web-platform/tests/mediacapture-streams/MediaStream-clone.https.html | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/testing/web-platform/tests/mediacapture-streams/MediaStream-clone.https.html b/testing/web-platform/tests/mediacapture-streams/MediaStream-clone.https.html new file mode 100644 index 0000000000..0fe6f3498b --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaStream-clone.https.html @@ -0,0 +1,98 @@ +<!doctype html> +<html> +<head> +<title>MediaStream and MediaStreamTrack clone()</title> +<link rel="help" href="https://w3c.github.io/mediacapture-main/#dom-mediastream-clone"> +<link rel="help" href="https://w3c.github.io/mediacapture-main/#dom-mediastreamtrack-clone"> +</head> +<body> +<p class="instructions">When prompted, accept to give permission to use your audio and video devices.</p> +<h1 class="instructions">Description</h1> +<p class="instructions">This test checks that cloning MediaStreams and MediaStreamTracks works as expected.</p> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src=/resources/testdriver.js></script> +<script src=/resources/testdriver-vendor.js></script> +<script src=permission-helper.js></script> +<script> + +promise_test(async t => { + await setMediaPermission(); + const stream = await navigator.mediaDevices.getUserMedia({video: true, audio: true}); + assert_equals(stream.getAudioTracks().length, 1); + assert_equals(stream.getVideoTracks().length, 1); + + const clone1 = stream.clone(); + assert_equals(clone1.getAudioTracks().length, 1); + assert_equals(clone1.getVideoTracks().length, 1); + assert_not_equals(stream.getAudioTracks()[0].id, clone1.getAudioTracks()[0].id); + assert_not_equals(stream.getVideoTracks()[0].id, clone1.getVideoTracks()[0].id); + + stream.getTracks().forEach(track => track.stop()); + assert_false(stream.active); + assert_equals(stream.getAudioTracks()[0].readyState, "ended"); + assert_equals(stream.getVideoTracks()[0].readyState, "ended"); + assert_true(clone1.active); + assert_equals(clone1.getAudioTracks()[0].readyState, "live"); + assert_equals(clone1.getVideoTracks()[0].readyState, "live"); + + clone1.getAudioTracks()[0].stop(); + assert_true(clone1.active); + assert_equals(clone1.getAudioTracks()[0].readyState, "ended"); + assert_equals(clone1.getVideoTracks()[0].readyState, "live"); + + const clone2 = clone1.clone(); + assert_true(clone2.active); + assert_equals(clone2.getAudioTracks()[0].readyState, "ended"); + assert_equals(clone2.getVideoTracks()[0].readyState, "live"); + + clone1.getVideoTracks()[0].stop(); + clone2.getVideoTracks()[0].stop(); + + const clone3 = clone2.clone(); + assert_false(clone3.active); + assert_equals(clone3.getAudioTracks()[0].readyState, "ended"); + assert_equals(clone3.getVideoTracks()[0].readyState, "ended"); + assert_not_equals(clone1.getAudioTracks()[0].id, clone2.getAudioTracks()[0].id); + assert_not_equals(clone1.getVideoTracks()[0].id, clone2.getVideoTracks()[0].id); + assert_not_equals(clone2.getAudioTracks()[0].id, clone3.getAudioTracks()[0].id); + assert_not_equals(clone2.getVideoTracks()[0].id, clone3.getVideoTracks()[0].id); + assert_not_equals(clone1.getAudioTracks()[0].id, clone3.getAudioTracks()[0].id); + assert_not_equals(clone1.getVideoTracks()[0].id, clone3.getVideoTracks()[0].id); +}, "Tests that cloning MediaStream objects works as expected"); + +promise_test(async t => { + const stream = await navigator.mediaDevices.getUserMedia({video: true, audio: true}); + assert_equals(stream.getAudioTracks().length, 1); + assert_equals(stream.getVideoTracks().length, 1); + assert_equals(stream.getAudioTracks()[0].readyState, "live"); + assert_equals(stream.getVideoTracks()[0].readyState, "live"); + assert_true(stream.active); + + const audio_clone = stream.getAudioTracks()[0].clone(); + const video_clone = stream.getVideoTracks()[0].clone(); + assert_equals(audio_clone.readyState, "live"); + assert_equals(video_clone.readyState, "live"); + assert_not_equals(stream.getAudioTracks()[0].id, audio_clone.id); + assert_not_equals(stream.getVideoTracks()[0].id, video_clone.id); + + stream.getTracks().forEach(track => track.stop()); + assert_false(stream.active); + assert_equals(stream.getAudioTracks()[0].readyState, "ended"); + assert_equals(stream.getVideoTracks()[0].readyState, "ended"); + assert_equals(audio_clone.readyState, "live"); + assert_equals(video_clone.readyState, "live"); + + stream.addTrack(audio_clone); + stream.addTrack(video_clone); + assert_true(stream.active); + + stream.getTracks().forEach(track => track.stop()); + assert_false(stream.active); + assert_equals(audio_clone.readyState, "ended"); + assert_equals(video_clone.readyState, "ended"); +}, "Tests that cloning MediaStreamTrack objects works as expected"); + +</script> +</body> +</html> |