Set getUserMedia permission to true by default on WTR
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Jun 2017 23:16:31 +0000 (23:16 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Jun 2017 23:16:31 +0000 (23:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173610

Patch by Youenn Fablet <youenn@apple.com> on 2017-06-23
Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

* web-platform-tests/webrtc/simplecall-expected.txt:

Tools:

Adding a way to reset the getUserMedia permission to pending.

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::setUserMediaPermissionAsUnset):
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setUserMediaPermissionAsUnset):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetStateToConsistentValues):
(WTR::TestController::setUserMediaPermissionAsUnset):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):

LayoutTests:

* fast/mediastream/delayed-permission-allowed.html:
* fast/mediastream/delayed-permission-denied.html:

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

14 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/mediastream/delayed-permission-allowed.html
LayoutTests/fast/mediastream/delayed-permission-denied.html
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/webrtc/simplecall-expected.txt
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 d801874..fb04c11 100644 (file)
@@ -1,5 +1,15 @@
 2017-06-23  Youenn Fablet  <youenn@apple.com>
 
+        Set getUserMedia permission to true by default on WTR
+        https://bugs.webkit.org/show_bug.cgi?id=173610
+
+        Reviewed by Alex Christensen.
+
+        * fast/mediastream/delayed-permission-allowed.html:
+        * fast/mediastream/delayed-permission-denied.html:
+
+2017-06-23  Youenn Fablet  <youenn@apple.com>
+
         webrtc/routines.js should call createAnswer once setRemoteDescription promise is resolved
         https://bugs.webkit.org/show_bug.cgi?id=173785
 
index ecb45a1..c3d4891 100644 (file)
@@ -14,6 +14,9 @@ function allowPermission() {
         testRunner.setUserMediaPermission(true);
 }
 
+if (window.testRunner)
+    testRunner.resetUserMediaPermission();
+
 var options = {audio: true, video: true};
 navigator.mediaDevices.getUserMedia(options)
     .then(stream => {
index c7ce612..c1a60c0 100644 (file)
@@ -14,6 +14,9 @@ function denyPermission() {
         testRunner.setUserMediaPermission(false);
 }
 
+if (window.testRunner)
+    testRunner.resetUserMediaPermission();
+
 var error;
 var options = {audio: true, video: true};
 navigator.mediaDevices.getUserMedia(options)
index 19ea29e..18330c6 100644 (file)
@@ -1,3 +1,12 @@
+2017-06-23  Youenn Fablet  <youenn@apple.com>
+
+        Set getUserMedia permission to true by default on WTR
+        https://bugs.webkit.org/show_bug.cgi?id=173610
+
+        Reviewed by Alex Christensen.
+
+        * web-platform-tests/webrtc/simplecall-expected.txt:
+
 2017-06-22  Romain Bellessort  <romain.bellessort@crf.canon.fr>
 
         [Readable Streams API] Implement ReadableStreamBYOBReader read()
index b71e604..8ffd4fa 100644 (file)
@@ -1,4 +1,4 @@
 The feature(s) tested here are known to have been made available via vendor prefixes; you can run this test with vendor prefixes enabled.
 
-TIMEOUT Can set up a basic WebRTC call. Test timed out
-  
+PASS Can set up a basic WebRTC call. 
index 52022ac..582b180 100644 (file)
@@ -1,3 +1,26 @@
+2017-06-23  Youenn Fablet  <youenn@apple.com>
+
+        Set getUserMedia permission to true by default on WTR
+        https://bugs.webkit.org/show_bug.cgi?id=173610
+
+        Reviewed by Alex Christensen.
+
+        Adding a way to reset the getUserMedia permission to pending.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::setUserMediaPermissionAsUnset):
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::setUserMediaPermissionAsUnset):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::resetStateToConsistentValues):
+        (WTR::TestController::setUserMediaPermissionAsUnset):
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
+
 2017-06-23  Alex Christensen  <achristensen@webkit.org>
 
         Add SPI to WKURLSchemeTask for redirection
index 9cbcb56..67b82da 100644 (file)
@@ -189,6 +189,7 @@ interface TestRunner {
 
     // MediaStream
     void setUserMediaPermission(boolean value);
+    void resetUserMediaPermission();
     void setUserMediaPersistentPermissionForOrigin(boolean permission, DOMString origin, DOMString parentOrigin);
     unsigned long userMediaPermissionRequestCountForOrigin(DOMString origin, DOMString parentOrigin);
     void resetUserMediaPermissionRequestCountForOrigin(DOMString origin, DOMString parentOrigin);
index 9486290..52342ae 100644 (file)
@@ -604,6 +604,12 @@ void InjectedBundle::setUserMediaPermission(bool enabled)
     WKBundlePagePostMessage(page()->page(), messageName.get(), messageBody.get());
 }
 
