Title: [241694] releases/WebKitGTK/webkit-2.24
Revision
241694
Author
carlo...@webkit.org
Date
2019-02-18 08:15:09 -0800 (Mon, 18 Feb 2019)

Log Message

Merge r241602 - Make navigator.mediaDevices SecureContext
https://bugs.webkit.org/show_bug.cgi?id=194666

Reviewed by Eric Carlson.

Source/WebCore:

Make navigator.mediaDevices SecureContext.
This can still be enabled for unsecure context using the existing page settings.
To cover that case, introduce ContextHasMediaDevices custom IDL keyword.

Covered by API test.

* Modules/mediastream/NavigatorMediaDevices.idl:
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateRuntimeEnableConditionalString):
* bindings/scripts/IDLAttributes.json:
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::hasMediaDevices const):
(WebCore::ScriptExecutionContext::hasServiceWorkerScheme const):
* dom/ScriptExecutionContext.h:

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/UserMediaDisabled.mm:
(MediaCaptureDisabledTest::loadTestAndWaitForMessage):
(TEST_F):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.24/Source/WebCore/ChangeLog (241693 => 241694)


--- releases/WebKitGTK/webkit-2.24/Source/WebCore/ChangeLog	2019-02-18 16:15:02 UTC (rev 241693)
+++ releases/WebKitGTK/webkit-2.24/Source/WebCore/ChangeLog	2019-02-18 16:15:09 UTC (rev 241694)
@@ -1,5 +1,27 @@
 2019-02-15  Youenn Fablet  <you...@apple.com>
 
+        Make navigator.mediaDevices SecureContext
+        https://bugs.webkit.org/show_bug.cgi?id=194666
+
+        Reviewed by Eric Carlson.
+
+        Make navigator.mediaDevices SecureContext.
+        This can still be enabled for unsecure context using the existing page settings.
+        To cover that case, introduce ContextHasMediaDevices custom IDL keyword.
+
+        Covered by API test.
+
+        * Modules/mediastream/NavigatorMediaDevices.idl:
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateRuntimeEnableConditionalString):
+        * bindings/scripts/IDLAttributes.json:
+        * dom/ScriptExecutionContext.cpp:
+        (WebCore::ScriptExecutionContext::hasMediaDevices const):
+        (WebCore::ScriptExecutionContext::hasServiceWorkerScheme const):
+        * dom/ScriptExecutionContext.h:
+
+2019-02-15  Youenn Fablet  <you...@apple.com>
+
         WebSocket should not fire events after being stopped
         https://bugs.webkit.org/show_bug.cgi?id=194690
 

Modified: releases/WebKitGTK/webkit-2.24/Source/WebCore/Modules/mediastream/NavigatorMediaDevices.idl (241693 => 241694)


--- releases/WebKitGTK/webkit-2.24/Source/WebCore/Modules/mediastream/NavigatorMediaDevices.idl	2019-02-18 16:15:02 UTC (rev 241693)
+++ releases/WebKitGTK/webkit-2.24/Source/WebCore/Modules/mediastream/NavigatorMediaDevices.idl	2019-02-18 16:15:09 UTC (rev 241694)
@@ -32,6 +32,5 @@
     Conditional=MEDIA_STREAM,
     EnabledAtRuntime=MediaDevices,
 ] partial interface Navigator {
-    // FIXME: missing [SameObject]
-    readonly attribute MediaDevices mediaDevices;
+    [SameObject, SecureContext, ContextAllowsMediaDevices] readonly attribute MediaDevices mediaDevices;
 };

Modified: releases/WebKitGTK/webkit-2.24/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (241693 => 241694)


--- releases/WebKitGTK/webkit-2.24/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2019-02-18 16:15:02 UTC (rev 241693)
+++ releases/WebKitGTK/webkit-2.24/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2019-02-18 16:15:09 UTC (rev 241694)
@@ -3690,6 +3690,9 @@
         if ($context->extendedAttributes->{ContextHasServiceWorkerScheme}) {
             push(@conjuncts, "(jsCast<JSDOMGlobalObject*>(" . $globalObjectPtr . ")->scriptExecutionContext()->isSecureContext()"
                 . "|| jsCast<JSDOMGlobalObject*>(" . $globalObjectPtr . ")->scriptExecutionContext()->hasServiceWorkerScheme())");
+        } elsif ($context->extendedAttributes->{ContextAllowsMediaDevices}) {
+            push(@conjuncts, "(jsCast<JSDOMGlobalObject*>(" . $globalObjectPtr . ")->scriptExecutionContext()->isSecureContext()"
+                . "|| jsCast<JSDOMGlobalObject*>(" . $globalObjectPtr . ")->scriptExecutionContext()->allowsMediaDevices())");
         } else {
             push(@conjuncts, "jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext()");
         }

Modified: releases/WebKitGTK/webkit-2.24/Source/WebCore/bindings/scripts/IDLAttributes.json (241693 => 241694)


