[webkit-changes] [WebKit/WebKit] f45376: [MediaStream] enumerateDevices should not exposed ...

Eric Carlson noreply at github.com
Mon Jul 10 15:50:28 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f4537682e879e9aa3c5b76de6c4d547015e3993d
      https://github.com/WebKit/WebKit/commit/f4537682e879e9aa3c5b76de6c4d547015e3993d
  Author: Eric Carlson <eric.carlson at apple.com>
  Date:   2023-07-10 (Mon, 10 Jul 2023)

  Changed paths:
    A LayoutTests/fast/mediastream/camera-invalid-device-expected.txt
    A LayoutTests/fast/mediastream/camera-invalid-device.html
    M Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp
    M Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.h
    M Source/WebCore/platform/mock/MockMediaDevice.h
    M Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp
    M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
    M Source/WebKit/UIProcess/API/C/WKMockMediaDevice.cpp
    M Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp
    M Source/WebKit/WebProcess/glib/UserMediaCaptureManager.cpp
    M Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
    M Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
    M Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

  Log Message:
  -----------
  [MediaStream] enumerateDevices should not exposed devices that can not be used
https://bugs.webkit.org/show_bug.cgi?id=258993
rdar://110210394

Reviewed by Jer Noble and Youenn Fablet.

`enumerateDevices` should only include devices that are available for capture, so
make sure each device can be instantiated before including it.

* LayoutTests/fast/mediastream/camera-invalid-device-expected.txt: Added.
* LayoutTests/fast/mediastream/camera-invalid-device.html: Added.

* Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp:
(WebCore::RealtimeMediaSourceCenter::getCapabilities): Change to return a std::optional<>
so it can signal failure.
* Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.h:

* Source/WebCore/platform/mock/MockMediaDevice.h:
(WebCore::MockMediaDevice::captureDevice const): Combine the existing `IsEphemeral` bool
with the new `Invalid` flag into a "Flags" bitfield.
(WebCore::MockMediaDevice::encode const): Encode the new flags variable.
(WebCore::MockMediaDevice::decodeMockMediaDevice): Decode it.
(WebCore::MockMediaDevice::decode): Ditto.

* Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp:
(WebCore::defaultDevices): Update for the struct change.
(WebCore::MockRealtimeMediaSourceCenter::setDeviceIsEphemeral): Ditto.

* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in: Define the new bitfield.

* Source/WebKit/UIProcess/API/C/WKMockMediaDevice.cpp:
(WKAddMockMediaDevice): Both mock camera and microphone can now have properties.

* Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
(WebKit::UserMediaPermissionRequestManagerProxy::platformGetMediaStreamDevices): Don't include
a device if `RealtimeMediaSourceCenter::getCapabilities` returns null.

* Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::captureDeviceProperties): Convert the properties JS object to a WKDictionaryRef.
(WTR::TestRunner::addMockCameraDevice): Call captureDeviceProperties.
(WTR::TestRunner::addMockMicrophoneDevice): Add a properties parameter, call
captureDeviceProperties to parse it.
* Tools/WebKitTestRunner/InjectedBundle/TestRunner.h:

Canonical link: https://commits.webkit.org/265923@main




More information about the webkit-changes mailing list