Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Enforce user gesture for getUserMedia in case a previous getUserMedia…
… call was denied https://bugs.webkit.org/show_bug.cgi?id=203362 Source/WebCore: Reviewed by Eric Carlson. Compute whether a media request is user priviledged or not. It is priviledged if it is created as part of a user gesture and no request of the same type has been previously created for the same user gesture. If getDisplayMedia is called twice as part of a single user gesture, getDisplaMedia will reject for the second call. Remove the internal ability to disable user gesture check. Instead use internals API to simulate a user gesture. Test: fast/mediastream/getUserMedia-deny-persistency5.html and updated test. * Modules/mediastream/MediaDevices.cpp: (WebCore::MediaDevices::computeUserGesturePriviledge): (WebCore::MediaDevices::getUserMedia): (WebCore::MediaDevices::getDisplayMedia): (WebCore::MediaDevices::getUserMedia const): Deleted. (WebCore::MediaDevices::getDisplayMedia const): Deleted. * Modules/mediastream/MediaDevices.h: * platform/mediastream/MediaStreamRequest.h: (WebCore::MediaStreamRequest::encode const): (WebCore::MediaStreamRequest::decode): * testing/Internals.cpp: (WebCore::Internals::setMediaStreamSourceInterrupted): (WebCore::Internals::setDisableGetDisplayMediaUserGestureConstraint): Deleted. * testing/Internals.h: * testing/Internals.idl: Source/WebKit: Reviewed by Eric Carlson. In case the request has user gesture priviledge, do not look at denied request history. * UIProcess/UserMediaPermissionRequestManagerProxy.cpp: (WebKit::UserMediaPermissionRequestManagerProxy::getRequestAction): * UIProcess/UserMediaPermissionRequestProxy.h: (WebKit::UserMediaPermissionRequestProxy::isUserGesturePriviledged const): Tools: Reviewed by Eric Carlson. * TestWebKitAPI/Tests/WebKitCocoa/GetDisplayMedia.mm: (TestWebKitAPI::TEST_F): Update test to take into account the ability to ask again for permission. * TestWebKitAPI/Tests/WebKit/getDisplayMedia.html: Update to make sure we notify test if internals is not available. LayoutTests: <rdar://problem/56648232> Reviewed by Eric Carlson. * fast/mediastream/constraint-intrinsic-size.html: * fast/mediastream/get-display-media-muted.html: * fast/mediastream/getUserMedia-deny-persistency5-expected.txt: * fast/mediastream/getUserMedia-deny-persistency5.html: * fast/mediastream/media-stream-page-muted.html: Use user gesture simulation instead of disabling user gesture check. * fast/mediastream/screencapture-user-gesture.html: * fast/mediastream/screencapture-user-gesture-expected.txt: * http/tests/media/media-stream/get-display-media-iframe-allow-attribute-expected.txt: * http/tests/media/media-stream/get-display-media-prompt.html: * http/tests/media/media-stream/resources/get-display-media-devices-iframe.html: * resources/testharnessreport.js: Canonical link: https://commits.webkit.org/217202@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@252046 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
25 changed files
with
273 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
PASS Testing getUserMedia with and without user gesture after user denied access | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<script src="../../resources/testharness.js"></script> | ||
<script src="../../resources/testharnessreport.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
promise_test(async (test) => { | ||
if (window.testRunner) | ||
testRunner.setUserMediaPermission(false); | ||
|
||
await navigator.mediaDevices.getUserMedia({audio:false, video:true}).then(assert_unreached, (e) => { }); | ||
await navigator.mediaDevices.getUserMedia({audio:true, video:false}).then(assert_unreached, (e) => { }); | ||
await navigator.mediaDevices.getUserMedia({audio:true, video:true}).then(assert_unreached, (e) => { }); | ||
|
||
if (window.testRunner) | ||
testRunner.setUserMediaPermission(true); | ||
|
||
await navigator.mediaDevices.getUserMedia({audio:false, video:true}).then(assert_unreached, (e) => { | ||
assert_equals(e.name, "NotAllowedError"); | ||
}); | ||
|
||
let promise; | ||
internals.withUserGesture(() => { | ||
promise = navigator.mediaDevices.getUserMedia({audio:false, video:true}); | ||
}); | ||
await promise; | ||
internals.withUserGesture(() => { | ||
promise = navigator.mediaDevices.getUserMedia({audio:true, video:false}); | ||
}); | ||
await promise; | ||
|
||
internals.withUserGesture(() => { | ||
promise = navigator.mediaDevices.getUserMedia({audio:true, video:true}); | ||
}); | ||
await promise; | ||
|
||
await navigator.mediaDevices.getUserMedia({audio:false, video:true}).then(assert_unreached, (e) => { }); | ||
await navigator.mediaDevices.getUserMedia({audio:true, video:false}).then(assert_unreached, (e) => { }); | ||
await navigator.mediaDevices.getUserMedia({audio:true, video:true}).then(assert_unreached, (e) => { }); | ||
}, "Testing getUserMedia with and without user gesture after user denied access"); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
|
||
PASS Allow getDisplayMedia call in case of user gesture | ||
PASS Disallow getDisplayMedia calls in case of user gesture if not the first call | ||
PASS Deny getDisplayMedia call if no user gesture | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.