+void InjectedBundle::resetUserMediaPermission()
+{
+    auto messageName = adoptWK(WKStringCreateWithUTF8CString("ResetUserMediaPermission"));
+    WKBundlePagePostMessage(page()->page(), messageName.get(), 0);
+}
+
 void InjectedBundle::setUserMediaPersistentPermissionForOrigin(bool permission, WKStringRef origin, WKStringRef parentOrigin)
 {
     auto messageName = adoptWK(WKStringCreateWithUTF8CString("SetUserMediaPersistentPermissionForOrigin"));
index 2edd5e7..0576314 100644 (file)
@@ -103,6 +103,7 @@ public:
 
     // MediaStream.
     void setUserMediaPermission(bool);
+    void resetUserMediaPermission();
     void setUserMediaPersistentPermissionForOrigin(bool permission, WKStringRef origin, WKStringRef parentOrigin);
     unsigned userMediaPermissionRequestCountForOrigin(WKStringRef origin, WKStringRef parentOrigin) const;
     void resetUserMediaPermissionRequestCountForOrigin(WKStringRef origin, WKStringRef parentOrigin);
index 435443e..f6a3d50 100644 (file)
@@ -913,6 +913,12 @@ void TestRunner::setUserMediaPermission(bool enabled)
     InjectedBundle::singleton().setUserMediaPermission(enabled);
 }
 
+void TestRunner::resetUserMediaPermission()
+{
+    // FIXME: this should be done by frame.
+    InjectedBundle::singleton().resetUserMediaPermission();
+}
+
 void TestRunner::setUserMediaPersistentPermissionForOrigin(bool permission, JSStringRef origin, JSStringRef parentOrigin)
 {
     WKRetainPtr<WKStringRef> originWK = toWK(origin);
index e9c4eaa..4a7d0eb 100644 (file)
@@ -288,6 +288,7 @@ public:
 
     // MediaStream
     void setUserMediaPermission(bool);
+    void resetUserMediaPermission();
     void setUserMediaPersistentPermissionForOrigin(bool permission, JSStringRef origin, JSStringRef parentOrigin);
     unsigned userMediaPermissionRequestCountForOrigin(JSStringRef origin, JSStringRef parentOrigin) const;
     void resetUserMediaPermissionRequestCountForOrigin(JSStringRef origin, JSStringRef parentOrigin);
index 8765146..e157c7a 100644 (file)
@@ -803,8 +803,7 @@ bool TestController::resetStateToConsistentValues(const TestOptions& options)
     // Reset UserMedia permissions.
     m_userMediaPermissionRequests.clear();
     m_cachedUserMediaPermissions.clear();
-    m_isUserMediaPermissionSet = false;
-    m_isUserMediaPermissionAllowed = false;
+    setUserMediaPermission(true);
 
     // Reset Custom Policy Delegate.
     setCustomPolicyDelegate(false, false);
@@ -1890,6 +1889,11 @@ void TestController::setUserMediaPermission(bool enabled)
     decidePolicyForUserMediaPermissionRequestIfPossible();
 }
 
+void TestController::resetUserMediaPermission()
+{
+    m_isUserMediaPermissionSet = false;
+}
+
 class OriginSettings : public RefCounted<OriginSettings> {
 public:
     explicit OriginSettings()
index eb14889..fba3784 100644 (file)
@@ -102,6 +102,7 @@ public:
     void getUserMediaInfoForOrigin(WKFrameRef, WKStringRef originKey, bool&, WKRetainPtr<WKStringRef>&);
     WKStringRef getUserMediaSaltForOrigin(WKFrameRef, WKStringRef originKey);
     void setUserMediaPermission(bool);
+    void resetUserMediaPermission();
     void setUserMediaPersistentPermissionForOrigin(bool, WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString);
     void handleUserMediaPermissionRequest(WKFrameRef, WKSecurityOriginRef, WKSecurityOriginRef, WKUserMediaPermissionRequestRef);
     void handleCheckOfUserMediaPermissionForOrigin(WKFrameRef, WKSecurityOriginRef, WKSecurityOriginRef, const WKUserMediaPermissionCheckRef&);
index 893584b..8aeb35a 100644 (file)
@@ -506,6 +506,11 @@ void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName
         return;
     }
 
+    if (WKStringIsEqualToUTF8CString(messageName, "ResetUserMediaPermission")) {
+        TestController::singleton().resetUserMediaPermission();
+        return;
+    }
+
     if (WKStringIsEqualToUTF8CString(messageName, "SetUserMediaPersistentPermissionForOrigin")) {
         ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
         WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);