From baa4d372f5ea8ccebd38f5e150849f36bcbe8493 Mon Sep 17 00:00:00 2001 From: Jan-Ivar Bruaroey Date: Fri, 26 May 2023 16:22:48 +0000 Subject: [PATCH] Bug 1528042 - Don't expose number of devices of a kind unless information can be exposed for that kind per https://github.com/w3c/mediacapture-main/pull/900. r=karlt Differential Revision: https://phabricator.services.mozilla.com/D176925 --- dom/media/MediaDevices.cpp | 4 ++-- .../MediaDevices-enumerateDevices.https.html | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/dom/media/MediaDevices.cpp b/dom/media/MediaDevices.cpp index 2cb5d443468f5..8164ec871fd9d 100644 --- a/dom/media/MediaDevices.cpp +++ b/dom/media/MediaDevices.cpp @@ -270,7 +270,7 @@ RefPtr MediaDevices::FilterExposedDevices( if (mCanExposeMicrophoneInfo) { exposedMicrophoneGroupIds.Insert(device->mRawGroupID); } - if (!DeviceInformationCanBeExposed() && !legacy) { + if (!mCanExposeMicrophoneInfo && !legacy) { dropMics = true; } break; @@ -278,7 +278,7 @@ RefPtr MediaDevices::FilterExposedDevices( if (dropCams) { continue; } - if (!DeviceInformationCanBeExposed() && !legacy) { + if (!mCanExposeCameraInfo && !legacy) { dropCams = true; } break; diff --git a/testing/web-platform/tests/mediacapture-streams/MediaDevices-enumerateDevices.https.html b/testing/web-platform/tests/mediacapture-streams/MediaDevices-enumerateDevices.https.html index 1007f053ea2e7..88c07048a1b48 100644 --- a/testing/web-platform/tests/mediacapture-streams/MediaDevices-enumerateDevices.https.html +++ b/testing/web-platform/tests/mediacapture-streams/MediaDevices-enumerateDevices.https.html @@ -71,9 +71,12 @@

Description

const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); stream.getTracks()[0].stop(); const devices = await navigator.mediaDevices.enumerateDevices(); - assert_equals(devices.filter(({kind}) => kind != "audiooutput").length, - devices1.filter(({kind}) => kind != "audiooutput").length, - "same number of input devices"); + assert_equals(devices.filter(({kind}) => kind == "videoinput").length, + devices1.filter(({kind}) => kind == "videoinput").length, + "same number of (previously exposed) videoinput devices"); + assert_greater_than_equal(devices.filter(d => d.kind == "audioinput").length, + devices1.filter(d => d.kind == "audioinput").length, + "same number or more audioinput devices"); const order = ["audioinput", "videoinput", "audiooutput"]; for (const {kind, deviceId} of devices) { assert_in_array(kind, order, "expected kind");