diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /dom/media/webrtc/tests/mochitests/test_setSinkId_default_addTrack.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/webrtc/tests/mochitests/test_setSinkId_default_addTrack.html')
-rw-r--r-- | dom/media/webrtc/tests/mochitests/test_setSinkId_default_addTrack.html | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/dom/media/webrtc/tests/mochitests/test_setSinkId_default_addTrack.html b/dom/media/webrtc/tests/mochitests/test_setSinkId_default_addTrack.html new file mode 100644 index 0000000000..64db4cad7c --- /dev/null +++ b/dom/media/webrtc/tests/mochitests/test_setSinkId_default_addTrack.html @@ -0,0 +1,52 @@ +<!DOCTYPE HTML> +<html> +<head> + <script type="application/javascript" src="mediaStreamPlayback.js"></script> +</head> +<body> +<pre id="test"> + +<script> + createHTML({ + title: "HTMLMediaElement.setSinkId with default device and adding a track", + bug: "1661649", + }); + + /** + * Run a test to verify set sink id in audio element. + */ + runTest(async () => { + await pushPrefs(["media.setsinkid.enabled", true]); + + // Expose an audio output device. + SpecialPowers.wrap(document).notifyUserGestureActivation(); + await navigator.mediaDevices.selectAudioOutput(); + + const allDevices = await navigator.mediaDevices.enumerateDevices(); + const audioDevices = allDevices.filter(({kind}) => kind == 'audiooutput'); + info(`Found ${audioDevices.length} output devices`); + isnot(audioDevices.length, 0, "Found output devices"); + + const audio = createMediaElement("audio", "audio"); + document.body.appendChild(audio); + + audio.srcObject = await navigator.mediaDevices.getUserMedia({audio: true}); + audio.play(); + + await audio.setSinkId(audioDevices[0].deviceId); + await audio.setSinkId(""); + is(audio.sinkId, "", "sinkId restored to default"); + + audio.srcObject.addTrack((await navigator.mediaDevices.getUserMedia({audio: true})).getTracks()[0]); + + await wait(0); + + for (let t of audio.srcObject.getTracks()) { + t.stop(); + } + }); + +</script> +</pre> +</body> +</html> |