--- releases/WebKitGTK/webkit-2.24/Source/WebCore/bindings/scripts/IDLAttributes.json	2019-02-18 16:15:02 UTC (rev 241693)
+++ releases/WebKitGTK/webkit-2.24/Source/WebCore/bindings/scripts/IDLAttributes.json	2019-02-18 16:15:09 UTC (rev 241694)
@@ -85,6 +85,9 @@
         "ConstructorMayThrowException": {
             "contextsAllowed": ["interface"]
         },
+        "ContextAllowsMediaDevices": {
+            "contextsAllowed": ["attribute"]
+        },
         "ContextHasServiceWorkerScheme": {
             "contextsAllowed": ["attribute"]
         },

Modified: releases/WebKitGTK/webkit-2.24/Source/WebCore/dom/ScriptExecutionContext.cpp (241693 => 241694)


--- releases/WebKitGTK/webkit-2.24/Source/WebCore/dom/ScriptExecutionContext.cpp	2019-02-18 16:15:02 UTC (rev 241693)
+++ releases/WebKitGTK/webkit-2.24/Source/WebCore/dom/ScriptExecutionContext.cpp	2019-02-18 16:15:09 UTC (rev 241694)
@@ -554,8 +554,20 @@
     return m_domainForCachePartition.isNull() ? topOrigin().domainForCachePartition() : m_domainForCachePartition;
 }
 
-bool ScriptExecutionContext::hasServiceWorkerScheme()
+bool ScriptExecutionContext::allowsMediaDevices() const
 {
+#if ENABLE(MEDIA_STREAM)
+    if (!is<Document>(*this))
+        return false;
+    auto page = downcast<Document>(*this).page();
+    return page ? !page->settings().mediaCaptureRequiresSecureConnection() : false;
+#else
+    return false;
+#endif
+}
+
+bool ScriptExecutionContext::hasServiceWorkerScheme() const
+{
     ASSERT(securityOrigin());
     return SchemeRegistry::isServiceWorkerContainerCustomScheme(securityOrigin()->protocol());
 }

Modified: releases/WebKitGTK/webkit-2.24/Source/WebCore/dom/ScriptExecutionContext.h (241693 => 241694)


--- releases/WebKitGTK/webkit-2.24/Source/WebCore/dom/ScriptExecutionContext.h	2019-02-18 16:15:02 UTC (rev 241693)
+++ releases/WebKitGTK/webkit-2.24/Source/WebCore/dom/ScriptExecutionContext.h	2019-02-18 16:15:09 UTC (rev 241694)
@@ -244,7 +244,8 @@
     WEBCORE_EXPORT String domainForCachePartition() const;
     void setDomainForCachePartition(String&& domain) { m_domainForCachePartition = WTFMove(domain); }
 
-    bool hasServiceWorkerScheme();
+    bool allowsMediaDevices() const;
+    bool hasServiceWorkerScheme() const;
 #if ENABLE(SERVICE_WORKER)
     ServiceWorker* activeServiceWorker() const;
     void setActiveServiceWorker(RefPtr<ServiceWorker>&&);

Modified: releases/WebKitGTK/webkit-2.24/Tools/ChangeLog (241693 => 241694)


--- releases/WebKitGTK/webkit-2.24/Tools/ChangeLog	2019-02-18 16:15:02 UTC (rev 241693)
+++ releases/WebKitGTK/webkit-2.24/Tools/ChangeLog	2019-02-18 16:15:09 UTC (rev 241694)
@@ -1,3 +1,14 @@
+2019-02-15  Youenn Fablet  <you...@apple.com>
+
+        Make navigator.mediaDevices SecureContext
+        https://bugs.webkit.org/show_bug.cgi?id=194666
+
+        Reviewed by Eric Carlson.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/UserMediaDisabled.mm:
+        (MediaCaptureDisabledTest::loadTestAndWaitForMessage):
+        (TEST_F):
+
 2019-02-15  Zalan Bujtas  <za...@apple.com>
 
         [LFC] Out-of-flow box is never a float box

Modified: releases/WebKitGTK/webkit-2.24/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserMediaDisabled.mm (241693 => 241694)


--- releases/WebKitGTK/webkit-2.24/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserMediaDisabled.mm	2019-02-18 16:15:02 UTC (rev 241693)
+++ releases/WebKitGTK/webkit-2.24/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserMediaDisabled.mm	2019-02-18 16:15:09 UTC (rev 241694)
@@ -131,4 +131,16 @@
     loadTestAndWaitForMessage("allowed");
     EXPECT_TRUE(wasPrompted);
 }
+
+TEST_F(MediaCaptureDisabledTest, UnsecureContext)
+{
+    auto preferences = [m_webView configuration].preferences;
+    preferences._mediaCaptureRequiresSecureConnection = YES;
+
+    receivedScriptMessage = false;
+    [m_webView loadHTMLString:@"<html><body><script>window.webkit.messageHandlers.testHandler.postMessage(Navigator.prototype.hasOwnProperty('mediaDevices') ? 'has' : 'none');</script></body></html>" baseURL: [[NSURL alloc] initWithString:@"http://test.org"]];
+
+    TestWebKitAPI::Util::run(&receivedScriptMessage);
+    EXPECT_STREQ([(NSString *)[lastScriptMessage body] UTF8String], "none");
+}
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to