⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 237643 in webkit


Ignore:
Timestamp:
Oct 31, 2018, 10:26:49 AM (8 years ago)
Author:
eric.carlson@apple.com
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:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r237642 r237643  
     12018-10-31  Eric Carlson  <eric.carlson@apple.com>
     2
     3        [MediaStream] Don't reveal device IDs until the user has granted permission to capture
     4        https://bugs.webkit.org/show_bug.cgi?id=191112
     5        <rdar://problem/45699932>
     6
     7        Reviewed by Youenn Fablet.
     8
     9        * TestExpectations: Skip http/tests/media/media-stream/enumerate-devices-source-id-persistent.html
     10        and http/tests/media/media-stream/enumerate-devices-source-id.html for now, they don't make sense
     11        with these changes and will be updated to pass in a future patch.
     12        * fast/mediastream/MediaStreamTrack-getCapabilities.html:
     13        * fast/mediastream/get-user-media-device-id-expected.txt:
     14        * fast/mediastream/get-user-media-device-id.html:
     15
    1162018-10-31  YUHAN WU  <yuhan_wu@apple.com>
    217
  • trunk/LayoutTests/TestExpectations

    r237587 r237643  
    29052905fast/mediacapturefromelement/CanvasCaptureMediaStream-framerate-0.html [ Skip ]
    29062906fast/mediacapturefromelement/CanvasCaptureMediaStream-capture-out-of-DOM-element.html [ Skip ]
     2907
     2908# FIXME: The behavior of navigator.mediaDevices.enumerateDevices is in flux, skip these tests for now.
     2909http/tests/media/media-stream/enumerate-devices-source-id-persistent.html [ Skip ]
     2910http/tests/media/media-stream/enumerate-devices-source-id.html [ Skip ]
  • trunk/LayoutTests/fast/mediastream/MediaStreamTrack-getCapabilities.html

    r232754 r237643  
    33    <head>
    44        <script src="../../resources/js-test-pre.js"></script>
    5         <script src="./resources/getUserMedia-helper.js"></script>
    65        <script>
    76            var mediaStream;
    87            var devices;
     8
     9            if (window.testRunner)
     10                testRunner.setUserMediaPermission(true);
    911
    1012            function limitPrecision(value, precision)
     
    8183            }
    8284
    83             function start()
     85            async function start()
    8486            {
    8587                description("Tests MediaStreamTrack.getCapabilities.");
    86                 navigator.mediaDevices.enumerateDevices().then(deviceInfoArray => {
    87                     devices = deviceInfoArray;
    88                     getUserMedia("allow", {audio:true, video:true}, gotStream);
    89                 }, e => {
    90                     testFailed('enumerateDevices failed:' + e);
    91                     finishJSTest();
    92                 });
     88
     89                mediaStream = await navigator.mediaDevices.getUserMedia({ audio:true, video:true });
     90                devices = await navigator.mediaDevices.enumerateDevices();
     91
     92                listTrackProperties(mediaStream.getVideoTracks()[0]);
     93                listTrackProperties(mediaStream.getAudioTracks()[0]);
     94                finishJSTest();
    9395            }
    9496
  • trunk/LayoutTests/fast/mediastream/get-user-media-device-id-expected.txt

    r216836 r237643  
    11
     2PASS Device IDs should be empty initially
    23PASS Collect device IDs
    34PASS Pass device IDs as exact constraints
  • trunk/LayoutTests/fast/mediastream/get-user-media-device-id.html

    r222471 r237643  
    1616            .then((devices) => {
    1717                devices.forEach((device) => {
     18                    assert_true(device.deviceId.length == 0 , "device.deviceId is empty before permission to capture");
     19                });
     20            });
     21    }, "Device IDs should be empty initially");
     22   
     23    promise_test((test) => {
     24        return navigator.mediaDevices.getUserMedia({ audio:true, video:true })
     25            .then((stream) => {
     26                return navigator.mediaDevices.enumerateDevices();
     27            }).then(devices => {
     28                devices.forEach((device) => {
    1829                    let kind = device.kind == "audioinput" ? "audio" : "video";
    1930                    deviceIds.push({ type: kind, id : device.deviceId});
     
    2132            });
    2233    }, "Collect device IDs");
    23    
     34
    2435    let constraints = { };
    2536
  • trunk/Source/WebCore/ChangeLog

    r237642 r237643  
     12018-10-31  Eric Carlson  <eric.carlson@apple.com>
     2
     3        [MediaStream] Don't reveal device IDs until the user has granted permission to capture
     4        https://bugs.webkit.org/show_bug.cgi?id=191112
     5        <rdar://problem/45699932>
     6
     7        Reviewed by Youenn Fablet.
     8
     9        No new tests, existing tests updated.
     10
     11        * Modules/mediastream/MediaDevicesRequest.cpp:
     12        (WebCore::MediaDevicesRequest::start): Don't reveal device ID or group ID until the user
     13        has granted permssion to capture.
     14
    1152018-10-31  YUHAN WU  <yuhan_wu@apple.com>
    216
  • trunk/Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp

    r237266 r237643  
    116116
    117117        Vector<Ref<MediaDeviceInfo>> devices;
     118        bool revealIdsAndLabels = originHasPersistentAccess || document.hasHadCaptureMediaStreamTrack();
    118119        for (auto& deviceInfo : captureDevices) {
    119120            auto label = emptyString();
    120             if (originHasPersistentAccess || document.hasHadCaptureMediaStreamTrack())
     121            auto id = emptyString();
     122            auto groupId = emptyString();
     123            if (revealIdsAndLabels) {
    121124                label = deviceInfo.label();
     125                id = RealtimeMediaSourceCenter::singleton().hashStringWithSalt(deviceInfo.persistentId(), deviceIdentifierHashSalt);
     126                if (id.isEmpty())
     127                    continue;
     128                groupId = RealtimeMediaSourceCenter::singleton().hashStringWithSalt(deviceInfo.groupId(), deviceIdentifierHashSalt);
     129            }
    122130
    123             auto id = RealtimeMediaSourceCenter::singleton().hashStringWithSalt(deviceInfo.persistentId(), deviceIdentifierHashSalt);
    124             if (id.isEmpty())
    125                 continue;
    126 
    127             auto groupId = RealtimeMediaSourceCenter::singleton().hashStringWithSalt(deviceInfo.groupId(), deviceIdentifierHashSalt);
    128131            auto deviceType = deviceInfo.type() == CaptureDevice::DeviceType::Microphone ? MediaDeviceInfo::Kind::Audioinput : MediaDeviceInfo::Kind::Videoinput;
    129132            devices.append(MediaDeviceInfo::create(scriptExecutionContext(), label, id, groupId, deviceType));
    130133        }
    131134
    132         if (!originHasPersistentAccess && !document.hasHadCaptureMediaStreamTrack())
     135        if (!revealIdsAndLabels)
    133136            filterDeviceList(devices);
    134137
Note: See TracChangeset for help on using the changeset viewer.