Changeset 251712 in webkit
- Timestamp:
- Oct 29, 2019 10:33:43 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r251710 r251712 1 2019-10-29 Truitt Savell <tsavell@apple.com> 2 3 Unreviewed, rolling out r251639. 4 5 Caused flakey API failures for GetDisplayMediaTest.Constraints 6 7 Reverted changeset: 8 9 "Enforce user gesture for getUserMedia in case a previous 10 getUserMedia call was denied" 11 https://bugs.webkit.org/show_bug.cgi?id=203362 12 https://trac.webkit.org/changeset/251639 13 1 14 2019-10-29 Chris Dumez <cdumez@apple.com> 2 15 -
trunk/LayoutTests/fast/mediastream/screencapture-user-gesture-expected.txt
r251639 r251712 1 1 2 2 PASS Allow getDisplayMedia call in case of user gesture 3 PASS Disallow getDisplayMedia calls in case of user gesture if not the first call4 3 PASS Deny getDisplayMedia call if no user gesture 5 4 -
trunk/LayoutTests/fast/mediastream/screencapture-user-gesture.html
r251639 r251712 13 13 }, "Allow getDisplayMedia call in case of user gesture"); 14 14 15 promise_test(() => {16 let promise;17 internals.withUserGesture(() => {18 const promise1 = navigator.mediaDevices.getDisplayMedia({video : true});19 const promise2 = navigator.mediaDevices.getDisplayMedia({video : true}).then(() => {20 return Promise.reject("Second promise should reject");21 }, () => {22 return "Second promise rejected";23 });24 promise = Promise.all([promise1, promise2]);25 });26 return promise;27 }, "Disallow getDisplayMedia calls in case of user gesture if not the first call");28 29 30 15 promise_test((test) => { 31 16 return promise_rejects(test, "InvalidAccessError", navigator.mediaDevices.getDisplayMedia({video : true})); -
trunk/Source/WebCore/ChangeLog
r251710 r251712 1 2019-10-29 Truitt Savell <tsavell@apple.com> 2 3 Unreviewed, rolling out r251639. 4 5 Caused flakey API failures for GetDisplayMediaTest.Constraints 6 7 Reverted changeset: 8 9 "Enforce user gesture for getUserMedia in case a previous 10 getUserMedia call was denied" 11 https://bugs.webkit.org/show_bug.cgi?id=203362 12 https://trac.webkit.org/changeset/251639 13 1 14 2019-10-29 Chris Dumez <cdumez@apple.com> 2 15 -
trunk/Source/WebCore/Modules/mediastream/MediaDevices.cpp
r251639 r251712 42 42 #include "MediaTrackSupportedConstraints.h" 43 43 #include "RealtimeMediaSourceSettings.h" 44 #include "UserGestureIndicator.h"45 44 #include "UserMediaController.h" 46 45 #include "UserMediaRequest.h" … … 106 105 } 107 106 108 bool MediaDevices::computeUserGesturePriviledge(GestureAllowedRequest requestType) 109 { 110 auto* currentGestureToken = UserGestureIndicator::currentUserGesture().get(); 111 if (m_currentGestureToken != currentGestureToken) { 112 m_currentGestureToken = currentGestureToken; 113 m_requestTypesForCurrentGesture = { }; 114 } 115 116 bool isUserGesturePriviledged = m_currentGestureToken && !m_requestTypesForCurrentGesture.contains(requestType); 117 m_requestTypesForCurrentGesture.add(requestType); 118 return isUserGesturePriviledged; 119 } 120 121 void MediaDevices::getUserMedia(const StreamConstraints& constraints, Promise&& promise) 107 void MediaDevices::getUserMedia(const StreamConstraints& constraints, Promise&& promise) const 122 108 { 123 109 auto* document = this->document(); … … 127 113 auto audioConstraints = createMediaConstraints(constraints.audio); 128 114 auto videoConstraints = createMediaConstraints(constraints.video); 129 130 bool isUserGesturePriviledged = false; 131 132 if (audioConstraints.isValid) 133 isUserGesturePriviledged |= computeUserGesturePriviledge(GestureAllowedRequest::Microphone); 134 135 if (videoConstraints.isValid) { 136 isUserGesturePriviledged |= computeUserGesturePriviledge(GestureAllowedRequest::Camera); 115 if (videoConstraints.isValid) 137 116 videoConstraints.setDefaultVideoConstraints(); 138 } 139 140 auto request = UserMediaRequest::create(*document, { MediaStreamRequest::Type::UserMedia, WTFMove(audioConstraints), WTFMove(videoConstraints), isUserGesturePriviledged }, WTFMove(promise)); 117 118 auto request = UserMediaRequest::create(*document, { MediaStreamRequest::Type::UserMedia, WTFMove(audioConstraints), WTFMove(videoConstraints) }, WTFMove(promise)); 141 119 request->start(); 142 120 } 143 121 144 void MediaDevices::getDisplayMedia(const StreamConstraints& constraints, Promise&& promise) 122 void MediaDevices::getDisplayMedia(const StreamConstraints& constraints, Promise&& promise) const 145 123 { 146 124 auto* document = this->document(); … … 148 126 return; 149 127 150 bool isUserGesturePriviledged = computeUserGesturePriviledge(GestureAllowedRequest::Display); 151 if (!m_disableGetDisplayMediaUserGestureConstraint && !isUserGesturePriviledged) { 128 if (!m_disableGetDisplayMediaUserGestureConstraint && !UserGestureIndicator::processingUserGesture()) { 152 129 promise.reject(Exception { InvalidAccessError, "getDisplayMedia must be called from a user gesture handler."_s }); 153 130 return; 154 131 } 155 132 156 auto request = UserMediaRequest::create(*document, { MediaStreamRequest::Type::DisplayMedia, { }, createMediaConstraints(constraints.video) , isUserGesturePriviledged}, WTFMove(promise));133 auto request = UserMediaRequest::create(*document, { MediaStreamRequest::Type::DisplayMedia, { }, createMediaConstraints(constraints.video) }, WTFMove(promise)); 157 134 request->start(); 158 135 } -
trunk/Source/WebCore/Modules/mediastream/MediaDevices.h
r251639 r251712 50 50 class MediaDeviceInfo; 51 51 class MediaStream; 52 class UserGestureToken;53 52 54 53 struct MediaTrackSupportedConstraints; … … 79 78 Variant<bool, MediaTrackConstraints> audio; 80 79 }; 81 void getUserMedia(const StreamConstraints&, Promise&&) ;82 void getDisplayMedia(const StreamConstraints&, Promise&&) ;80 void getUserMedia(const StreamConstraints&, Promise&&) const; 81 void getDisplayMedia(const StreamConstraints&, Promise&&) const; 83 82 void enumerateDevices(EnumerateDevicesPromise&&); 84 83 MediaTrackSupportedConstraints getSupportedConstraints(); … … 111 110 void derefEventTarget() final { deref(); } 112 111 113 enum class GestureAllowedRequest {114 Microphone = 1 << 0,115 Camera = 1 << 1,116 Display = 1 << 2,117 };118 bool computeUserGesturePriviledge(GestureAllowedRequest);119 120 112 Timer m_scheduledEventTimer; 121 113 UserMediaClient::DeviceChangeObserverToken m_deviceChangeToken; … … 127 119 bool m_canAccessCamera { false }; 128 120 bool m_canAccessMicrophone { false }; 129 130 OptionSet<GestureAllowedRequest> m_requestTypesForCurrentGesture;131 UserGestureToken* m_currentGestureToken { nullptr };132 121 }; 133 122 -
trunk/Source/WebCore/platform/mediastream/MediaStreamRequest.h
r251639 r251712 34 34 struct MediaStreamRequest { 35 35 enum class Type { UserMedia, DisplayMedia }; 36 Type type { Type::UserMedia };36 Type type; 37 37 MediaConstraints audioConstraints; 38 38 MediaConstraints videoConstraints; 39 bool isUserGesturePriviledged { false };40 39 41 40 template<class Encoder> … … 45 44 encoder << audioConstraints; 46 45 encoder << videoConstraints; 47 encoder << isUserGesturePriviledged;48 46 } 49 47 … … 51 49 { 52 50 MediaStreamRequest request; 53 if (decoder.decodeEnum(request.type) && decoder.decode(request.audioConstraints) && decoder.decode(request.videoConstraints) && decoder.decode(request.isUserGesturePriviledged))51 if (decoder.decodeEnum(request.type) && decoder.decode(request.audioConstraints) && decoder.decode(request.videoConstraints)) 54 52 return request; 55 53 -
trunk/Source/WebKit/ChangeLog
r251711 r251712 1 2019-10-29 Truitt Savell <tsavell@apple.com> 2 3 Unreviewed, rolling out r251639. 4 5 Caused flakey API failures for GetDisplayMediaTest.Constraints 6 7 Reverted changeset: 8 9 "Enforce user gesture for getUserMedia in case a previous 10 getUserMedia call was denied" 11 https://bugs.webkit.org/show_bug.cgi?id=203362 12 https://trac.webkit.org/changeset/251639 13 1 14 2019-10-29 Truitt Savell <tsavell@apple.com> 2 15 -
trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp
r251639 r251712 346 346 ASSERT(!(requestingScreenCapture && requestingMicrophone)); 347 347 348 if ( !request.isUserGesturePriviledged() &&wasRequestDenied(request.frameID(), request.userMediaDocumentSecurityOrigin(), request.topLevelDocumentSecurityOrigin(), requestingMicrophone, requestingCamera, requestingScreenCapture))348 if (wasRequestDenied(request.frameID(), request.userMediaDocumentSecurityOrigin(), request.topLevelDocumentSecurityOrigin(), requestingMicrophone, requestingCamera, requestingScreenCapture)) 349 349 return RequestAction::Deny; 350 350 -
trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestProxy.h
r251711 r251712 85 85 WebCore::CaptureDevice videoDevice() const { return m_eligibleVideoDevices.isEmpty() ? WebCore::CaptureDevice { } : m_eligibleVideoDevices[0]; } 86 86 87 bool isUserGesturePriviledged() const { return m_request.isUserGesturePriviledged; }88 89 87 private: 90 88 UserMediaPermissionRequestProxy(UserMediaPermissionRequestManagerProxy&, uint64_t userMediaID, WebCore::FrameIdentifier mainFrameID, WebCore::FrameIdentifier, Ref<WebCore::SecurityOrigin>&& userMediaDocumentOrigin, Ref<WebCore::SecurityOrigin>&& topLevelDocumentOrigin, Vector<WebCore::CaptureDevice>&& audioDevices, Vector<WebCore::CaptureDevice>&& videoDevices, WebCore::MediaStreamRequest&&); -
trunk/Tools/ChangeLog
r251709 r251712 1 2019-10-29 Truitt Savell <tsavell@apple.com> 2 3 Unreviewed, rolling out r251639. 4 5 Caused flakey API failures for GetDisplayMediaTest.Constraints 6 7 Reverted changeset: 8 9 "Enforce user gesture for getUserMedia in case a previous 10 getUserMedia call was denied" 11 https://bugs.webkit.org/show_bug.cgi?id=203362 12 https://trac.webkit.org/changeset/251639 13 1 14 2019-10-29 Chris Dumez <cdumez@apple.com> 2 15 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/GetDisplayMedia.mm
r251639 r251712 181 181 promptForCapture(@"{ video: true }", false); 182 182 shouldDeny = false; 183 promptForCapture(@"{ video: true }", true); 183 promptForCapture(@"{ video: true }", false); 184 promptForCapture(@"{ video: true }", false); 184 185 } 185 186
Note: See TracChangeset
for help on using the changeset viewer.