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:
Coroiu Cristina 2019-09-05 20:00:26 +03:00
Родитель 95fc013b8b
Коммит 5f190b63ff
8 изменённых файлов: 39 добавлений и 129 удалений

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

@ -142,10 +142,6 @@ already_AddRefed<Promise> MediaDevices::EnumerateDevices(CallerType aCallerType,
}
auto windowId = window->WindowID();
nsTArray<RefPtr<MediaDeviceInfo>> infos;
bool allowLabel =
aDevices->Length() == 0 ||
MediaManager::Get()->IsActivelyCapturingOrHasAPermission(
windowId);
for (auto& device : *aDevices) {
MOZ_ASSERT(device->mKind == dom::MediaDeviceKind::Audioinput ||
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
// or persistent permissions (audio or video) have been granted
nsString label;
if (allowLabel ||
if (MediaManager::Get()->IsActivelyCapturingOrHasAPermission(
windowId) ||
Preferences::GetBool("media.navigator.permission.disabled",
false)) {
label = device->mName;

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

@ -3161,10 +3161,8 @@ RefPtr<MediaManager::DevicesPromise> MediaManager::EnumerateDevices(
__func__);
}
uint64_t windowId = aWindow->WindowID();
Document* doc = aWindow->GetExtantDoc();
MOZ_ASSERT(doc);
nsIPrincipal* principal = doc->NodePrincipal();
nsIPrincipal* principal = aWindow->GetExtantDoc()->NodePrincipal();
RefPtr<GetUserMediaWindowListener> windowListener =
GetWindowListener(windowId);
@ -3185,30 +3183,8 @@ RefPtr<MediaManager::DevicesPromise> MediaManager::EnumerateDevices(
DeviceEnumerationType videoEnumerationType = 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);
// In order of precedence: resist fingerprinting > loopback > fake pref
if (resistFingerprinting) {
videoEnumerationType = DeviceEnumerationType::Fake;
@ -3218,29 +3194,30 @@ RefPtr<MediaManager::DevicesPromise> MediaManager::EnumerateDevices(
nsAutoCString videoLoopDev, audioLoopDev;
bool wantFakes = Preferences::GetBool("media.navigator.streams.fake");
// Video
if (videoType == MediaSourceEnum::Camera) {
Preferences::GetCString("media.video_loopback_dev", videoLoopDev);
// Loopback prefs take precedence over fake prefs
if (!videoLoopDev.IsEmpty()) {
videoEnumerationType = DeviceEnumerationType::Loopback;
} else if (wantFakes) {
videoEnumerationType = DeviceEnumerationType::Fake;
}
Preferences::GetCString("media.video_loopback_dev", videoLoopDev);
// Loopback prefs take precedence over fake prefs
if (!videoLoopDev.IsEmpty()) {
videoEnumerationType = DeviceEnumerationType::Loopback;
} else if (wantFakes) {
videoEnumerationType = DeviceEnumerationType::Fake;
}
// Audio
if (audioType == MediaSourceEnum::Microphone) {
Preferences::GetCString("media.audio_loopback_dev", audioLoopDev);
// Loopback prefs take precedence over fake prefs
if (!audioLoopDev.IsEmpty()) {
audioEnumerationType = DeviceEnumerationType::Loopback;
} else if (wantFakes) {
audioEnumerationType = DeviceEnumerationType::Fake;
}
Preferences::GetCString("media.audio_loopback_dev", audioLoopDev);
// Loopback prefs take precedence over fake prefs
if (!audioLoopDev.IsEmpty()) {
audioEnumerationType = DeviceEnumerationType::Loopback;
} else if (wantFakes) {
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,
devices)
->Then(

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

@ -106,9 +106,7 @@ runTest(async () => {
let [sameOriginDevices, differentOriginDevices] = origins.map(o => devicesMap.get(o));
is(sameOriginDevices.length, devices.length);
// Camera and microphone are allowed for documents that are same-origin by
// default.
is(differentOriginDevices.length, 0);
is(differentOriginDevices.length, devices.length);
[...sameOriginDevices, ...differentOriginDevices].forEach(d => validateDevice(d));
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";
//NOTE ALEX: for completion, a test for ondevicechange event is missing.
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", "audioinput", "audiooutput"]);
assert_true(undefined !== navigator.mediaDevices.enumerateDevices, "navigator.mediaDevices.enumerateDevices exists");
const device_list = await navigator.mediaDevices.enumerateDevices();
for (const mediainfo of device_list) {
assert_true(undefined !== mediainfo.deviceId, "mediaInfo's deviceId should exist.");
assert_true(undefined !== mediainfo.kind, "mediaInfo's kind should exist.");
assert_in_array(mediainfo.kind, ["videoinput", "audioinput", "audiooutput"]);
assert_true(undefined !== mediainfo.label, "mediaInfo's label should exist.");
assert_true(undefined !== mediainfo.groupId, "mediaInfo's groupId should exist.");
}
}, "mediaDevices.enumerateDevices() is present and working");
promise_test(async () => {
const deviceList = await navigator.mediaDevices.enumerateDevices();
for (const mediaInfo of deviceList) {
if (mediaInfo.kind == "audioinput" || mediaInfo.kind == "videoinput") {
assert_true(mediaInfo instanceof InputDeviceInfo);
} else if ( mediaInfo.kind == "audiooutput" ) {
assert_true(mediaInfo instanceof MediaDeviceInfo);
const device_list = await navigator.mediaDevices.enumerateDevices();
for (const mediainfo of device_list) {
if (mediainfo.kind == "audioinput" || mediainfo.kind == "videoinput") {
assert_true(mediainfo instanceof InputDeviceInfo);
} else if ( mediainfo.kind == "audiooutput" ) {
assert_true(mediainfo instanceof MediaDeviceInfo);
} 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");