зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1548087) for wpt failures at audio-output/setSinkId.https.html on a CLOSED TREE
Backed out changeset 6f9782261d63 (bug 1548087) Backed out changeset 044e224f7011 (bug 1548087)
This commit is contained in:
Родитель
95fc013b8b
Коммит
5f190b63ff
|
@ -142,10 +142,6 @@ already_AddRefed<Promise> MediaDevices::EnumerateDevices(CallerType aCallerType,
|
||||||
}
|
}
|
||||||
auto windowId = window->WindowID();
|
auto windowId = window->WindowID();
|
||||||
nsTArray<RefPtr<MediaDeviceInfo>> infos;
|
nsTArray<RefPtr<MediaDeviceInfo>> infos;
|
||||||
bool allowLabel =
|
|
||||||
aDevices->Length() == 0 ||
|
|
||||||
MediaManager::Get()->IsActivelyCapturingOrHasAPermission(
|
|
||||||
windowId);
|
|
||||||
for (auto& device : *aDevices) {
|
for (auto& device : *aDevices) {
|
||||||
MOZ_ASSERT(device->mKind == dom::MediaDeviceKind::Audioinput ||
|
MOZ_ASSERT(device->mKind == dom::MediaDeviceKind::Audioinput ||
|
||||||
device->mKind == dom::MediaDeviceKind::Videoinput ||
|
device->mKind == dom::MediaDeviceKind::Videoinput ||
|
||||||
|
@ -153,7 +149,8 @@ already_AddRefed<Promise> MediaDevices::EnumerateDevices(CallerType aCallerType,
|
||||||
// Include name only if page currently has a gUM stream active
|
// Include name only if page currently has a gUM stream active
|
||||||
// or persistent permissions (audio or video) have been granted
|
// or persistent permissions (audio or video) have been granted
|
||||||
nsString label;
|
nsString label;
|
||||||
if (allowLabel ||
|
if (MediaManager::Get()->IsActivelyCapturingOrHasAPermission(
|
||||||
|
windowId) ||
|
||||||
Preferences::GetBool("media.navigator.permission.disabled",
|
Preferences::GetBool("media.navigator.permission.disabled",
|
||||||
false)) {
|
false)) {
|
||||||
label = device->mName;
|
label = device->mName;
|
||||||
|
|
|
@ -3161,10 +3161,8 @@ RefPtr<MediaManager::DevicesPromise> MediaManager::EnumerateDevices(
|
||||||
__func__);
|
__func__);
|
||||||
}
|
}
|
||||||
uint64_t windowId = aWindow->WindowID();
|
uint64_t windowId = aWindow->WindowID();
|
||||||
Document* doc = aWindow->GetExtantDoc();
|
|
||||||
MOZ_ASSERT(doc);
|
|
||||||
|
|
||||||
nsIPrincipal* principal = doc->NodePrincipal();
|
nsIPrincipal* principal = aWindow->GetExtantDoc()->NodePrincipal();
|
||||||
|
|
||||||
RefPtr<GetUserMediaWindowListener> windowListener =
|
RefPtr<GetUserMediaWindowListener> windowListener =
|
||||||
GetWindowListener(windowId);
|
GetWindowListener(windowId);
|
||||||
|
@ -3185,30 +3183,8 @@ RefPtr<MediaManager::DevicesPromise> MediaManager::EnumerateDevices(
|
||||||
|
|
||||||
DeviceEnumerationType videoEnumerationType = DeviceEnumerationType::Normal;
|
DeviceEnumerationType videoEnumerationType = DeviceEnumerationType::Normal;
|
||||||
DeviceEnumerationType audioEnumerationType = DeviceEnumerationType::Normal;
|
DeviceEnumerationType audioEnumerationType = DeviceEnumerationType::Normal;
|
||||||
|
|
||||||
// Only expose devices which are allowed to use:
|
|
||||||
// https://w3c.github.io/mediacapture-main/#dom-mediadevices-enumeratedevices
|
|
||||||
MediaSourceEnum videoType = dom::FeaturePolicyUtils::IsFeatureAllowed(
|
|
||||||
doc, NS_LITERAL_STRING("camera"))
|
|
||||||
? MediaSourceEnum::Camera
|
|
||||||
: MediaSourceEnum::Other;
|
|
||||||
MediaSourceEnum audioType = dom::FeaturePolicyUtils::IsFeatureAllowed(
|
|
||||||
doc, NS_LITERAL_STRING("microphone"))
|
|
||||||
? MediaSourceEnum::Microphone
|
|
||||||
: MediaSourceEnum::Other;
|
|
||||||
|
|
||||||
auto devices = MakeRefPtr<MediaDeviceSetRefCnt>();
|
|
||||||
MediaSinkEnum audioOutputType = MediaSinkEnum::Other;
|
|
||||||
// TODO bug Bug 1577199 we don't seem to support the "speaker" feature policy
|
|
||||||
// yet.
|
|
||||||
if (Preferences::GetBool("media.setsinkid.enabled")) {
|
|
||||||
audioOutputType = MediaSinkEnum::Speaker;
|
|
||||||
} else if (audioType == MediaSourceEnum::Other &&
|
|
||||||
videoType == MediaSourceEnum::Other) {
|
|
||||||
return DevicesPromise::CreateAndResolve(devices, __func__);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool resistFingerprinting = nsContentUtils::ResistFingerprinting(aCallerType);
|
bool resistFingerprinting = nsContentUtils::ResistFingerprinting(aCallerType);
|
||||||
|
|
||||||
// In order of precedence: resist fingerprinting > loopback > fake pref
|
// In order of precedence: resist fingerprinting > loopback > fake pref
|
||||||
if (resistFingerprinting) {
|
if (resistFingerprinting) {
|
||||||
videoEnumerationType = DeviceEnumerationType::Fake;
|
videoEnumerationType = DeviceEnumerationType::Fake;
|
||||||
|
@ -3218,29 +3194,30 @@ RefPtr<MediaManager::DevicesPromise> MediaManager::EnumerateDevices(
|
||||||
nsAutoCString videoLoopDev, audioLoopDev;
|
nsAutoCString videoLoopDev, audioLoopDev;
|
||||||
bool wantFakes = Preferences::GetBool("media.navigator.streams.fake");
|
bool wantFakes = Preferences::GetBool("media.navigator.streams.fake");
|
||||||
// Video
|
// Video
|
||||||
if (videoType == MediaSourceEnum::Camera) {
|
Preferences::GetCString("media.video_loopback_dev", videoLoopDev);
|
||||||
Preferences::GetCString("media.video_loopback_dev", videoLoopDev);
|
// Loopback prefs take precedence over fake prefs
|
||||||
// Loopback prefs take precedence over fake prefs
|
if (!videoLoopDev.IsEmpty()) {
|
||||||
if (!videoLoopDev.IsEmpty()) {
|
videoEnumerationType = DeviceEnumerationType::Loopback;
|
||||||
videoEnumerationType = DeviceEnumerationType::Loopback;
|
} else if (wantFakes) {
|
||||||
} else if (wantFakes) {
|
videoEnumerationType = DeviceEnumerationType::Fake;
|
||||||
videoEnumerationType = DeviceEnumerationType::Fake;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Audio
|
// Audio
|
||||||
if (audioType == MediaSourceEnum::Microphone) {
|
Preferences::GetCString("media.audio_loopback_dev", audioLoopDev);
|
||||||
Preferences::GetCString("media.audio_loopback_dev", audioLoopDev);
|
// Loopback prefs take precedence over fake prefs
|
||||||
// Loopback prefs take precedence over fake prefs
|
if (!audioLoopDev.IsEmpty()) {
|
||||||
if (!audioLoopDev.IsEmpty()) {
|
audioEnumerationType = DeviceEnumerationType::Loopback;
|
||||||
audioEnumerationType = DeviceEnumerationType::Loopback;
|
} else if (wantFakes) {
|
||||||
} else if (wantFakes) {
|
audioEnumerationType = DeviceEnumerationType::Fake;
|
||||||
audioEnumerationType = DeviceEnumerationType::Fake;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return EnumerateDevicesImpl(windowId, videoType, audioType, audioOutputType,
|
MediaSinkEnum audioOutputType = MediaSinkEnum::Other;
|
||||||
|
if (Preferences::GetBool("media.setsinkid.enabled")) {
|
||||||
|
audioOutputType = MediaSinkEnum::Speaker;
|
||||||
|
}
|
||||||
|
auto devices = MakeRefPtr<MediaDeviceSetRefCnt>();
|
||||||
|
return EnumerateDevicesImpl(windowId, MediaSourceEnum::Camera,
|
||||||
|
MediaSourceEnum::Microphone, audioOutputType,
|
||||||
videoEnumerationType, audioEnumerationType, false,
|
videoEnumerationType, audioEnumerationType, false,
|
||||||
devices)
|
devices)
|
||||||
->Then(
|
->Then(
|
||||||
|
|
|
@ -106,9 +106,7 @@ runTest(async () => {
|
||||||
let [sameOriginDevices, differentOriginDevices] = origins.map(o => devicesMap.get(o));
|
let [sameOriginDevices, differentOriginDevices] = origins.map(o => devicesMap.get(o));
|
||||||
|
|
||||||
is(sameOriginDevices.length, devices.length);
|
is(sameOriginDevices.length, devices.length);
|
||||||
// Camera and microphone are allowed for documents that are same-origin by
|
is(differentOriginDevices.length, devices.length);
|
||||||
// default.
|
|
||||||
is(differentOriginDevices.length, 0);
|
|
||||||
[...sameOriginDevices, ...differentOriginDevices].forEach(d => validateDevice(d));
|
[...sameOriginDevices, ...differentOriginDevices].forEach(d => validateDevice(d));
|
||||||
|
|
||||||
for (let device of sameOriginDevices) {
|
for (let device of sameOriginDevices) {
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>enumerateDevices: test enumerateDevices should not expose camera devices if they are not allowed to use</title>
|
|
||||||
<link rel="help" href="https://w3c.github.io/mediacapture-main/#dom-mediadevices-enumeratedevices">
|
|
||||||
<meta name='assert' content='Check that the enumerateDevices() method should not exposed camera devices.'/>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 class="instructions">Description</h1>
|
|
||||||
<p class="instructions">This test checks for the presence of camera in
|
|
||||||
<code>navigator.mediaDevices.enumerateDevices()</code> method.</p>
|
|
||||||
<div id='log'></div>
|
|
||||||
<script src=/resources/testharness.js></script>
|
|
||||||
<script src=/resources/testharnessreport.js></script>
|
|
||||||
<script>
|
|
||||||
"use strict";
|
|
||||||
promise_test(async () => {
|
|
||||||
assert_not_equals(navigator.mediaDevices.enumerateDevices, undefined, "navigator.mediaDevices.enumerateDevices exists");
|
|
||||||
const deviceList = await navigator.mediaDevices.enumerateDevices();
|
|
||||||
for (const mediaInfo of deviceList) {
|
|
||||||
assert_not_equals(mediaInfo.deviceId, undefined, "mediaInfo's deviceId should exist.");
|
|
||||||
assert_not_equals(mediaInfo.kind, undefined, "mediaInfo's kind should exist.");
|
|
||||||
assert_not_equals(mediaInfo.label, undefined, "mediaInfo's label should exist.");
|
|
||||||
assert_not_equals(mediaInfo.groupId, undefined, "mediaInfo's groupId should exist.");
|
|
||||||
assert_in_array(mediaInfo.kind, ["audioinput", "audiooutput"]);
|
|
||||||
}
|
|
||||||
}, "Camera is not exposed in mediaDevices.enumerateDevices()");
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1 +0,0 @@
|
||||||
Feature-Policy: camera 'none'
|
|
|
@ -1,30 +0,0 @@
|
||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>enumerateDevices: test enumerateDevices should not expose microphone devices if they are not allowed to use</title>
|
|
||||||
<link rel="help" href="https://w3c.github.io/mediacapture-main/#dom-mediadevices-enumeratedevices">
|
|
||||||
<meta name='assert' content='Check that the enumerateDevices() method should not exposed microphone devices.'/>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 class="instructions">Description</h1>
|
|
||||||
<p class="instructions">This test checks for the presence of microphone in
|
|
||||||
<code>navigator.mediaDevices.enumerateDevices()</code> method.</p>
|
|
||||||
<div id='log'></div>
|
|
||||||
<script src=/resources/testharness.js></script>
|
|
||||||
<script src=/resources/testharnessreport.js></script>
|
|
||||||
<script>
|
|
||||||
"use strict";
|
|
||||||
promise_test(async () => {
|
|
||||||
assert_not_equals(navigator.mediaDevices.enumerateDevices, undefined, "navigator.mediaDevices.enumerateDevices exists");
|
|
||||||
const deviceList = await navigator.mediaDevices.enumerateDevices();
|
|
||||||
for (const mediaInfo of deviceList) {
|
|
||||||
assert_not_equals(mediaInfo.deviceId, undefined, "mediaInfo's deviceId should exist.");
|
|
||||||
assert_not_equals(mediaInfo.kind, undefined, "mediaInfo's kind should exist.");
|
|
||||||
assert_not_equals(mediaInfo.label, undefined, "mediaInfo's label should exist.");
|
|
||||||
assert_not_equals(mediaInfo.groupId, undefined, "mediaInfo's groupId should exist.");
|
|
||||||
assert_in_array(mediaInfo.kind, ["videoinput", "audiooutput"]);
|
|
||||||
}
|
|
||||||
}, "Microphone is not exposed in mediaDevices.enumerateDevices()");
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1 +0,0 @@
|
||||||
Feature-Policy: microphone 'none'
|
|
|
@ -17,26 +17,26 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
//NOTE ALEX: for completion, a test for ondevicechange event is missing.
|
//NOTE ALEX: for completion, a test for ondevicechange event is missing.
|
||||||
promise_test(async () => {
|
promise_test(async () => {
|
||||||
assert_not_equals(navigator.mediaDevices.enumerateDevices, undefined, "navigator.mediaDevices.enumerateDevices exists");
|
assert_true(undefined !== navigator.mediaDevices.enumerateDevices, "navigator.mediaDevices.enumerateDevices exists");
|
||||||
const deviceList = await navigator.mediaDevices.enumerateDevices();
|
const device_list = await navigator.mediaDevices.enumerateDevices();
|
||||||
for (const mediaInfo of deviceList) {
|
for (const mediainfo of device_list) {
|
||||||
assert_not_equals(mediaInfo.deviceId, undefined, "mediaInfo's deviceId should exist.");
|
assert_true(undefined !== mediainfo.deviceId, "mediaInfo's deviceId should exist.");
|
||||||
assert_not_equals(mediaInfo.kind, undefined, "mediaInfo's kind should exist.");
|
assert_true(undefined !== mediainfo.kind, "mediaInfo's kind should exist.");
|
||||||
assert_not_equals(mediaInfo.label, undefined, "mediaInfo's label should exist.");
|
assert_in_array(mediainfo.kind, ["videoinput", "audioinput", "audiooutput"]);
|
||||||
assert_not_equals(mediaInfo.groupId, undefined, "mediaInfo's groupId should exist.");
|
assert_true(undefined !== mediainfo.label, "mediaInfo's label should exist.");
|
||||||
assert_in_array(mediaInfo.kind, ["videoinput", "audioinput", "audiooutput"]);
|
assert_true(undefined !== mediainfo.groupId, "mediaInfo's groupId should exist.");
|
||||||
}
|
}
|
||||||
}, "mediaDevices.enumerateDevices() is present and working");
|
}, "mediaDevices.enumerateDevices() is present and working");
|
||||||
|
|
||||||
promise_test(async () => {
|
promise_test(async () => {
|
||||||
const deviceList = await navigator.mediaDevices.enumerateDevices();
|
const device_list = await navigator.mediaDevices.enumerateDevices();
|
||||||
for (const mediaInfo of deviceList) {
|
for (const mediainfo of device_list) {
|
||||||
if (mediaInfo.kind == "audioinput" || mediaInfo.kind == "videoinput") {
|
if (mediainfo.kind == "audioinput" || mediainfo.kind == "videoinput") {
|
||||||
assert_true(mediaInfo instanceof InputDeviceInfo);
|
assert_true(mediainfo instanceof InputDeviceInfo);
|
||||||
} else if ( mediaInfo.kind == "audiooutput" ) {
|
} else if ( mediainfo.kind == "audiooutput" ) {
|
||||||
assert_true(mediaInfo instanceof MediaDeviceInfo);
|
assert_true(mediainfo instanceof MediaDeviceInfo);
|
||||||
} else {
|
} else {
|
||||||
assert_unreached("mediaInfo.kind should be one of 'audioinput', 'videoinput', or 'audiooutput'.")
|
assert_unreached("mediainfo.kind should be one of 'audioinput', 'videoinput', or 'audiooutput'.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, "InputDeviceInfo is supported");
|
}, "InputDeviceInfo is supported");
|
||||||
|
|
Загрузка…
Ссылка в новой задаче