Bug 1528042 - Add media.devices.enumerate.legacy.enabled pref. r=karlt

For now legacy is enabled.

Differential Revision: https://phabricator.services.mozilla.com/D154139
This commit is contained in:
Jan-Ivar Bruaroey 2023-05-26 16:22:47 +00:00
Родитель 09ba959819
Коммит 2ec8f9b719
5 изменённых файлов: 32 добавлений и 14 удалений

Просмотреть файл

@ -238,6 +238,7 @@ RefPtr<MediaDeviceSetRefCnt> MediaDevices::FilterExposedDevices(
// they are exposed only when explicitly and individually allowed by the
// user.
}
bool legacy = StaticPrefs::media_devices_enumerate_legacy_enabled();
bool outputIsDefault = true; // First output is the default.
bool haveDefaultOutput = false;
nsTHashSet<nsString> exposedMicrophoneGroupIds;
@ -250,7 +251,7 @@ RefPtr<MediaDeviceSetRefCnt> MediaDevices::FilterExposedDevices(
if (mCanExposeMicrophoneInfo) {
exposedMicrophoneGroupIds.Insert(device->mRawGroupID);
}
if (!DeviceInformationCanBeExposed()) {
if (!DeviceInformationCanBeExposed() && !legacy) {
dropMics = true;
}
break;
@ -258,7 +259,7 @@ RefPtr<MediaDeviceSetRefCnt> MediaDevices::FilterExposedDevices(
if (dropCams) {
continue;
}
if (!DeviceInformationCanBeExposed()) {
if (!DeviceInformationCanBeExposed() && !legacy) {
dropCams = true;
}
break;
@ -406,15 +407,15 @@ void MediaDevices::ResumeEnumerateDevices(
void MediaDevices::ResolveEnumerateDevicesPromise(
Promise* aPromise, const LocalMediaDeviceSet& aDevices) const {
nsTArray<RefPtr<MediaDeviceInfo>> infos;
bool legacy = StaticPrefs::media_devices_enumerate_legacy_enabled();
for (const RefPtr<LocalMediaDevice>& device : aDevices) {
MOZ_ASSERT(device->Kind() < MediaDeviceKind::EndGuard_);
bool canExposeInfo = CanExposeInfo(device->Kind());
bool exposeInfo = CanExposeInfo(device->Kind()) || legacy;
bool exposeLabel = legacy ? DeviceInformationCanBeExposed() : exposeInfo;
infos.AppendElement(MakeRefPtr<MediaDeviceInfo>(
canExposeInfo ? device->mID : u""_ns, device->Kind(),
canExposeInfo ? device->mName : u""_ns,
canExposeInfo ? device->mGroupID : u""_ns));
exposeInfo ? device->mID : u""_ns, device->Kind(),
exposeLabel ? device->mName : u""_ns,
exposeInfo ? device->mGroupID : u""_ns));
}
aPromise->MaybeResolve(std::move(infos));
}

Просмотреть файл

@ -10770,6 +10770,23 @@
value: true
mirror: once
# This pref turns on legacy (non-spec) exposure of camera and microphone
# information from enumerateDevices and devicechange ahead of successful
# getUserMedia calls. Should only be turned on to resolve web compat issues,
# since doing so reveals more user fingerprinting information to trackers.
#
# This mode is marginally more permissive than the legacy behavior it attempts
# to emulate in that device labels do not disappear when tracks are stopped and
# temporary permission expires. That behavior isn't emulated due to low relative
# privacy value compared to spec and it not being being conducive to spec
# convergence.
#
# Planned next steps: true → @IS_NOT_NIGHTLY_BUILD@ → false
- name: media.devices.enumerate.legacy.enabled
type: bool
value: true
mirror: always
# WebRTC prefs follow
# Enables RTCPeerConnection support. Note that, when true, this pref enables

Просмотреть файл

@ -1 +1 @@
prefs: [media.navigator.permission.disabled:true, media.setsinkid.enabled:true]
prefs: [media.navigator.permission.disabled:true, media.setsinkid.enabled:true, media.devices.enumerate.legacy.enabled:false]

Просмотреть файл

@ -1,2 +1,2 @@
prefs: [media.navigator.permission.disabled:true, media.navigator.streams.fake:true, dom.security.featurePolicy.header.enabled:true, dom.security.featurePolicy.webidl.enabled:true]
prefs: [media.navigator.permission.disabled:true, media.navigator.streams.fake:true, dom.security.featurePolicy.header.enabled:true, dom.security.featurePolicy.webidl.enabled:true,media.devices.enumerate.legacy.enabled:false]
lsan-allowed: [NewSegment, mozilla::layers::BufferTextureData::CreateInternal]

Просмотреть файл

@ -40,9 +40,9 @@ promise_test(async () => {
const outputDevices = devices.filter(info => info.kind == "audiooutput");
assert_equals(outputDevices.length, 1, "number of audiooutput devices.");
assert_not_equals(selected, undefined);
const info = outputDevices[0];
assert_equals(info.deviceId, selected.deviceId);
assert_equals(info.groupId, selected.groupId);
assert_equals(info.label, selected.label);
const [info] = outputDevices;
assert_equals(info.deviceId, selected.deviceId, "deviceId exposed");
assert_equals(info.groupId, selected.groupId, "groupId exposed");
assert_equals(info.label, selected.label, "label exposed");
}, "enumerateDevices() after selectAudioOutput()");
</script>