Diff
Modified: trunk/LayoutTests/ChangeLog (217929 => 217930)
--- trunk/LayoutTests/ChangeLog 2017-06-08 13:24:26 UTC (rev 217929)
+++ trunk/LayoutTests/ChangeLog 2017-06-08 16:28:40 UTC (rev 217930)
@@ -1,3 +1,15 @@
+2017-06-08 Youenn Fablet <[email protected]>
+
+ getUserMedia request should not be allowed for background tabs unless the tab is already capturing
+ https://bugs.webkit.org/show_bug.cgi?id=172989
+
+ Reviewed by Eric Carlson.
+
+ * fast/mediastream/getUserMedia-grant-persistency-expected.txt:
+ * fast/mediastream/getUserMedia-grant-persistency.html: Using testRunner.setPageVisibility so that UIProcess is made aware of the change.
+ Removing test about capture muted page since there is no API for setting a page as muted right now.
+ This test should be readded later on.
+
2017-06-08 Charlie Turner <[email protected]>
[GTK] Test gardening
Modified: trunk/LayoutTests/fast/mediastream/getUserMedia-grant-persistency-expected.txt (217929 => 217930)
--- trunk/LayoutTests/fast/mediastream/getUserMedia-grant-persistency-expected.txt 2017-06-08 13:24:26 UTC (rev 217929)
+++ trunk/LayoutTests/fast/mediastream/getUserMedia-grant-persistency-expected.txt 2017-06-08 16:28:40 UTC (rev 217930)
@@ -1,6 +1,5 @@
PASS Testing same page getUserMedia grant persistency
-PASS Testing same page getUserMedia grant persistency in case page capture is in muted state
PASS Testing same page getUserMedia grant persistency after in page navigation
FAIL Testing same page getUserMedia grant persistency with visibility assert_true: Resolving getUserMedia promise should wait for page to be visible expected true got false
Modified: trunk/LayoutTests/fast/mediastream/getUserMedia-grant-persistency.html (217929 => 217930)
--- trunk/LayoutTests/fast/mediastream/getUserMedia-grant-persistency.html 2017-06-08 13:24:26 UTC (rev 217929)
+++ trunk/LayoutTests/fast/mediastream/getUserMedia-grant-persistency.html 2017-06-08 16:28:40 UTC (rev 217930)
@@ -7,6 +7,7 @@
<body>
<div id="navigateToSamePage"></div>
<script>
+
promise_test((test) => {
if (window.testRunner)
testRunner.setUserMediaPermission(true);
@@ -32,25 +33,6 @@
promise_test((test) => {
if (window.testRunner)
testRunner.setUserMediaPermission(true);
- return navigator.mediaDevices.getUserMedia({audio:true, video:true}).then((stream) => {
- if (window.testRunner)
- testRunner.setUserMediaPermission(false);
- return navigator.mediaDevices.getUserMedia({audio:true, video:true});
- }).then(() => {
- if (window.internals)
- internals.setPageMuted("capturedevices");
- return navigator.mediaDevices.getUserMedia({audio:true, video:true});
- }).then(() => {
- if (!window.internals)
- return;
- assert_true(internals.pageMediaState().includes("HasActiveVideoCaptureDevice"), "Check active video");
- assert_true(internals.pageMediaState().includes("HasActiveAudioCaptureDevice"), "Check active audio");
- });
-}, "Testing same page getUserMedia grant persistency in case page capture is in muted state");
-
-promise_test((test) => {
- if (window.testRunner)
- testRunner.setUserMediaPermission(true);
return navigator.mediaDevices.getUserMedia({audio:false, video:true}).then((stream) => {
if (window.testRunner)
testRunner.setUserMediaPermission(false);
@@ -70,13 +52,13 @@
if (window.testRunner)
testRunner.setUserMediaPermission(false);
isPageVisible = false;
- if (window.internals)
- internals.setPageVisibility(false);
+ if (window.testRunner)
+ testRunner.setPageVisibility("hidden");
setTimeout(() => {
isPageVisible = true;
- if (window.internals)
- internals.setPageVisibility(true);
- }, 100);
+ if (window.testRunner)
+ testRunner.setPageVisibility();
+ }, 1000);
return navigator.mediaDevices.getUserMedia({audio:false, video:true});
}).then(() => {
assert_true(isPageVisible, "Resolving getUserMedia promise should wait for page to be visible");
Modified: trunk/Source/WebKit2/ChangeLog (217929 => 217930)
--- trunk/Source/WebKit2/ChangeLog 2017-06-08 13:24:26 UTC (rev 217929)
+++ trunk/Source/WebKit2/ChangeLog 2017-06-08 16:28:40 UTC (rev 217930)
@@ -1,3 +1,31 @@
+2017-06-08 Youenn Fablet <[email protected]>
+
+ getUserMedia request should not be allowed for background tabs unless the tab is already capturing
+ https://bugs.webkit.org/show_bug.cgi?id=172989
+
+ Reviewed by Eric Carlson.
+
+ Covered by updated test and manual testing.
+
+ In case a getUserMedia can be granted, we check for visbility of the view.
+ If the view is visible, the getUserMedia request is allowed and promise is resolved.
+ Otherwise we store the pregranted request and will allow it when the view gets visible.
+ Pregranted requests will be cleared if the document of the view is changed.
+
+ Pregranted requests will not be used when capture page is muted.
+ In that case, a prompt will appear.
+
+ * UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
+ (WebKit::UserMediaPermissionRequestManagerProxy::removeGrantedAccess):
+ (WebKit::allowRequest):
+ (WebKit::UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame):
+ (WebKit::UserMediaPermissionRequestManagerProxy::processPregrantedRequests):
+ * UIProcess/UserMediaPermissionRequestManagerProxy.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::dispatchActivityStateChange):
+ (WebKit::WebPageProxy::viewIsBecomingVisible):
+ * UIProcess/WebPageProxy.h:
+
2017-06-07 Carlos Garcia Campos <[email protected]>
[WPE] Enable resource usage
Modified: trunk/Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp (217929 => 217930)
--- trunk/Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp 2017-06-08 13:24:26 UTC (rev 217929)
+++ trunk/Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp 2017-06-08 16:28:40 UTC (rev 217930)
@@ -164,15 +164,19 @@
}
#if ENABLE(MEDIA_STREAM)
-void UserMediaPermissionRequestManagerProxy::removeGrantedAccess(uint64_t frameID)
+void UserMediaPermissionRequestManagerProxy::resetAccess(uint64_t frameID)
{
m_grantedRequests.removeAllMatching([frameID](const auto& grantedRequest) {
return grantedRequest->mainFrameID() == frameID;
});
+ m_pregrantedRequests.clear();
}
const UserMediaPermissionRequestProxy* UserMediaPermissionRequestManagerProxy::searchForGrantedRequest(uint64_t frameID, const WebCore::SecurityOrigin& userMediaDocumentOrigin, const WebCore::SecurityOrigin& topLevelDocumentOrigin, bool needsAudio, bool needsVideo) const
{
+ if (m_page.isMediaStreamCaptureMuted())
+ return nullptr;
+
bool checkForAudio = needsAudio;
bool checkForVideo = needsVideo;
for (const auto& grantedRequest : m_grantedRequests) {
@@ -221,6 +225,11 @@
m_rejectionTimer.startOneShot(Seconds(mimimumDelayBeforeReplying + randomNumber()));
}
+static inline void allowRequest(UserMediaPermissionRequestProxy& request)
+{
+ request.allow(request.audioDeviceUIDs().isEmpty() ? String() : request.audioDeviceUIDs()[0], request.videoDeviceUIDs().isEmpty() ? String() : request.videoDeviceUIDs()[0]);
+}
+
void UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, Ref<WebCore::SecurityOrigin>&& userMediaDocumentOrigin, Ref<WebCore::SecurityOrigin>&& topLevelDocumentOrigin, const WebCore::MediaConstraints& audioConstraints, const WebCore::MediaConstraints& videoConstraints)
{
#if ENABLE(MEDIA_STREAM)
@@ -248,9 +257,12 @@
auto* grantedRequest = searchForGrantedRequest(frameID, userMediaDocumentOrigin.get(), topLevelDocumentOrigin.get(), !audioDeviceUIDs.isEmpty(), !videoDeviceUIDs.isEmpty());
if (grantedRequest) {
+ if (m_page.isViewVisible())
// We select the first available devices, but the current client API allows client to select which device to pick.
// FIXME: Remove the possiblity for the client to do the device selection.
- grantAccess(userMediaID, audioDeviceUIDs.isEmpty() ? String() : audioDeviceUIDs[0], videoDeviceUIDs.isEmpty() ? String() : videoDeviceUIDs[0], grantedRequest->deviceIdentifierHashSalt());
+ grantAccess(userMediaID, audioDeviceUIDs.isEmpty() ? String() : audioDeviceUIDs[0], videoDeviceUIDs.isEmpty() ? String() : videoDeviceUIDs[0], grantedRequest->deviceIdentifierHashSalt());
+ else
+ m_pregrantedRequests.append(createRequest(userMediaID, m_page.mainFrame()->frameID(), frameID, WTFMove(userMediaDocumentOrigin), WTFMove(topLevelDocumentOrigin), WTFMove(audioDeviceUIDs), WTFMove(videoDeviceUIDs), String(grantedRequest->deviceIdentifierHashSalt())));
return;
}
auto userMediaOrigin = API::SecurityOrigin::create(userMediaDocumentOrigin.get());
@@ -259,10 +271,7 @@
auto request = createRequest(userMediaID, m_page.mainFrame()->frameID(), frameID, WTFMove(userMediaDocumentOrigin), WTFMove(topLevelDocumentOrigin), WTFMove(audioDeviceUIDs), WTFMove(videoDeviceUIDs), WTFMove(deviceIdentifierHashSalt));
if (m_page.preferences().mockCaptureDevicesEnabled() && !m_page.preferences().mockCaptureDevicesPromptEnabled()) {
- // FIXME: https://bugs.webkit.org/show_bug.cgi?id=172989
- // We should probably only allow this if page is already actively capturing or page is visible.
- // If page is hidden and not capturing, we should wait for page to be visible before allowing the request.
- request->allow(request->audioDeviceUIDs().isEmpty() ? String() : request->audioDeviceUIDs()[0], request->videoDeviceUIDs().isEmpty() ? String() : request->videoDeviceUIDs()[0]);
+ allowRequest(request);
return;
}
@@ -367,4 +376,11 @@
#endif
}
+void UserMediaPermissionRequestManagerProxy::processPregrantedRequests()
+{
+ for (auto& request : m_pregrantedRequests)
+ allowRequest(request.get());
+ m_pregrantedRequests.clear();
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.h (217929 => 217930)
--- trunk/Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.h 2017-06-08 13:24:26 UTC (rev 217929)
+++ trunk/Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.h 2017-06-08 16:28:40 UTC (rev 217930)
@@ -47,7 +47,8 @@
void requestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, Ref<WebCore::SecurityOrigin>&& userMediaDocumentOrigin, Ref<WebCore::SecurityOrigin>&& topLevelDocumentOrigin, const WebCore::MediaConstraints& audioConstraints, const WebCore::MediaConstraints& videoConstraints);
- void removeGrantedAccess(uint64_t mainFrameID);
+ void resetAccess(uint64_t mainFrameID);
+ void processPregrantedRequests();
void userMediaAccessWasGranted(uint64_t, const String& audioDeviceUID, const String& videoDeviceUID);
void userMediaAccessWasDenied(uint64_t, UserMediaPermissionRequestProxy::UserMediaAccessDenialReason);
@@ -82,6 +83,7 @@
WebCore::Timer m_rejectionTimer;
Vector<uint64_t> m_pendingRejections;
+ Vector<Ref<UserMediaPermissionRequestProxy>> m_pregrantedRequests;
Vector<Ref<UserMediaPermissionRequestProxy>> m_grantedRequests;
};
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (217929 => 217930)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2017-06-08 13:24:26 UTC (rev 217929)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2017-06-08 16:28:40 UTC (rev 217930)
@@ -1520,6 +1520,9 @@
updateActivityState(m_potentiallyChangedActivityStateFlags);
ActivityState::Flags changed = m_activityState ^ previousActivityState;
+ if ((m_potentiallyChangedActivityStateFlags & ActivityState::IsVisible) && isViewVisible())
+ viewIsBecomingVisible();
+
bool isNowInWindow = (changed & ActivityState::IsInWindow) && isInWindow();
// We always want to wait for the Web process to reply if we've been in-window before and are coming back in-window.
if (m_viewWasEverInWindow && isNowInWindow) {
@@ -3515,12 +3518,19 @@
void WebPageProxy::didChangeMainDocument(uint64_t frameID)
{
#if ENABLE(MEDIA_STREAM)
- userMediaPermissionRequestManager().removeGrantedAccess(frameID);
+ userMediaPermissionRequestManager().resetAccess(frameID);
#else
UNUSED_PARAM(frameID);
#endif
}
+void WebPageProxy::viewIsBecomingVisible()
+{
+#if ENABLE(MEDIA_STREAM)
+ userMediaPermissionRequestManager().processPregrantedRequests();
+#endif
+}
+
void WebPageProxy::didReceiveTitleForFrame(uint64_t frameID, const String& title, const UserData& userData)
{
PageClientProtector protector(m_pageClient);
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (217929 => 217930)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2017-06-08 13:24:26 UTC (rev 217929)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2017-06-08 16:28:40 UTC (rev 217930)
@@ -471,6 +471,7 @@
bool isEditable() const { return m_isEditable; }
void activateMediaStreamCaptureInPage() { setMuted(m_mutedState & ~WebCore::MediaProducer::CaptureDevicesAreMuted); }
+ bool isMediaStreamCaptureMuted() const { return m_mutedState & WebCore::MediaProducer::CaptureDevicesAreMuted; }
#if PLATFORM(IOS)
void executeEditCommand(const String& commandName, std::function<void (CallbackBase::Error)>);
@@ -1608,6 +1609,8 @@
void handleMessage(IPC::Connection&, const String& messageName, const UserData& messageBody);
void handleSynchronousMessage(IPC::Connection&, const String& messageName, const UserData& messageBody, UserData& returnUserData);
+ void viewIsBecomingVisible();
+
PageClient& m_pageClient;
Ref<API::PageConfiguration> m_configuration;