Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[MediaStream] Don't request user permission for a device if it has al…
…ready been granted in the current browsing context https://bugs.webkit.org/show_bug.cgi?id=164760 Source/WebKit2: <rdar://problem/29261266> Reviewed by Youenn Fablet. * UIProcess/UserMediaPermissionRequestManagerProxy.cpp: (WebKit::FrameAuthorizationState::FrameAuthorizationState): (WebKit::FrameAuthorizationState::hasPermissionToUseCaptureDevice): (WebKit::FrameAuthorizationState::setHasPermissionToUseCaptureDevice): (WebKit::FrameAuthorizationState::reset): (WebKit::FrameAuthorizationState::securityOriginsAreEqual): (WebKit::UserMediaPermissionRequestManagerProxy::stateForRequest): (WebKit::UserMediaPermissionRequestManagerProxy::invalidateRequests): (WebKit::UserMediaPermissionRequestManagerProxy::createRequest): (WebKit::UserMediaPermissionRequestManagerProxy::userMediaAccessWasDenied): (WebKit::UserMediaPermissionRequestManagerProxy::userMediaAccessWasGranted): (WebKit::UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame): * UIProcess/UserMediaPermissionRequestManagerProxy.h: (WebKit::FrameAuthorizationState::~FrameAuthorizationState): (WebKit::FrameAuthorizationState::frameID): * UIProcess/UserMediaPermissionRequestProxy.cpp: (WebKit::UserMediaPermissionRequestProxy::UserMediaPermissionRequestProxy): * UIProcess/UserMediaPermissionRequestProxy.h: (WebKit::UserMediaPermissionRequestProxy::create): (WebKit::UserMediaPermissionRequestProxy::frameID): (WebKit::UserMediaPermissionRequestProxy::userMediaDocumentSecurityOrigin): (WebKit::UserMediaPermissionRequestProxy::topLevelDocumentSecurityOrigin): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::didCommitLoadForFrame): * WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp: (WebKit::UserMediaPermissionRequestManager::removeMediaRequestFromMaps): Tools: <rdar://problem/29261266> Reviewed by Youenn Fablet. Allow scripts to determine the number of times the user has been prompted for capture device access. * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp: (WTR::InjectedBundle::setUserMediaPersistentPermissionForOrigin): (WTR::InjectedBundle::userMediaPermissionRequestCountForOrigin): (WTR::InjectedBundle::resetUserMediaPermissionRequestCountForOrigin): (WTR::InjectedBundle::setUserMediaPermissionForOrigin): Deleted. * WebKitTestRunner/InjectedBundle/InjectedBundle.h: * WebKitTestRunner/InjectedBundle/TestRunner.cpp: (WTR::TestRunner::setUserMediaPersistentPermissionForOrigin): (WTR::TestRunner::userMediaPermissionRequestCountForOrigin): (WTR::TestRunner::resetUserMediaPermissionRequestCountForOrigin): (WTR::TestRunner::setUserMediaPermissionForOrigin): Deleted. * WebKitTestRunner/InjectedBundle/TestRunner.h: * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetStateToConsistentValues): (WTR::OriginSettings::incrementRequestCount): (WTR::OriginSettings::resetRequestCount): (WTR::OriginSettings::requestCount): (WTR::TestController::saltForOrigin): (WTR::TestController::setUserMediaPersistentPermissionForOrigin): (WTR::TestController::handleCheckOfUserMediaPermissionForOrigin): (WTR::TestController::settingsForOrigin): (WTR::TestController::userMediaPermissionRequestCountForOrigin): (WTR::TestController::resetUserMediaPermissionRequestCountForOrigin): (WTR::TestController::decidePolicyForUserMediaPermissionRequestIfPossible): (WTR::TestController::setUserMediaPermissionForOrigin): Deleted. * WebKitTestRunner/TestController.h: * WebKitTestRunner/TestInvocation.cpp: (WTR::TestInvocation::didReceiveMessageFromInjectedBundle): (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle): LayoutTests: Reviewed by Youenn Fablet. * fast/mediastream/MediaDevices-getUserMedia-expected.txt: * fast/mediastream/MediaDevices-getUserMedia.html: Canonical link: https://commits.webkit.org/182772@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209082 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
512 additions
and 80 deletions.
- +10 −0 LayoutTests/ChangeLog
- +2 −2 LayoutTests/fast/mediastream/MediaDevices-enumerateDevices.html
- +3 −5 LayoutTests/fast/mediastream/MediaDevices-getUserMedia-expected.txt
- +12 −9 LayoutTests/fast/mediastream/MediaDevices-getUserMedia.html
- +1 −1 LayoutTests/http/tests/media/media-stream/enumerate-devices-source-id-persistent.html
- +29 −0 LayoutTests/http/tests/media/media-stream/get-user-media-prompt-expected.txt
- +68 −0 LayoutTests/http/tests/media/media-stream/get-user-media-prompt.html
- +35 −0 Source/WebKit2/ChangeLog
- +9 −0 Source/WebKit2/UIProcess/API/C/WKPage.cpp
- +3 −1 Source/WebKit2/UIProcess/API/C/WKPagePrivate.h
- +104 −18 Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp
- +23 −3 Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.h
- +8 −1 Source/WebKit2/UIProcess/UserMediaPermissionRequestProxy.cpp
- +14 −3 Source/WebKit2/UIProcess/UserMediaPermissionRequestProxy.h
- +6 −0 Source/WebKit2/UIProcess/WebPageProxy.cpp
- +2 −0 Source/WebKit2/UIProcess/WebPageProxy.h
- +41 −0 Tools/ChangeLog
- +3 −1 Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
- +34 −2 Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
- +3 −1 Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
- +16 −2 Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
- +5 −1 Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
- +44 −26 Tools/WebKitTestRunner/TestController.cpp
- +5 −2 Tools/WebKitTestRunner/TestController.h
- +32 −2 Tools/WebKitTestRunner/TestInvocation.cpp
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
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
@@ -0,0 +1,29 @@ | ||
Tests that user is only prompted once per device in the current browsing context. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS numberOfTimesGetUserMediaHasBeenCalled() is 0 | ||
|
||
** Request an audio-only stream, the user should be prompted ** | ||
PASS navigator.mediaDevices.getUserMedia({audio:true}).then(gotStream1); did not throw exception. | ||
PASS numberOfTimesGetUserMediaHasBeenCalled() is 1 | ||
PASS stream.getAudioTracks().length is 1 | ||
PASS stream.getVideoTracks().length is 0 | ||
|
||
** Request a video-only stream, the user should be prompted ** | ||
PASS navigator.mediaDevices.getUserMedia({video:true}).then(gotStream2); did not throw exception. | ||
PASS numberOfTimesGetUserMediaHasBeenCalled() is 2 | ||
PASS stream.getAudioTracks().length is 0 | ||
PASS stream.getVideoTracks().length is 1 | ||
|
||
** Request a stream with video and audio, the user should be not prompted ** | ||
PASS navigator.mediaDevices.getUserMedia({audio:true, video:true}).then(gotStream3); did not throw exception. | ||
PASS numberOfTimesGetUserMediaHasBeenCalled() is 2 | ||
PASS stream.getAudioTracks().length is 1 | ||
PASS stream.getVideoTracks().length is 1 | ||
|
||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
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
@@ -0,0 +1,68 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
iframe { border: 1px solid black; } | ||
</style> | ||
<script src="../../../../resources/js-test-pre.js"></script> | ||
<script> | ||
|
||
function numberOfTimesGetUserMediaHasBeenCalled() | ||
{ | ||
return testRunner.userMediaPermissionRequestCountForOrigin(document.location.href, document.location.href); | ||
} | ||
|
||
function gotStream3(s) | ||
{ | ||
stream = s; | ||
shouldBe("numberOfTimesGetUserMediaHasBeenCalled()", "2"); | ||
shouldBe("stream.getAudioTracks().length", "1"); | ||
shouldBe("stream.getVideoTracks().length", "1"); | ||
|
||
debug(""); | ||
finishJSTest(); | ||
} | ||
|
||
function gotStream2(s) | ||
{ | ||
stream = s; | ||
shouldBe("numberOfTimesGetUserMediaHasBeenCalled()", "2"); | ||
shouldBe("stream.getAudioTracks().length", "0"); | ||
shouldBe("stream.getVideoTracks().length", "1"); | ||
|
||
debug("<br>** Request a stream with video and audio, the user should be not prompted **"); | ||
shouldNotThrow("navigator.mediaDevices.getUserMedia({audio:true, video:true}).then(gotStream3);"); | ||
} | ||
|
||
function gotStream1(s) | ||
{ | ||
stream = s; | ||
shouldBe("numberOfTimesGetUserMediaHasBeenCalled()", "1"); | ||
shouldBe("stream.getAudioTracks().length", "1"); | ||
shouldBe("stream.getVideoTracks().length", "0"); | ||
|
||
debug("<br>** Request a video-only stream, the user should be prompted **"); | ||
shouldNotThrow("navigator.mediaDevices.getUserMedia({video:true}).then(gotStream2);") | ||
} | ||
|
||
function setup() | ||
{ | ||
description("Tests that user is only prompted once per device in the current browsing context."); | ||
|
||
testRunner.resetUserMediaPermissionRequestCountForOrigin(document.location.href, document.location.href); | ||
shouldBe("numberOfTimesGetUserMediaHasBeenCalled()", "0"); | ||
|
||
debug("<br>** Request an audio-only stream, the user should be prompted **"); | ||
shouldNotThrow("navigator.mediaDevices.getUserMedia({audio:true}).then(gotStream1);"); | ||
} | ||
|
||
if (window.testRunner) | ||
testRunner.setUserMediaPermission(true); | ||
window.jsTestIsAsync = true; | ||
window.successfullyParsed = true; | ||
</script> | ||
<script src="../../../../resources/js-test-post.js"></script> | ||
</head> | ||
<body onload="setup()"> | ||
</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
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.