Unreviewed, rolling out r209008.
authorryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Nov 2016 22:41:23 +0000 (22:41 +0000)
committerryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Nov 2016 22:41:23 +0000 (22:41 +0000)
This change appears to have caused two fast/mediastrem
LayoutTests to fail.

Reverted changeset:

"[MediaStream] Don't request user permission for a device if
it has already been granted in the current browsing context"
https://bugs.webkit.org/show_bug.cgi?id=164760
http://trac.webkit.org/changeset/209008

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209024 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/mediastream/MediaDevices-enumerateDevices.html
LayoutTests/http/tests/media/media-stream/enumerate-devices-source-id-persistent.html
LayoutTests/http/tests/media/media-stream/get-user-media-prompt-expected.txt [deleted file]
LayoutTests/http/tests/media/media-stream/get-user-media-prompt.html [deleted file]
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp
Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.h
Source/WebKit2/UIProcess/UserMediaPermissionRequestProxy.cpp
Source/WebKit2/UIProcess/UserMediaPermissionRequestProxy.h
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestInvocation.cpp

index 49c5e36..bfe8d5f 100644 (file)
@@ -1,3 +1,17 @@
+2016-11-28  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r209008.
+
+        This change appears to have caused two fast/mediastrem
+        LayoutTests to fail.
+
+        Reverted changeset:
+
+        "[MediaStream] Don't request user permission for a device if
+        it has already been granted in the current browsing context"
+        https://bugs.webkit.org/show_bug.cgi?id=164760
+        http://trac.webkit.org/changeset/209008
+
 2016-11-28  Eric Carlson  <eric.carlson@apple.com>
 
         [MediaStream] Don't request user permission for a device if it has already been granted in the current browsing context
