- Revision
- 237643
- Author
- eric.carl...@apple.com
- Date
- 2018-10-31 10:26:49 -0700 (Wed, 31 Oct 2018)
Log Message
[MediaStream] Don't reveal device IDs until the user has granted permission to capture
https://bugs.webkit.org/show_bug.cgi?id=191112
<rdar://problem/45699932>
Reviewed by Youenn Fablet.
Source/WebCore:
No new tests, existing tests updated.
* Modules/mediastream/MediaDevicesRequest.cpp:
(WebCore::MediaDevicesRequest::start): Don't reveal device ID or group ID until the user
has granted permssion to capture.
LayoutTests:
* TestExpectations: Skip http/tests/media/media-stream/enumerate-devices-source-id-persistent.html
and http/tests/media/media-stream/enumerate-devices-source-id.html for now, they don't make sense
with these changes and will be updated to pass in a future patch.
* fast/mediastream/MediaStreamTrack-getCapabilities.html:
* fast/mediastream/get-user-media-device-id-expected.txt:
* fast/mediastream/get-user-media-device-id.html:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (237642 => 237643)
--- trunk/LayoutTests/ChangeLog 2018-10-31 17:19:27 UTC (rev 237642)
+++ trunk/LayoutTests/ChangeLog 2018-10-31 17:26:49 UTC (rev 237643)
@@ -1,3 +1,18 @@
+2018-10-31 Eric Carlson <eric.carl...@apple.com>
+
+ [MediaStream] Don't reveal device IDs until the user has granted permission to capture
+ https://bugs.webkit.org/show_bug.cgi?id=191112
+ <rdar://problem/45699932>
+
+ Reviewed by Youenn Fablet.
+
+ * TestExpectations: Skip http/tests/media/media-stream/enumerate-devices-source-id-persistent.html
+ and http/tests/media/media-stream/enumerate-devices-source-id.html for now, they don't make sense
+ with these changes and will be updated to pass in a future patch.
+ * fast/mediastream/MediaStreamTrack-getCapabilities.html:
+ * fast/mediastream/get-user-media-device-id-expected.txt:
+ * fast/mediastream/get-user-media-device-id.html:
+
2018-10-31 YUHAN WU <yuhan...@apple.com>
MediaRecorder should fire dataavailable event when all tracks are ended and stop() is called
Modified: trunk/LayoutTests/TestExpectations (237642 => 237643)
--- trunk/LayoutTests/TestExpectations 2018-10-31 17:19:27 UTC (rev 237642)
+++ trunk/LayoutTests/TestExpectations 2018-10-31 17:26:49 UTC (rev 237643)
@@ -2904,3 +2904,7 @@
fast/mediacapturefromelement/CanvasCaptureMediaStream-imagebitmaprenderingcontext.html [ Skip ]
fast/mediacapturefromelement/CanvasCaptureMediaStream-framerate-0.html [ Skip ]
fast/mediacapturefromelement/CanvasCaptureMediaStream-capture-out-of-DOM-element.html [ Skip ]
+
+# FIXME: The behavior of navigator.mediaDevices.enumerateDevices is in flux, skip these tests for now.
+http/tests/media/media-stream/enumerate-devices-source-id-persistent.html [ Skip ]
+http/tests/media/media-stream/enumerate-devices-source-id.html [ Skip ]
Modified: trunk/LayoutTests/fast/mediastream/MediaStreamTrack-getCapabilities.html (237642 => 237643)
--- trunk/LayoutTests/fast/mediastream/MediaStreamTrack-getCapabilities.html 2018-10-31 17:19:27 UTC (rev 237642)
+++ trunk/LayoutTests/fast/mediastream/MediaStreamTrack-getCapabilities.html 2018-10-31 17:26:49 UTC (rev 237643)
@@ -2,11 +2,13 @@
<html>
<head>
<script src=""
- <script src=""
<script>
var mediaStream;
var devices;
+ if (window.testRunner)
+ testRunner.setUserMediaPermission(true);
+
function limitPrecision(value, precision)
{
if (typeof value === "string")
@@ -80,16 +82,16 @@
finishJSTest();
}
- function start()
+ async function start()
{
description("Tests MediaStreamTrack.getCapabilities.");
- navigator.mediaDevices.enumerateDevices().then(deviceInfoArray => {
- devices = deviceInfoArray;
- getUserMedia("allow", {audio:true, video:true}, gotStream);
- }, e => {
- testFailed('enumerateDevices failed:' + e);
- finishJSTest();
- });
+
+ mediaStream = await navigator.mediaDevices.getUserMedia({ audio:true, video:true });
+ devices = await navigator.mediaDevices.enumerateDevices();
+
+ listTrackProperties(mediaStream.getVideoTracks()[0]);
+ listTrackProperties(mediaStream.getAudioTracks()[0]);
+ finishJSTest();
}
window.jsTestIsAsync = true;
Modified: trunk/LayoutTests/fast/mediastream/get-user-media-device-id-expected.txt (237642 => 237643)
--- trunk/LayoutTests/fast/mediastream/get-user-media-device-id-expected.txt 2018-10-31 17:19:27 UTC (rev 237642)
+++ trunk/LayoutTests/fast/mediastream/get-user-media-device-id-expected.txt 2018-10-31 17:26:49 UTC (rev 237643)
@@ -1,4 +1,5 @@
+PASS Device IDs should be empty initially
PASS Collect device IDs
PASS Pass device IDs as exact constraints
PASS Pass device IDs as optional constraints
Modified: trunk/LayoutTests/fast/mediastream/get-user-media-device-id.html (237642 => 237643)
--- trunk/LayoutTests/fast/mediastream/get-user-media-device-id.html 2018-10-31 17:19:27 UTC (rev 237642)
+++ trunk/LayoutTests/fast/mediastream/get-user-media-device-id.html 2018-10-31 17:26:49 UTC (rev 237643)
@@ -15,12 +15,23 @@
return navigator.mediaDevices.enumerateDevices()
.then((devices) => {
devices.forEach((device) => {
+ assert_true(device.deviceId.length == 0 , "device.deviceId is empty before permission to capture");
+ });
+ });
+ }, "Device IDs should be empty initially");
+
+ promise_test((test) => {
+ return navigator.mediaDevices.getUserMedia({ audio:true, video:true })
+ .then((stream) => {
+ return navigator.mediaDevices.enumerateDevices();
+ }).then(devices => {
+ devices.forEach((device) => {
let kind = device.kind == "audioinput" ? "audio" : "video";
deviceIds.push({ type: kind, id : device.deviceId});
});
});
}, "Collect device IDs");
-
+
let constraints = { };
promise_test((test) => {
Modified: trunk/Source/WebCore/ChangeLog (237642 => 237643)
--- trunk/Source/WebCore/ChangeLog 2018-10-31 17:19:27 UTC (rev 237642)
+++ trunk/Source/WebCore/ChangeLog 2018-10-31 17:26:49 UTC (rev 237643)
@@ -1,3 +1,17 @@
+2018-10-31 Eric Carlson <eric.carl...@apple.com>
+
+ [MediaStream] Don't reveal device IDs until the user has granted permission to capture
+ https://bugs.webkit.org/show_bug.cgi?id=191112
+ <rdar://problem/45699932>
+
+ Reviewed by Youenn Fablet.
+
+ No new tests, existing tests updated.
+
+ * Modules/mediastream/MediaDevicesRequest.cpp:
+ (WebCore::MediaDevicesRequest::start): Don't reveal device ID or group ID until the user
+ has granted permssion to capture.
+
2018-10-31 YUHAN WU <yuhan...@apple.com>
MediaRecorder should fire dataavailable event when all tracks are ended and stop() is called
Modified: trunk/Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp (237642 => 237643)
--- trunk/Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp 2018-10-31 17:19:27 UTC (rev 237642)
+++ trunk/Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp 2018-10-31 17:26:49 UTC (rev 237643)
@@ -115,21 +115,24 @@
document.setDeviceIDHashSalt(deviceIdentifierHashSalt);
Vector<Ref<MediaDeviceInfo>> devices;
+ bool revealIdsAndLabels = originHasPersistentAccess || document.hasHadCaptureMediaStreamTrack();
for (auto& deviceInfo : captureDevices) {
auto label = emptyString();
- if (originHasPersistentAccess || document.hasHadCaptureMediaStreamTrack())
+ auto id = emptyString();
+ auto groupId = emptyString();
+ if (revealIdsAndLabels) {
label = deviceInfo.label();
+ id = RealtimeMediaSourceCenter::singleton().hashStringWithSalt(deviceInfo.persistentId(), deviceIdentifierHashSalt);
+ if (id.isEmpty())
+ continue;
+ groupId = RealtimeMediaSourceCenter::singleton().hashStringWithSalt(deviceInfo.groupId(), deviceIdentifierHashSalt);
+ }
- auto id = RealtimeMediaSourceCenter::singleton().hashStringWithSalt(deviceInfo.persistentId(), deviceIdentifierHashSalt);
- if (id.isEmpty())
- continue;
-
- auto groupId = RealtimeMediaSourceCenter::singleton().hashStringWithSalt(deviceInfo.groupId(), deviceIdentifierHashSalt);
auto deviceType = deviceInfo.type() == CaptureDevice::DeviceType::Microphone ? MediaDeviceInfo::Kind::Audioinput : MediaDeviceInfo::Kind::Videoinput;
devices.append(MediaDeviceInfo::create(scriptExecutionContext(), label, id, groupId, deviceType));
}
- if (!originHasPersistentAccess && !document.hasHadCaptureMediaStreamTrack())
+ if (!revealIdsAndLabels)
filterDeviceList(devices);
callOnMainThread([protectedThis = makeRef(*this), devices = WTFMove(devices)]() mutable {