diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-end-manual.https.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-end-manual.https.html')
-rw-r--r-- | testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-end-manual.https.html | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-end-manual.https.html b/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-end-manual.https.html new file mode 100644 index 0000000000..58e484d484 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-end-manual.https.html @@ -0,0 +1,54 @@ +<!doctype html> +<html> +<head> +<title>Test that mediastreamtrack are properly ended</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://w3c.github.io/mediacapture-main/getusermedia.html#mediastreamtrack"> +</head> +<body> +<p class="instructions">When prompted, accept to share your video and audio +stream, and then revoke that permission.</p> +<h1 class="instructions">Description</h1> +<p class="instructions">This test checks that the video and audio tracks of +MediaStream object returned by the success callback in getUserMedia are +correctly set into inactive state when permission is revoked.</p> + +<div id='log'></div> +<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> +'use strict'; +promise_test(async t => { + await setMediaPermission(); + const stream = await navigator.mediaDevices.getUserMedia({ + audio: true, + video: true, + }); + + const vidTrack = stream.getVideoTracks()[0]; + assert_equals(vidTrack.readyState, "live", + "The video track object is in live state"); + const vidEnded = new Promise(r => vidTrack.onended = r); + const audTrack = stream.getAudioTracks()[0]; + assert_equals(audTrack.readyState, "live", + "The audio track object is in live state"); + const audEnded = new Promise(r => audTrack.onended = r); + + await Promise.race([vidEnded, audEnded]); + assert_equals(stream.getTracks().filter(t => t.readyState == "ended").length, + 1, "Only one track is ended after first track's ended event"); + assert_equals(stream.getTracks().filter(t => t.readyState == "live").length, + 1, "One track is still live after first track's ended event"); + assert_true(stream.active, "MediaStream is still active"); + + await Promise.all([vidEnded, audEnded]); + assert_equals(vidTrack.readyState, "ended", "Video track ended as expected"); + assert_equals(audTrack.readyState, "ended", "Audio track ended as expected"); + assert_false(stream.active, "MediaStream has become inactive as expected"); +}, "Tests that MediaStreamTracks end properly on permission revocation"); +</script> +</body> +</html> |