WebKit Bugzilla
Attachment 362076 Details for
Bug 194666
: Make navigator.mediaDevices SecureContext
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194666-20190214155547.patch (text/plain), 7.21 KB, created by
youenn fablet
on 2019-02-14 15:55:48 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2019-02-14 15:55:48 PST
Size:
7.21 KB
patch
obsolete
>Subversion Revision: 241548 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index bf6eae5e7dce1e2155255f19f0493f07ab3cccfa..d36f5136b437839cfeddba1b5db4e0e1200b22f0 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,25 @@ >+2019-02-14 Youenn Fablet <youenn@apple.com> >+ >+ Make navigator.mediaDevices SecureContext >+ https://bugs.webkit.org/show_bug.cgi?id=194666 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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-14 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r241486. >diff --git a/Source/WebCore/Modules/mediastream/NavigatorMediaDevices.idl b/Source/WebCore/Modules/mediastream/NavigatorMediaDevices.idl >index beeb65cc1302d518eccedffc389531423cf1d68d..e079f9e8e07c148ecd955e75be08626223f697f6 100644 >--- a/Source/WebCore/Modules/mediastream/NavigatorMediaDevices.idl >+++ b/Source/WebCore/Modules/mediastream/NavigatorMediaDevices.idl >@@ -32,6 +32,5 @@ > Conditional=MEDIA_STREAM, > EnabledAtRuntime=MediaDevices, > ] partial interface Navigator { >- // FIXME: missing [SameObject] >- readonly attribute MediaDevices mediaDevices; >+ [SameObject, SecureContext, ContextHasMediaDevices] readonly attribute MediaDevices mediaDevices; > }; >diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm >index 795403b2545fdd399167c6f8ddefa3410bda8853..662523f06b28047bab58eced2315845784e21a0d 100644 >--- a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm >+++ b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm >@@ -3690,6 +3690,9 @@ sub GenerateRuntimeEnableConditionalString > if ($context->extendedAttributes->{ContextHasServiceWorkerScheme}) { > push(@conjuncts, "(jsCast<JSDOMGlobalObject*>(" . $globalObjectPtr . ")->scriptExecutionContext()->isSecureContext()" > . "|| jsCast<JSDOMGlobalObject*>(" . $globalObjectPtr . ")->scriptExecutionContext()->hasServiceWorkerScheme())"); >+ } elsif ($context->extendedAttributes->{ContextHasMediaDevices}) { >+ push(@conjuncts, "(jsCast<JSDOMGlobalObject*>(" . $globalObjectPtr . ")->scriptExecutionContext()->isSecureContext()" >+ . "|| jsCast<JSDOMGlobalObject*>(" . $globalObjectPtr . ")->scriptExecutionContext()->hasMediaDevices())"); > } else { > push(@conjuncts, "jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext()"); > } >diff --git a/Source/WebCore/bindings/scripts/IDLAttributes.json b/Source/WebCore/bindings/scripts/IDLAttributes.json >index a00df42a5f7c70a17f76380fcacebd878fae0366..43a541e9c46adccc3f147ed0ee413c53d4d8afdd 100644 >--- a/Source/WebCore/bindings/scripts/IDLAttributes.json >+++ b/Source/WebCore/bindings/scripts/IDLAttributes.json >@@ -85,6 +85,9 @@ > "ConstructorMayThrowException": { > "contextsAllowed": ["interface"] > }, >+ "ContextHasMediaDevices": { >+ "contextsAllowed": ["attribute"] >+ }, > "ContextHasServiceWorkerScheme": { > "contextsAllowed": ["attribute"] > }, >diff --git a/Source/WebCore/dom/ScriptExecutionContext.cpp b/Source/WebCore/dom/ScriptExecutionContext.cpp >index e85985223f78e31b4a2b7fb08c6b10d81cfd2709..cfc4b5cf6d0fb897c9d9da59f125ce5eb1e7229b 100644 >--- a/Source/WebCore/dom/ScriptExecutionContext.cpp >+++ b/Source/WebCore/dom/ScriptExecutionContext.cpp >@@ -554,7 +554,19 @@ String ScriptExecutionContext::domainForCachePartition() const > return m_domainForCachePartition.isNull() ? topOrigin().domainForCachePartition() : m_domainForCachePartition; > } > >-bool ScriptExecutionContext::hasServiceWorkerScheme() >+bool ScriptExecutionContext::hasMediaDevices() 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()); >diff --git a/Source/WebCore/dom/ScriptExecutionContext.h b/Source/WebCore/dom/ScriptExecutionContext.h >index 5c58527d38be45a0d108f0a3b3d1b8b7b6caab24..78d1afcc646952b5d54961ed1c71ba01598f6884 100644 >--- a/Source/WebCore/dom/ScriptExecutionContext.h >+++ b/Source/WebCore/dom/ScriptExecutionContext.h >@@ -244,7 +244,8 @@ public: > WEBCORE_EXPORT String domainForCachePartition() const; > void setDomainForCachePartition(String&& domain) { m_domainForCachePartition = WTFMove(domain); } > >- bool hasServiceWorkerScheme(); >+ bool hasMediaDevices() const; >+ bool hasServiceWorkerScheme() const; > #if ENABLE(SERVICE_WORKER) > ServiceWorker* activeServiceWorker() const; > void setActiveServiceWorker(RefPtr<ServiceWorker>&&); >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index ce25452df926684eef32f85bb4df0a5aa7565759..c1b7843081f2530185aefeb25fc451ceb7c8e89f 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,14 @@ >+2019-02-14 Youenn Fablet <youenn@apple.com> >+ >+ Make navigator.mediaDevices SecureContext >+ https://bugs.webkit.org/show_bug.cgi?id=194666 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestWebKitAPI/Tests/WebKitCocoa/UserMediaDisabled.mm: >+ (MediaCaptureDisabledTest::loadTestAndWaitForMessage): >+ (TEST_F): >+ > 2019-02-14 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r241486. >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserMediaDisabled.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserMediaDisabled.mm >index 65d28f28868848f55f3c00721d1909e000540965..a5a902af75e1a316731ae6de6edaa0ec1476d11d 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserMediaDisabled.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserMediaDisabled.mm >@@ -131,4 +131,16 @@ TEST_F(MediaCaptureDisabledTest, EnableAndDisable) > 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
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194666
:
362061
|
362076
|
362128