WebKit Bugzilla
Attachment 362128 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 for landing
bug-194666-20190215104431.patch (text/plain), 7.22 KB, created by
youenn fablet
on 2019-02-15 10:44:32 PST
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2019-02-15 10:44:32 PST
Size:
7.22 KB
patch
obsolete
>Subversion Revision: 241548 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index bf6eae5e7dce1e2155255f19f0493f07ab3cccfa..c9942b0faaef01fc2d82b7ab17167d6dd85afc54 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 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-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..d57facd0d629be16fddfc73bdf78b7148354e19a 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, ContextAllowsMediaDevices] readonly attribute MediaDevices mediaDevices; > }; >diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm >index 795403b2545fdd399167c6f8ddefa3410bda8853..9812077204c0f35683991ec1a60799029775bf67 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->{ContextAllowsMediaDevices}) { >+ push(@conjuncts, "(jsCast<JSDOMGlobalObject*>(" . $globalObjectPtr . ")->scriptExecutionContext()->isSecureContext()" >+ . "|| jsCast<JSDOMGlobalObject*>(" . $globalObjectPtr . ")->scriptExecutionContext()->allowsMediaDevices())"); > } 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..bc39251136a80a753e5a76600feedbbbe7b3997d 100644 >--- a/Source/WebCore/bindings/scripts/IDLAttributes.json >+++ b/Source/WebCore/bindings/scripts/IDLAttributes.json >@@ -85,6 +85,9 @@ > "ConstructorMayThrowException": { > "contextsAllowed": ["interface"] > }, >+ "ContextAllowsMediaDevices": { >+ "contextsAllowed": ["attribute"] >+ }, > "ContextHasServiceWorkerScheme": { > "contextsAllowed": ["attribute"] > }, >diff --git a/Source/WebCore/dom/ScriptExecutionContext.cpp b/Source/WebCore/dom/ScriptExecutionContext.cpp >index e85985223f78e31b4a2b7fb08c6b10d81cfd2709..d7ff3e78bd72cbede5884ede09f449f9a03bb261 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::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()); >diff --git a/Source/WebCore/dom/ScriptExecutionContext.h b/Source/WebCore/dom/ScriptExecutionContext.h >index 5c58527d38be45a0d108f0a3b3d1b8b7b6caab24..22587ef58dc65313dbe72c48e7b4ae90e68e167d 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 allowsMediaDevices() 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..a2cccf9d6da49982760642df747c2fc6a73ead1f 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 Eric Carlson. >+ >+ * 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