index 252d503..3e2fa32 100644 (file)
@@ -58,7 +58,7 @@
             {
                 if (window.testRunner) {
                     testRunner.setUserMediaPermission(true);
-                    testRunner.setUserMediaPersistentPermissionForOrigin(false, document.location.href, "");
+                    testRunner.setUserMediaPermissionForOrigin(false, document.location.href, "");
                 }
 
                 navigator.mediaDevices
@@ -77,7 +77,7 @@
             function grantPermission()
             {
                 if (window.testRunner)
-                    testRunner.setUserMediaPersistentPermissionForOrigin(true, document.location.href, "");
+                    testRunner.setUserMediaPermissionForOrigin(true, document.location.href, "");
 
                 debug(`<br>*** Calling mediaDevices.enumerateDevices with persistent access, and without a media stream track<br>`);
                 havePermission = true;
index cb4e349..2a0d3de 100644 (file)
@@ -11,7 +11,7 @@
 
             if (window.testRunner) {
                 testRunner.setUserMediaPermission(true);
-                testRunner.setUserMediaPersistentPermissionForOrigin(true, "http://localhost:8000", location.href);
+                testRunner.setUserMediaPermissionForOrigin(true, "http://localhost:8000", location.href);
             }
 
             function setup()
diff --git a/LayoutTests/http/tests/media/media-stream/get-user-media-prompt-expected.txt b/LayoutTests/http/tests/media/media-stream/get-user-media-prompt-expected.txt
deleted file mode 100644 (file)
index 3d572dd..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-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
-
diff --git a/LayoutTests/http/tests/media/media-stream/get-user-media-prompt.html b/LayoutTests/http/tests/media/media-stream/get-user-media-prompt.html
deleted file mode 100644 (file)
index 30f2226..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-<!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>
index 0b41485..db9c051 100644 (file)
@@ -1,3 +1,17 @@
+2016-11-28  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r209008.
+
+        This change appears to have caused two fast/mediastrem
+        LayoutTests to fail.
+
+        Reverted changeset:
+
+        "[MediaStream] Don't request user permission for a device if
+        it has already been granted in the current browsing context"
+        https://bugs.webkit.org/show_bug.cgi?id=164760
+        http://trac.webkit.org/changeset/209008
+
 2016-11-28  Andrew Gold  <agold@apple.com>
 
         Support for HTML Media Capture API
index 2194b4e..0f81e0b 100644 (file)
@@ -34,61 +34,6 @@ using namespace WebCore;
 
 namespace WebKit {
 
-FrameAuthorizationState::FrameAuthorizationState(UserMediaPermissionRequestProxy& request)
-    : m_userMediaDocumentSecurityOrigin(request.userMediaDocumentSecurityOrigin())
-    , m_topLevelDocumentSecurityOrigin(request.topLevelDocumentSecurityOrigin())
-{
-}
-
-bool FrameAuthorizationState::hasPermissionToUseCaptureDevice(const String& deviceUID)
-{
-    return m_authorizedDeviceUIDs.find(deviceUID) != notFound;
-}
-
-void FrameAuthorizationState::setHasPermissionToUseCaptureDevice(const String& deviceUID, bool hasPermission)
-{
-    if (deviceUID.isEmpty())
-        return;
-
-    size_t index = m_authorizedDeviceUIDs.find(deviceUID);
-    if (hasPermission == (index != notFound))
-        return;
-
-    if (hasPermission)
-        m_authorizedDeviceUIDs.append(deviceUID);
-    else
-        m_authorizedDeviceUIDs.remove(index);
-}
-
-void FrameAuthorizationState::ensureSecurityOriginsAreEqual(UserMediaPermissionRequestProxy& request)
-{
-    do {
-        if (!m_userMediaDocumentSecurityOrigin || !m_userMediaDocumentSecurityOrigin->equal(request.userMediaDocumentSecurityOrigin()))
-            break;
-
-        if (!m_topLevelDocumentSecurityOrigin || !m_topLevelDocumentSecurityOrigin->equal(request.topLevelDocumentSecurityOrigin()))
-            break;
-
-        return;
-    } while (0);
-
-    m_userMediaDocumentSecurityOrigin = request.userMediaDocumentSecurityOrigin();
-    m_topLevelDocumentSecurityOrigin = request.topLevelDocumentSecurityOrigin();
-    m_authorizedDeviceUIDs.clear();
-}
-
-FrameAuthorizationState& UserMediaPermissionRequestManagerProxy::stateForRequest(UserMediaPermissionRequestProxy& request)
-{
-    auto& state = m_frameStates.add(request.frameID(), nullptr).iterator->value;
-    if (state) {
-        state->ensureSecurityOriginsAreEqual(request);
-        return *state;
-    }
-
-    state = std::make_unique<FrameAuthorizationState>(request);
-    return *state;
-}
-
 UserMediaPermissionRequestManagerProxy::UserMediaPermissionRequestManagerProxy(WebPageProxy& page)
     : m_page(page)
 {
@@ -104,12 +49,19 @@ void UserMediaPermissionRequestManagerProxy::invalidateRequests()
         request->invalidate();
     m_pendingDeviceRequests.clear();
 
-    m_frameStates.clear();
+    m_pageSandboxExtensionsGranted.clear();
+}
+
+Ref<UserMediaPermissionRequestProxy> UserMediaPermissionRequestManagerProxy::createRequest(uint64_t userMediaID, const Vector<String>& audioDeviceUIDs, const Vector<String>& videoDeviceUIDs)
+{
+    Ref<UserMediaPermissionRequestProxy> request = UserMediaPermissionRequestProxy::create(*this, userMediaID, audioDeviceUIDs, videoDeviceUIDs);
+    m_pendingUserMediaRequests.add(userMediaID, request.ptr());
+    return request;
 }
 
-Ref<UserMediaPermissionRequestProxy> UserMediaPermissionRequestManagerProxy::createRequest(uint64_t userMediaID, uint64_t frameID, const String& userMediaDocumentOriginIdentifier, const String& topLevelDocumentOriginIdentifier, const Vector<String>& audioDeviceUIDs, const Vector<String>& videoDeviceUIDs)
+Ref<UserMediaPermissionRequestProxy> UserMediaPermissionRequestManagerProxy::createRequest(uint64_t userMediaID)
 {
-    auto request = UserMediaPermissionRequestProxy::create(*this, userMediaID, frameID, userMediaDocumentOriginIdentifier, topLevelDocumentOriginIdentifier, audioDeviceUIDs, videoDeviceUIDs);
+    Ref<UserMediaPermissionRequestProxy> request = UserMediaPermissionRequestProxy::create(*this, userMediaID, Vector<String>(), Vector<String>());
     m_pendingUserMediaRequests.add(userMediaID, request.ptr());
     return request;
 }
@@ -151,17 +103,10 @@ void UserMediaPermissionRequestManagerProxy::userMediaAccessWasDenied(uint64_t u
     if (!m_page.isValid())
         return;
 
-    auto request = m_pendingUserMediaRequests.take(userMediaID);
-    if (!request)
+    if (!m_pendingUserMediaRequests.take(userMediaID))
         return;
 
-    auto fameState = stateForRequest(*request);
-    for (const auto& deviceUID : request->videoDeviceUIDs())
-        fameState.setHasPermissionToUseCaptureDevice(deviceUID, false);
-    for (const auto& deviceUID : request->audioDeviceUIDs())
-        fameState.setHasPermissionToUseCaptureDevice(deviceUID, false);
-
-    denyRequest(userMediaID, reason, emptyString());
+    denyRequest(userMediaID, reason, "");
 }
 
 void UserMediaPermissionRequestManagerProxy::denyRequest(uint64_t userMediaID, UserMediaPermissionRequestProxy::UserMediaAccessDenialReason reason, const String& invalidConstraint)
@@ -183,15 +128,10 @@ void UserMediaPermissionRequestManagerProxy::userMediaAccessWasGranted(uint64_t
     if (!m_page.isValid())
         return;
 
-#if ENABLE(MEDIA_STREAM)
-    auto request = m_pendingUserMediaRequests.take(userMediaID);
-    if (!request)
+    if (!m_pendingUserMediaRequests.take(userMediaID))
         return;
 
-    auto& fameState = stateForRequest(*request);
-    fameState.setHasPermissionToUseCaptureDevice(audioDeviceUID, true);
-    fameState.setHasPermissionToUseCaptureDevice(videoDeviceUID, true);
-
+#if ENABLE(MEDIA_STREAM)
     size_t extensionCount = 0;
     unsigned requiredExtensions = SandboxExtensionsGranted::None;
     if (!audioDeviceUID.isEmpty()) {
@@ -203,10 +143,10 @@ void UserMediaPermissionRequestManagerProxy::userMediaAccessWasGranted(uint64_t
         extensionCount++;
     }
 
-    unsigned currentExtensions = m_pageSandboxExtensionsGranted;
+    unsigned currentExtensions = m_pageSandboxExtensionsGranted.get(m_page.pageID());
     if (!(requiredExtensions & currentExtensions)) {
         ASSERT(extensionCount);
-        m_pageSandboxExtensionsGranted = requiredExtensions | currentExtensions;
+        m_pageSandboxExtensionsGranted.set(m_page.pageID(), requiredExtensions | currentExtensions);
         SandboxExtension::HandleArray handles;
         handles.allocate(extensionCount);
         if (!videoDeviceUID.isEmpty())
@@ -218,7 +158,6 @@ void UserMediaPermissionRequestManagerProxy::userMediaAccessWasGranted(uint64_t
 
     m_page.process().send(Messages::WebPage::UserMediaAccessWasGranted(userMediaID, audioDeviceUID, videoDeviceUID), m_page.pageID());
 #else
-    UNUSED_PARAM(userMediaID);
     UNUSED_PARAM(audioDeviceUID);
     UNUSED_PARAM(videoDeviceUID);
 #endif
@@ -239,38 +178,18 @@ void UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame(
             return;
 
         if (videoDeviceUIDs.isEmpty() && audioDeviceUIDs.isEmpty()) {
-            denyRequest(userMediaID, UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::NoConstraints, emptyString());
+            denyRequest(userMediaID, UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::NoConstraints, "");
             return;
         }
 
         auto userMediaOrigin = API::SecurityOrigin::create(SecurityOriginData::fromDatabaseIdentifier(userMediaDocumentOriginIdentifier)->securityOrigin());
         auto topLevelOrigin = API::SecurityOrigin::create(SecurityOriginData::fromDatabaseIdentifier(topLevelDocumentOriginIdentifier)->securityOrigin());
-        auto request = createRequest(userMediaID, frameID, userMediaDocumentOriginIdentifier, topLevelDocumentOriginIdentifier, audioDeviceUIDs, videoDeviceUIDs);
-
-        String authorizedAudioDevice;
-        String authorizedVideoDevice;
-        auto& fameState = stateForRequest(request);
-        for (auto deviceUID : audioDeviceUIDs) {
-            if (fameState.hasPermissionToUseCaptureDevice(deviceUID)) {
-                authorizedAudioDevice = deviceUID;
-                break;
-            }
-        }
-        for (auto deviceUID : videoDeviceUIDs) {
-            if (fameState.hasPermissionToUseCaptureDevice(deviceUID)) {
-                authorizedVideoDevice = deviceUID;
-                break;
-            }
-        }
+        auto request = createRequest(userMediaID, audioDeviceUIDs, videoDeviceUIDs);
 
-        if (audioDeviceUIDs.isEmpty() == authorizedAudioDevice.isEmpty() && videoDeviceUIDs.isEmpty() == authorizedVideoDevice.isEmpty()) {
-            userMediaAccessWasGranted(userMediaID, authorizedAudioDevice, authorizedVideoDevice);
-            return;
+        if (!m_page.uiClient().decidePolicyForUserMediaPermissionRequest(m_page, *m_page.process().webFrame(frameID), *userMediaOrigin.get(), *topLevelOrigin.get(), request.get())) {
+            m_pendingUserMediaRequests.take(userMediaID);
+            request->deny(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::UserMediaDisabled);
         }
-
-        if (!m_page.uiClient().decidePolicyForUserMediaPermissionRequest(m_page, *m_page.process().webFrame(frameID), *userMediaOrigin.get(), *topLevelOrigin.get(), request.get()))
-            userMediaAccessWasDenied(userMediaID, UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::UserMediaDisabled);
-        
     };
 
     auto audioConstraints = MediaConstraintsImpl::create(audioConstraintsData);
index 10268a6..d866285 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "UserMediaPermissionCheckProxy.h"
 #include "UserMediaPermissionRequestProxy.h"
-#include <WebCore/SecurityOrigin.h>
 #include <WebCore/UserMediaRequest.h>
 #include <wtf/HashMap.h>
 
@@ -35,21 +34,6 @@ namespace WebKit {
 
 class WebPageProxy;
 
-class FrameAuthorizationState {
-public:
-    explicit FrameAuthorizationState(UserMediaPermissionRequestProxy&);
-
-    bool hasPermissionToUseCaptureDevice(const String& deviceUID);
-    void setHasPermissionToUseCaptureDevice(const String&, bool);
-
-    void ensureSecurityOriginsAreEqual(UserMediaPermissionRequestProxy&);
-
-private:
-    RefPtr<WebCore::SecurityOrigin> m_userMediaDocumentSecurityOrigin;
-    RefPtr<WebCore::SecurityOrigin> m_topLevelDocumentSecurityOrigin;
-    Vector<String> m_authorizedDeviceUIDs;
-};
-
 class UserMediaPermissionRequestManagerProxy {
 public:
     explicit UserMediaPermissionRequestManagerProxy(WebPageProxy&);
@@ -60,14 +44,14 @@ public:
 
     void userMediaAccessWasGranted(uint64_t, const String& audioDeviceUID, const String& videoDeviceUID);
     void userMediaAccessWasDenied(uint64_t, UserMediaPermissionRequestProxy::UserMediaAccessDenialReason);
-    FrameAuthorizationState& stateForRequest(UserMediaPermissionRequestProxy&);
 
     void enumerateMediaDevicesForFrame(uint64_t userMediaID, uint64_t frameID, String userMediaDocumentOriginIdentifier, String topLevelDocumentOriginIdentifier);
 
     void didCompleteUserMediaPermissionCheck(uint64_t, const String&, bool allow);
 
 private:
-    Ref<UserMediaPermissionRequestProxy> createRequest(uint64_t userMediaID, uint64_t frameID, const String&userMediaDocumentOriginIdentifier, const String& topLevelDocumentOriginIdentifier, const Vector<String>& audioDeviceUIDs, const Vector<String>& videoDeviceUIDs);
+    Ref<UserMediaPermissionRequestProxy> createRequest(uint64_t, const Vector<String>& audioDeviceUIDs, const Vector<String>& videoDeviceUIDs);
+    Ref<UserMediaPermissionRequestProxy> createRequest(uint64_t userMediaID);
     void denyRequest(uint64_t userMediaID, UserMediaPermissionRequestProxy::UserMediaAccessDenialReason, const String& invalidConstraint);
     Ref<UserMediaPermissionCheckProxy> createUserMediaPermissionCheck(uint64_t userMediaID);
     void syncWithWebCorePrefs() const;
@@ -80,9 +64,7 @@ private:
         Video = 1 << 0,
         Audio = 1 << 1
     };
-    unsigned m_pageSandboxExtensionsGranted;
-
-    HashMap<uint64_t, std::unique_ptr<FrameAuthorizationState>> m_frameStates;
+    HashMap<uint64_t, unsigned> m_pageSandboxExtensionsGranted;
 
     WebPageProxy& m_page;
 };
index d56f3d6..ef20d4f 100644 (file)
 
 #include "UserMediaPermissionRequestManagerProxy.h"
 #include <WebCore/RealtimeMediaSourceCenter.h>
-#include <WebCore/SecurityOrigin.h>
-#include <WebCore/SecurityOriginData.h>
 #include <wtf/text/StringHash.h>
 
-using namespace WebCore;
-
 namespace WebKit {
 
-UserMediaPermissionRequestProxy::UserMediaPermissionRequestProxy(UserMediaPermissionRequestManagerProxy& manager, uint64_t userMediaID, uint64_t frameID, const String& userMediaDocumentOriginIdentifier, const String& topLevelDocumentOriginIdentifier, const Vector<String>& audioDeviceUIDs, const Vector<String>& videoDeviceUIDs)
+UserMediaPermissionRequestProxy::UserMediaPermissionRequestProxy(UserMediaPermissionRequestManagerProxy& manager, uint64_t userMediaID, const Vector<String>& audioDeviceUIDs, const Vector<String>& videoDeviceUIDs)
     : m_manager(&manager)
     , m_userMediaID(userMediaID)
-    , m_frameID(frameID)
-    , m_userMediaDocumentSecurityOrigin((SecurityOriginData::fromDatabaseIdentifier(userMediaDocumentOriginIdentifier)->securityOrigin()))
-    , m_topLevelDocumentSecurityOrigin(SecurityOriginData::fromDatabaseIdentifier(topLevelDocumentOriginIdentifier)->securityOrigin())
     , m_videoDeviceUIDs(videoDeviceUIDs)
     , m_audioDeviceUIDs(audioDeviceUIDs)
 {
index b2c25c5..385005b 100644 (file)
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
 
-namespace WebCore {
-class SecurityOrigin;
-}
-
 namespace WebKit {
 
 class UserMediaPermissionRequestManagerProxy;
 
 class UserMediaPermissionRequestProxy : public API::ObjectImpl<API::Object::Type::UserMediaPermissionRequest> {
 public:
-    static Ref<UserMediaPermissionRequestProxy> create(UserMediaPermissionRequestManagerProxy& manager, uint64_t userMediaID, uint64_t frameID, const String& userMediaDocumentOriginIdentifier, const String& topLevelDocumentOriginIdentifier, const Vector<String>& videoDeviceUIDs, const Vector<String>& audioDeviceUIDs)
+    static Ref<UserMediaPermissionRequestProxy> create(UserMediaPermissionRequestManagerProxy& manager, uint64_t userMediaID, const Vector<String>& videoDeviceUIDs, const Vector<String>& audioDeviceUIDs)
     {
-        return adoptRef(*new UserMediaPermissionRequestProxy(manager, userMediaID, frameID, userMediaDocumentOriginIdentifier, topLevelDocumentOriginIdentifier, videoDeviceUIDs, audioDeviceUIDs));
+        return adoptRef(*new UserMediaPermissionRequestProxy(manager, userMediaID, videoDeviceUIDs, audioDeviceUIDs));
     }
 
     void allow(const String& videoDeviceUID, const String& audioDeviceUID);
@@ -53,18 +49,11 @@ public:
     const Vector<String>& videoDeviceUIDs() const { return m_videoDeviceUIDs; }
     const Vector<String>& audioDeviceUIDs() const { return m_audioDeviceUIDs; }
 
-    uint64_t frameID() const { return m_frameID; }
-    WebCore::SecurityOrigin* userMediaDocumentSecurityOrigin() { return &m_userMediaDocumentSecurityOrigin.get(); }
-    WebCore::SecurityOrigin* topLevelDocumentSecurityOrigin() { return &m_topLevelDocumentSecurityOrigin.get(); }
-
 private:
-    UserMediaPermissionRequestProxy(UserMediaPermissionRequestManagerProxy&, uint64_t userMediaID, uint64_t frameID, const String& userMediaDocumentOriginIdentifier, const String& topLevelDocumentOriginIdentifier, const Vector<String>& videoDeviceUIDs, const Vector<String>& audioDeviceUIDs);
+    UserMediaPermissionRequestProxy(UserMediaPermissionRequestManagerProxy&, uint64_t userMediaID, const Vector<String>& videoDeviceUIDs, const Vector<String>& audioDeviceUIDs);
 
     UserMediaPermissionRequestManagerProxy* m_manager;
     uint64_t m_userMediaID;
-    uint64_t m_frameID;
-    Ref<WebCore::SecurityOrigin> m_userMediaDocumentSecurityOrigin;
-    Ref<WebCore::SecurityOrigin> m_topLevelDocumentSecurityOrigin;
     Vector<String> m_videoDeviceUIDs;
     Vector<String> m_audioDeviceUIDs;
 };
index 05de702..984dc95 100644 (file)
@@ -1,3 +1,17 @@
+2016-11-28  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r209008.
+
+        This change appears to have caused two fast/mediastrem
+        LayoutTests to fail.
+
+        Reverted changeset:
+
+        "[MediaStream] Don't request user permission for a device if
+        it has already been granted in the current browsing context"
+        https://bugs.webkit.org/show_bug.cgi?id=164760
+        http://trac.webkit.org/changeset/209008
+
 2016-11-28  Daniel Bates  <dabates@apple.com>
 
         Teach webkitpy how to read CSSProperties.json r209001
index 62d80ee..db9daca 100644 (file)
@@ -185,9 +185,7 @@ interface TestRunner {
 
     // MediaStream
     void setUserMediaPermission(boolean value);
-    void setUserMediaPersistentPermissionForOrigin(boolean permission, DOMString origin, DOMString parentOrigin);
-    unsigned long userMediaPermissionRequestCountForOrigin(DOMString origin, DOMString parentOrigin);
-    void resetUserMediaPermissionRequestCountForOrigin(DOMString origin, DOMString parentOrigin);
+    void setUserMediaPermissionForOrigin(boolean permission, DOMString origin, DOMString parentOrigin);
 
     // Audio testing.
     [PassContext] void setAudioResult(object data);
index 8636fa0..a20ca76 100644 (file)
@@ -582,9 +582,9 @@ void InjectedBundle::setUserMediaPermission(bool enabled)
     WKBundlePagePostMessage(page()->page(), messageName.get(), messageBody.get());
 }
 
-void InjectedBundle::setUserMediaPersistentPermissionForOrigin(bool permission, WKStringRef origin, WKStringRef parentOrigin)
+void InjectedBundle::setUserMediaPermissionForOrigin(bool permission, WKStringRef origin, WKStringRef parentOrigin)
 {
-    auto messageName = adoptWK(WKStringCreateWithUTF8CString("SetUserMediaPersistentPermissionForOrigin"));
+    auto messageName = adoptWK(WKStringCreateWithUTF8CString("SetUserMediaPermissionForOrigin"));
     WKRetainPtr<WKMutableDictionaryRef> messageBody(AdoptWK, WKMutableDictionaryCreate());
 
     WKRetainPtr<WKStringRef> permissionKeyWK(AdoptWK, WKStringCreateWithUTF8CString("permission"));
@@ -600,38 +600,6 @@ void InjectedBundle::setUserMediaPersistentPermissionForOrigin(bool permission,
     WKBundlePagePostMessage(page()->page(), messageName.get(), messageBody.get());
 }
 
-unsigned InjectedBundle::userMediaPermissionRequestCountForOrigin(WKStringRef origin, WKStringRef parentOrigin) const
-{
-    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("UserMediaPermissionRequestCountForOrigin"));
-    WKRetainPtr<WKMutableDictionaryRef> messageBody(AdoptWK, WKMutableDictionaryCreate());
-
-    WKRetainPtr<WKStringRef> originKeyWK(AdoptWK, WKStringCreateWithUTF8CString("origin"));
-    WKDictionarySetItem(messageBody.get(), originKeyWK.get(), origin);
-
-    WKRetainPtr<WKStringRef> parentOriginKeyWK(AdoptWK, WKStringCreateWithUTF8CString("parentOrigin"));
-    WKDictionarySetItem(messageBody.get(), parentOriginKeyWK.get(), parentOrigin);
-
-    WKTypeRef resultToPass = 0;
-    WKBundlePagePostSynchronousMessageForTesting(page()->page(), messageName.get(), messageBody.get(), &resultToPass);
-    WKRetainPtr<WKUInt64Ref> count(AdoptWK, static_cast<WKUInt64Ref>(resultToPass));
-
-    return static_cast<unsigned>(WKUInt64GetValue(count.get()));
-}
-
-void InjectedBundle::resetUserMediaPermissionRequestCountForOrigin(WKStringRef origin, WKStringRef parentOrigin)
-{
-    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("ResetUserMediaPermissionRequestCountForOrigin"));
-    WKRetainPtr<WKMutableDictionaryRef> messageBody(AdoptWK, WKMutableDictionaryCreate());
-
-    WKRetainPtr<WKStringRef> originKeyWK(AdoptWK, WKStringCreateWithUTF8CString("origin"));
-    WKDictionarySetItem(messageBody.get(), originKeyWK.get(), origin);
-
-    WKRetainPtr<WKStringRef> parentOriginKeyWK(AdoptWK, WKStringCreateWithUTF8CString("parentOrigin"));
-    WKDictionarySetItem(messageBody.get(), parentOriginKeyWK.get(), parentOrigin);
-
-    WKBundlePagePostMessage(page()->page(), messageName.get(), messageBody.get());
-}
-
 void InjectedBundle::setCustomPolicyDelegate(bool enabled, bool permissive)
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetCustomPolicyDelegate"));
index e4a4045..069998b 100644 (file)
@@ -101,9 +101,7 @@ public:
 
     // MediaStream.
     void setUserMediaPermission(bool);
-    void setUserMediaPersistentPermissionForOrigin(bool permission, WKStringRef origin, WKStringRef parentOrigin);
-    unsigned userMediaPermissionRequestCountForOrigin(WKStringRef origin, WKStringRef parentOrigin) const;
-    void resetUserMediaPermissionRequestCountForOrigin(WKStringRef origin, WKStringRef parentOrigin);
+    void setUserMediaPermissionForOrigin(bool permission, WKStringRef origin, WKStringRef parentOrigin);
 
     // Policy delegate.
     void setCustomPolicyDelegate(bool enabled, bool permissive);
index d93fc15..6c2badb 100644 (file)
@@ -889,25 +889,11 @@ void TestRunner::setUserMediaPermission(bool enabled)
     InjectedBundle::singleton().setUserMediaPermission(enabled);
 }
 
-void TestRunner::setUserMediaPersistentPermissionForOrigin(bool permission, JSStringRef origin, JSStringRef parentOrigin)
+void TestRunner::setUserMediaPermissionForOrigin(bool permission, JSStringRef origin, JSStringRef parentOrigin)
 {
     WKRetainPtr<WKStringRef> originWK = toWK(origin);
     WKRetainPtr<WKStringRef> parentOriginWK = toWK(parentOrigin);
-    InjectedBundle::singleton().setUserMediaPersistentPermissionForOrigin(permission, originWK.get(), parentOriginWK.get());
-}
-
-unsigned TestRunner::userMediaPermissionRequestCountForOrigin(JSStringRef origin, JSStringRef parentOrigin) const
-{
-    WKRetainPtr<WKStringRef> originWK = toWK(origin);
-    WKRetainPtr<WKStringRef> parentOriginWK = toWK(parentOrigin);
-    return InjectedBundle::singleton().userMediaPermissionRequestCountForOrigin(originWK.get(), parentOriginWK.get());
-}
-
-void TestRunner::resetUserMediaPermissionRequestCountForOrigin(JSStringRef origin, JSStringRef parentOrigin)
-{
-    WKRetainPtr<WKStringRef> originWK = toWK(origin);
-    WKRetainPtr<WKStringRef> parentOriginWK = toWK(parentOrigin);
-    InjectedBundle::singleton().resetUserMediaPermissionRequestCountForOrigin(originWK.get(), parentOriginWK.get());
+    InjectedBundle::singleton().setUserMediaPermissionForOrigin(permission, originWK.get(), parentOriginWK.get());
 }
 
 bool TestRunner::callShouldCloseOnWebView()
index 132af23..b38fc13 100644 (file)
@@ -286,9 +286,7 @@ public:
 
     // MediaStream
     void setUserMediaPermission(bool);
-    void setUserMediaPersistentPermissionForOrigin(bool permission, JSStringRef origin, JSStringRef parentOrigin);
-    unsigned userMediaPermissionRequestCountForOrigin(JSStringRef origin, JSStringRef parentOrigin) const;
-    void resetUserMediaPermissionRequestCountForOrigin(JSStringRef origin, JSStringRef parentOrigin);
+    void setUserMediaPermissionForOrigin(bool permission, JSStringRef origin, JSStringRef parentOrigin);
 
     void setPageVisibility(JSStringRef state);
     void resetPageVisibility();
@@ -402,8 +400,6 @@ private:
 
     WKRetainPtr<WKArrayRef> m_allowedHosts;
 
-    size_t m_userMediaPermissionRequestCount { 0 };
-
     PlatformTimerRef m_waitToDumpWatchdogTimer;
 };
 
index 8966237..0a7b15d 100644 (file)
@@ -765,7 +765,7 @@ bool TestController::resetStateToConsistentValues(const TestOptions& options)
 
     // Reset UserMedia permissions.
     m_userMediaPermissionRequests.clear();
-    m_cachedUserMediaPermissions.clear();
+    m_cahcedUserMediaPermissions.clear();
     m_isUserMediaPermissionSet = false;
     m_isUserMediaPermissionAllowed = false;
 
@@ -1885,34 +1885,34 @@ public:
 
     HashMap<uint64_t, String>& ephemeralSalts() { return m_ephemeralSalts; }
 
-    void incrementRequestCount() { ++m_requestCount; }
-    void resetRequestCount() { m_requestCount = 0; }
-    unsigned requestCount() const { return m_requestCount; }
-
 private:
     HashMap<uint64_t, String> m_ephemeralSalts;
     String m_persistentSalt;
-    unsigned m_requestCount { 0 };
     bool m_persistentPermission { false };
 };
 
 String TestController::saltForOrigin(WKFrameRef frame, String originHash)
 {
-    auto& settings = settingsForOrigin(originHash);
-    auto& ephemeralSalts = settings.ephemeralSalts();
+    RefPtr<OriginSettings> settings = m_cahcedUserMediaPermissions.get(originHash);
+    if (!settings) {
+        settings = adoptRef(*new OriginSettings());
+        m_cahcedUserMediaPermissions.add(originHash, settings);
+    }
+
+    auto& ephemeralSalts = settings->ephemeralSalts();
     auto frameInfo = adoptWK(WKFrameCreateFrameInfo(frame));
     auto frameHandle = WKFrameInfoGetFrameHandleRef(frameInfo.get());
     uint64_t frameIdentifier = WKFrameHandleGetFrameID(frameHandle);
     String frameSalt = ephemeralSalts.get(frameIdentifier);
 
-    if (settings.persistentPermission()) {
+    if (settings->persistentPermission()) {
         if (frameSalt.length())
             return frameSalt;
 
-        if (!settings.persistentSalt().length())
-            settings.setPersistentSalt(createCanonicalUUIDString());
+        if (!settings->persistentSalt().length())
+            settings->setPersistentSalt(createCanonicalUUIDString());
 
-        return settings.persistentSalt();
+        return settings->persistentSalt();
     }
 
     if (!frameSalt.length()) {
@@ -1923,11 +1923,16 @@ String TestController::saltForOrigin(WKFrameRef frame, String originHash)
     return frameSalt;
 }
 
-void TestController::setUserMediaPersistentPermissionForOrigin(bool permission, WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString)
+void TestController::setUserMediaPermissionForOrigin(bool permission, WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString)
 {
     auto originHash = userMediaOriginHash(userMediaDocumentOriginString, topLevelDocumentOriginString);
-    auto& settings = settingsForOrigin(originHash);
-    settings.setPersistentPermission(permission);
+    RefPtr<OriginSettings> settings = m_cahcedUserMediaPermissions.get(originHash);
+    if (!settings) {
+        settings = adoptRef(*new OriginSettings());
+        m_cahcedUserMediaPermissions.add(originHash, settings);
+    }
+
+    settings->setPersistentPermission(permission);
 }
 
 void TestController::handleCheckOfUserMediaPermissionForOrigin(WKFrameRef frame, WKSecurityOriginRef userMediaDocumentOrigin, WKSecurityOriginRef topLevelDocumentOrigin, const WKUserMediaPermissionCheckRef& checkRequest)
@@ -1935,7 +1940,7 @@ void TestController::handleCheckOfUserMediaPermissionForOrigin(WKFrameRef frame,
     auto originHash = userMediaOriginHash(userMediaDocumentOrigin, topLevelDocumentOrigin);
     auto salt = saltForOrigin(frame, originHash);
 
-    WKUserMediaPermissionCheckSetUserMediaAccessInfo(checkRequest, WKStringCreateWithUTF8CString(salt.utf8().data()), settingsForOrigin(originHash).persistentPermission());
+    WKUserMediaPermissionCheckSetUserMediaAccessInfo(checkRequest, WKStringCreateWithUTF8CString(salt.utf8().data()), m_cahcedUserMediaPermissions.get(originHash)->persistentPermission());
 }
 
 void TestController::handleUserMediaPermissionRequest(WKFrameRef frame, WKSecurityOriginRef userMediaDocumentOrigin, WKSecurityOriginRef topLevelDocumentOrigin, WKUserMediaPermissionRequestRef request)
@@ -1945,29 +1950,6 @@ void TestController::handleUserMediaPermissionRequest(WKFrameRef frame, WKSecuri
     decidePolicyForUserMediaPermissionRequestIfPossible();
 }
 
-OriginSettings& TestController::settingsForOrigin(const String& originHash)
-{
-    RefPtr<OriginSettings> settings = m_cachedUserMediaPermissions.get(originHash);
-    if (!settings) {
-        settings = adoptRef(*new OriginSettings());
-        m_cachedUserMediaPermissions.add(originHash, settings);
-    }
-
-    return *settings;
-}
-
-unsigned TestController::userMediaPermissionRequestCountForOrigin(WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString)
-{
-    auto originHash = userMediaOriginHash(userMediaDocumentOriginString, topLevelDocumentOriginString);
-    return settingsForOrigin(originHash).requestCount();
-}
-
-void TestController::resetUserMediaPermissionRequestCountForOrigin(WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString)
-{
-    auto originHash = userMediaOriginHash(userMediaDocumentOriginString, topLevelDocumentOriginString);
-    settingsForOrigin(originHash).resetRequestCount();
-}
-
 void TestController::decidePolicyForUserMediaPermissionRequestIfPossible()
 {
     if (!m_isUserMediaPermissionSet)
@@ -1977,10 +1959,12 @@ void TestController::decidePolicyForUserMediaPermissionRequestIfPossible()
         auto originHash = pair.first;
         auto request = pair.second.get();
 
-        auto& settings = settingsForOrigin(originHash);
-        settings.incrementRequestCount();
+        bool persistentPermission = false;
+        RefPtr<OriginSettings> settings = m_cahcedUserMediaPermissions.get(originHash);
+        if (settings)
+            persistentPermission = settings->persistentPermission();
 
-        if (!m_isUserMediaPermissionAllowed && !settings.persistentPermission()) {
+        if (!m_isUserMediaPermissionAllowed && !persistentPermission) {
             WKUserMediaPermissionRequestDeny(request, kWKPermissionDenied);
             continue;
         }
index d8e61d6..2f071b6 100644 (file)
@@ -101,12 +101,9 @@ public:
     void getUserMediaInfoForOrigin(WKFrameRef, WKStringRef originKey, bool&, WKRetainPtr<WKStringRef>&);
     WKStringRef getUserMediaSaltForOrigin(WKFrameRef, WKStringRef originKey);
     void setUserMediaPermission(bool);
-    void setUserMediaPersistentPermissionForOrigin(bool, WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString);
+    void setUserMediaPermissionForOrigin(bool, WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString);
     void handleUserMediaPermissionRequest(WKFrameRef, WKSecurityOriginRef, WKSecurityOriginRef, WKUserMediaPermissionRequestRef);
     void handleCheckOfUserMediaPermissionForOrigin(WKFrameRef, WKSecurityOriginRef, WKSecurityOriginRef, const WKUserMediaPermissionCheckRef&);
-    OriginSettings& settingsForOrigin(const String&);
-    unsigned userMediaPermissionRequestCountForOrigin(WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString);
-    void resetUserMediaPermissionRequestCountForOrigin(WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString);
 
     // Policy delegate.
     void setCustomPolicyDelegate(bool enabled, bool permissive);
@@ -319,7 +316,7 @@ private:
     bool m_isGeolocationPermissionSet { false };
     bool m_isGeolocationPermissionAllowed { false };
 
-    HashMap<String, RefPtr<OriginSettings>> m_cachedUserMediaPermissions;
+    HashMap<String, RefPtr<OriginSettings>> m_cahcedUserMediaPermissions;
 
     typedef Vector<std::pair<String, WKRetainPtr<WKUserMediaPermissionRequestRef>>> PermissionRequestList;
     PermissionRequestList m_userMediaPermissionRequests;
index 5ed7de5..ecfae49 100644 (file)
@@ -496,7 +496,7 @@ void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName
         return;
     }
 
-    if (WKStringIsEqualToUTF8CString(messageName, "SetUserMediaPersistentPermissionForOrigin")) {
+    if (WKStringIsEqualToUTF8CString(messageName, "SetUserMediaPermissionForOrigin")) {
         ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
         WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
 
@@ -510,21 +510,7 @@ void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName
         WKRetainPtr<WKStringRef> parentOriginKey(AdoptWK, WKStringCreateWithUTF8CString("parentOrigin"));
         WKStringRef parentOriginWK = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, parentOriginKey.get()));
 
-        TestController::singleton().setUserMediaPersistentPermissionForOrigin(permission, originWK, parentOriginWK);
-        return;
-    }
-
-    if (WKStringIsEqualToUTF8CString(messageName, "ResetUserMediaPermissionRequestCountForOrigin")) {
-        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
-        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
-
-        WKRetainPtr<WKStringRef> originKey(AdoptWK, WKStringCreateWithUTF8CString("origin"));
-        WKStringRef originWK = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, originKey.get()));
-
-        WKRetainPtr<WKStringRef> parentOriginKey(AdoptWK, WKStringCreateWithUTF8CString("parentOrigin"));
-        WKStringRef parentOriginWK = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, parentOriginKey.get()));
-        
-        TestController::singleton().resetUserMediaPermissionRequestCountForOrigin(originWK, parentOriginWK);
+        TestController::singleton().setUserMediaPermissionForOrigin(permission, originWK, parentOriginWK);
         return;
     }
 
@@ -860,22 +846,6 @@ WKRetainPtr<WKTypeRef> TestInvocation::didReceiveSynchronousMessageFromInjectedB
     }
 #endif // PLATFORM(MAC)
 
-    if (WKStringIsEqualToUTF8CString(messageName, "UserMediaPermissionRequestCountForOrigin")) {
-        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
-        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
-
-        WKRetainPtr<WKStringRef> originKey(AdoptWK, WKStringCreateWithUTF8CString("origin"));
-        WKStringRef originWK = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, originKey.get()));
-
-        WKRetainPtr<WKStringRef> parentOriginKey(AdoptWK, WKStringCreateWithUTF8CString("parentOrigin"));
-        WKStringRef parentOriginWK = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, parentOriginKey.get()));
-        
-        unsigned count = TestController::singleton().userMediaPermissionRequestCountForOrigin(originWK, parentOriginWK);
-        WKRetainPtr<WKUInt64Ref> result(AdoptWK, WKUInt64Create(count));
-        return result;
-    }
-
-
     ASSERT_NOT_REACHED();
     return nullptr;
 }