diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/audio-output/setSinkId-with-selectAudioOutput.https.html | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/audio-output/setSinkId-with-selectAudioOutput.https.html')
-rw-r--r-- | testing/web-platform/tests/audio-output/setSinkId-with-selectAudioOutput.https.html | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/testing/web-platform/tests/audio-output/setSinkId-with-selectAudioOutput.https.html b/testing/web-platform/tests/audio-output/setSinkId-with-selectAudioOutput.https.html new file mode 100644 index 0000000000..6847545503 --- /dev/null +++ b/testing/web-platform/tests/audio-output/setSinkId-with-selectAudioOutput.https.html @@ -0,0 +1,54 @@ +<!doctype html> +<head> +<title>Test setSinkId() before and after selectAudioOutput()</title> +<link rel="help" href="https://www.w3.org/TR/audio-output/#dom-htmlmediaelement-setsinkid"> +</head> +<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> +"use strict"; + +let deviceId; +promise_test(async t => { + await test_driver.bless('transient activation for selectAudioOutput()'); + ({deviceId} = await navigator.mediaDevices.selectAudioOutput()); + + const audio = new Audio(); + const p1 = audio.setSinkId(deviceId); + assert_equals(audio.sinkId, "", "before it resolves, setSinkId is unchanged"); + let r = await p1; + assert_equals(r, undefined, "setSinkId resolves with undefined"); + assert_equals(audio.sinkId, deviceId, "when it resolves, setSinkId updates sinkId to the requested deviceId"); + + r = await audio.setSinkId(deviceId); + assert_equals(r, undefined, "resetting sinkid on same current value should always work"); + + r = await audio.setSinkId(""); + assert_equals(r, undefined, "resetting sinkid on default audio output should always work"); +}, "setSinkId() after selectAudioOutput()"); + +// Use the same sinkId in another same-origin top-level browsing context. +// "the identifier MUST be the same in documents of the same origin in +// top-level browsing contexts." +// https://w3c.github.io/mediacapture-main/#dom-mediadeviceinfo-deviceid +promise_test(async t => { + assert_not_equals(deviceId, undefined, "selectAudioOutput() resolved"); + const proxy = window.open('/common/blank.html'); + t.add_cleanup(() => proxy.close()); + await new Promise(r => proxy.onload = r); + const pAudio = new proxy.Audio(); + await promise_rejects_dom(t, "NotFoundError", proxy.DOMException, + pAudio.setSinkId(deviceId), + "before selectAudioOutput()"); + await test_driver.bless('transient activation for selectAudioOutput()', + null, proxy); + const { deviceId: pDeviceId } = + await proxy.navigator.mediaDevices.selectAudioOutput({deviceId}); + assert_equals(pDeviceId, deviceId, + "deviceIds should be same in each browsing context"); + await pAudio.setSinkId(deviceId); + assert_equals(pAudio.sinkId, deviceId, "sinkId after setSinkId()"); +}, "setSinkId() with deviceID from another window"); +</script> |