haikuwebkit/LayoutTests/fast/mediastream/getUserMedia-deny-persisten...

48 lines
1.8 KiB
HTML
Raw Permalink Normal View History

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
2019-11-05 09:14:33 +00:00
<!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;
Remove getUserMedia denied requests if user grants a new getUserMedia request https://bugs.webkit.org/show_bug.cgi?id=222962 <rdar://74805451> Reviewed by Eric Carlson. Source/WebKit: A user may deny an audio getUserMedia request. On user gesture, user may be reprompted, in which case user may grant access. Before the patch, after these two getUserMedia calls, if the web page was trying to call getUserMedia without user gesture, it would fail. With this patch, we remove the first denied request based on the second granted request. This allows getUserMedia to be granted, even without a user gesture. Tests: fast/mediastream/granted-denied-request-management1.html fast/mediastream/granted-denied-request-management2.html * UIProcess/UserMediaPermissionRequestManagerProxy.cpp: (WebKit::UserMediaPermissionRequestManagerProxy::finishGrantingRequest): (WebKit::isMatchingDeniedRequest): (WebKit::UserMediaPermissionRequestManagerProxy::wasRequestDenied): (WebKit::UserMediaPermissionRequestManagerProxy::updateStoredRequests): (WebKit::UserMediaPermissionRequestManagerProxy::getRequestAction): * UIProcess/UserMediaPermissionRequestManagerProxy.h: LayoutTests: * fast/mediastream/getUserMedia-deny-persistency5.html: Update according new heuristic. * fast/mediastream/granted-denied-request-management1-expected.txt: Added. * fast/mediastream/granted-denied-request-management1.html: Added. * fast/mediastream/granted-denied-request-management2-expected.txt: Added. * fast/mediastream/granted-denied-request-management2.html: Added. Canonical link: https://commits.webkit.org/235122@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274206 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-10 11:52:49 +00:00
// We still have audio denied.
await navigator.mediaDevices.getUserMedia({audio:true, video:false}).then(assert_unreached, (e) => { });
await navigator.mediaDevices.getUserMedia({audio:true, video:true}).then(assert_unreached, (e) => { });
await navigator.mediaDevices.getUserMedia({audio:false, video:true});
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
2019-11-05 09:14:33 +00:00
internals.withUserGesture(() => {
Remove getUserMedia denied requests if user grants a new getUserMedia request https://bugs.webkit.org/show_bug.cgi?id=222962 <rdar://74805451> Reviewed by Eric Carlson. Source/WebKit: A user may deny an audio getUserMedia request. On user gesture, user may be reprompted, in which case user may grant access. Before the patch, after these two getUserMedia calls, if the web page was trying to call getUserMedia without user gesture, it would fail. With this patch, we remove the first denied request based on the second granted request. This allows getUserMedia to be granted, even without a user gesture. Tests: fast/mediastream/granted-denied-request-management1.html fast/mediastream/granted-denied-request-management2.html * UIProcess/UserMediaPermissionRequestManagerProxy.cpp: (WebKit::UserMediaPermissionRequestManagerProxy::finishGrantingRequest): (WebKit::isMatchingDeniedRequest): (WebKit::UserMediaPermissionRequestManagerProxy::wasRequestDenied): (WebKit::UserMediaPermissionRequestManagerProxy::updateStoredRequests): (WebKit::UserMediaPermissionRequestManagerProxy::getRequestAction): * UIProcess/UserMediaPermissionRequestManagerProxy.h: LayoutTests: * fast/mediastream/getUserMedia-deny-persistency5.html: Update according new heuristic. * fast/mediastream/granted-denied-request-management1-expected.txt: Added. * fast/mediastream/granted-denied-request-management1.html: Added. * fast/mediastream/granted-denied-request-management2-expected.txt: Added. * fast/mediastream/granted-denied-request-management2.html: Added. Canonical link: https://commits.webkit.org/235122@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274206 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-10 11:52:49 +00:00
promise = navigator.mediaDevices.getUserMedia({audio:true, video:false});
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
2019-11-05 09:14:33 +00:00
});
await promise;
Remove getUserMedia denied requests if user grants a new getUserMedia request https://bugs.webkit.org/show_bug.cgi?id=222962 <rdar://74805451> Reviewed by Eric Carlson. Source/WebKit: A user may deny an audio getUserMedia request. On user gesture, user may be reprompted, in which case user may grant access. Before the patch, after these two getUserMedia calls, if the web page was trying to call getUserMedia without user gesture, it would fail. With this patch, we remove the first denied request based on the second granted request. This allows getUserMedia to be granted, even without a user gesture. Tests: fast/mediastream/granted-denied-request-management1.html fast/mediastream/granted-denied-request-management2.html * UIProcess/UserMediaPermissionRequestManagerProxy.cpp: (WebKit::UserMediaPermissionRequestManagerProxy::finishGrantingRequest): (WebKit::isMatchingDeniedRequest): (WebKit::UserMediaPermissionRequestManagerProxy::wasRequestDenied): (WebKit::UserMediaPermissionRequestManagerProxy::updateStoredRequests): (WebKit::UserMediaPermissionRequestManagerProxy::getRequestAction): * UIProcess/UserMediaPermissionRequestManagerProxy.h: LayoutTests: * fast/mediastream/getUserMedia-deny-persistency5.html: Update according new heuristic. * fast/mediastream/granted-denied-request-management1-expected.txt: Added. * fast/mediastream/granted-denied-request-management1.html: Added. * fast/mediastream/granted-denied-request-management2-expected.txt: Added. * fast/mediastream/granted-denied-request-management2.html: Added. Canonical link: https://commits.webkit.org/235122@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274206 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-10 11:52:49 +00:00
// We should neither have audio nor video denied anymore.
await navigator.mediaDevices.getUserMedia({audio:true, video:false});
await navigator.mediaDevices.getUserMedia({audio:true, video:true});
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
2019-11-05 09:14:33 +00:00
}, "Testing getUserMedia with and without user gesture after user denied access");
</script>
</body>
</html>