blob: 7f102fa5cb55f9c70a019760ae89bb515410454b [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test passing capture device IDs to getUserMedia</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
function deviceFromLabel(devices, label)
{
for (let device of devices) {
if (device.label === label)
return device;
}
}
promise_test(async (test) => {
const devices = await navigator.mediaDevices.enumerateDevices();
devices.forEach((device) => {
assert_not_equals(device.kind, "audiooutput", "device.kind");
});
}, "Before gum, no audiooutput is exposed");
promise_test(async (test) => {
await navigator.mediaDevices.getUserMedia({ audio:true, video:true })
const devices = await navigator.mediaDevices.enumerateDevices();
assert_true(devices.length > 2, "after getting permission, more than 1 camera and 1 microphone are exposed");
devices.forEach((device) => {
assert_not_equals(device.deviceId.length == 0 , "device.deviceId is empty before permission to capture");
});
if (!window.internals)
return;
const mic1 = deviceFromLabel(devices, "Mock audio device 1");
const mic2 = deviceFromLabel(devices, "Mock audio device 2");
const speaker1 = deviceFromLabel(devices, "Mock speaker device 1");
const speaker2 = deviceFromLabel(devices, "Mock speaker device 2");
const speaker3 = deviceFromLabel(devices, "Mock speaker device 3");
assert_equals(speaker1.kind, "audiooutput", "speaker1");
assert_not_equals(speaker1.groupId, "", "speaker1 groupId");
assert_equals(speaker2.kind, "audiooutput", "speaker2");
assert_not_equals(speaker2.groupId, "", "speaker2 groupId");
assert_equals(speaker3, undefined, "speaker3");
assert_equals(speaker1.groupId, mic1.groupId, "device 1");
assert_equals(speaker2.groupId, mic2.groupId, "device 2");
}, "audiooutput devices");
</script>
</head>
<body>
</body>
</html>