Changeset 244749 in webkit
- Timestamp:
- Apr 29, 2019, 1:04:33 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 17 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/mediastream/media-stream-page-muted.html (modified) (1 diff)
-
LayoutTests/fast/mediastream/screencapture-user-gesture-expected.txt (added)
-
LayoutTests/fast/mediastream/screencapture-user-gesture.html (added)
-
LayoutTests/http/tests/media/media-stream/get-display-media-iframe-allow-attribute-expected.txt (modified) (1 diff)
-
LayoutTests/http/tests/media/media-stream/get-display-media-prompt.html (modified) (1 diff)
-
LayoutTests/http/tests/media/media-stream/resources/get-display-media-devices-iframe.html (modified) (1 diff)
-
LayoutTests/resources/testharnessreport.js (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/mediastream/MediaDevices.cpp (modified) (2 diffs)
-
Source/WebCore/Modules/mediastream/MediaDevices.h (modified) (3 diffs)
-
Source/WebCore/Modules/mediastream/NavigatorMediaDevices.h (modified) (1 diff)
-
Source/WebCore/page/DOMWindow.h (modified) (1 diff)
-
Source/WebCore/testing/Internals.cpp (modified) (3 diffs)
-
Source/WebCore/testing/Internals.h (modified) (1 diff)
-
Source/WebCore/testing/Internals.idl (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKit/getDisplayMedia.html (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/GetDisplayMedia.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r244748 r244749 1 2019-04-29 Youenn Fablet <youenn@apple.com> 2 3 getDisplayMedia should be called on user gesture 4 https://bugs.webkit.org/show_bug.cgi?id=197356 5 6 Reviewed by Eric Carlson. 7 8 * fast/mediastream/media-stream-page-muted.html: 9 * fast/mediastream/screencapture-user-gesture-expected.txt: Added. 10 * fast/mediastream/screencapture-user-gesture.html: Added. 11 * http/tests/media/media-stream/get-display-media-iframe-allow-attribute-expected.txt: 12 * http/tests/media/media-stream/get-display-media-iframe-allow-attribute.html: 13 * http/tests/media/media-stream/get-display-media-prompt.html: 14 * http/tests/media/media-stream/resources/get-display-media-devices-iframe.html: 15 16 * resources/testharnessreport.js: 17 1 18 2019-04-29 Javier Fernandez <jfernandez@igalia.com> 2 19 -
trunk/LayoutTests/fast/mediastream/media-stream-page-muted.html
r243899 r244749 5 5 <script src="../../resources/js-test-pre.js"></script> 6 6 <script> 7 if (window.internals) 8 internals.setDisableGetDisplayMediaUserGestureConstraint(true); 9 7 10 async function checkPageState(activeState, inactiveState) { 8 11 await new Promise((resolve, reject) => { -
trunk/LayoutTests/http/tests/media/media-stream/get-display-media-iframe-allow-attribute-expected.txt
r238091 r244749 1 CONSOLE MESSAGE: line 5: Trying to call getDisplayMedia from a frame without correct 'allow' attribute.2 CONSOLE MESSAGE: line 5: Trying to call getDisplayMedia from a frame without correct 'allow' attribute.3 CONSOLE MESSAGE: line 5: Trying to call getDisplayMedia from a frame without correct 'allow' attribute.1 CONSOLE MESSAGE: line 8: Trying to call getDisplayMedia from a frame without correct 'allow' attribute. 2 CONSOLE MESSAGE: line 8: Trying to call getDisplayMedia from a frame without correct 'allow' attribute. 3 CONSOLE MESSAGE: line 8: Trying to call getDisplayMedia from a frame without correct 'allow' attribute. 4 4 5 5 -
trunk/LayoutTests/http/tests/media/media-stream/get-display-media-prompt.html
r236465 r244749 10 10 11 11 <script> 12 if (window.internals) 13 internals.setDisableGetDisplayMediaUserGestureConstraint(true); 12 14 13 15 let stream; -
trunk/LayoutTests/http/tests/media/media-stream/resources/get-display-media-devices-iframe.html
r238091 r244749 1 1 <script> 2 if (window.internals) 3 internals.setDisableGetDisplayMediaUserGestureConstraint(true); 4 2 5 async function enumerate(event) 3 6 { -
trunk/LayoutTests/resources/testharnessreport.js
r230353 r244749 29 29 } 30 30 } 31 32 if (self.internals && internals.setDisableGetDisplayMediaUserGestureConstraint) 33 internals.setDisableGetDisplayMediaUserGestureConstraint(true); 31 34 32 35 if (self.internals && internals.setICECandidateFiltering) -
trunk/Source/WebCore/ChangeLog
r244748 r244749 1 2019-04-29 Youenn Fablet <youenn@apple.com> 2 3 getDisplayMedia should be called on user gesture 4 https://bugs.webkit.org/show_bug.cgi?id=197356 5 6 Reviewed by Eric Carlson. 7 8 Allow getDisplayMedia on user gesture only. 9 Otherwise reject the promise. 10 Minor refactoring to align getDisplayMedia, getUserMedia and 11 enumerateDevices when called with no document. 12 13 Test: fast/mediastream/screencapture-user-gesture.html 14 15 * Modules/mediastream/MediaDevices.cpp: 16 (WebCore::MediaDevices::getUserMedia const): 17 * Modules/mediastream/MediaDevices.h: 18 * Modules/mediastream/NavigatorMediaDevices.h: 19 * page/DOMWindow.h: 20 * testing/Internals.cpp: 21 (WebCore::Internals::setDisableGetDisplayMediaUserGestureConstraint): 22 * testing/Internals.h: 23 * testing/Internals.idl: 24 1 25 2019-04-29 Javier Fernandez <jfernandez@igalia.com> 2 26 -
trunk/Source/WebCore/Modules/mediastream/MediaDevices.cpp
r243887 r244749 103 103 { 104 104 auto* document = this->document(); 105 if (!document) { 106 promise.reject(Exception { InvalidStateError }); 107 return; 108 } 105 if (!document) 106 return; 109 107 110 108 auto audioConstraints = createMediaConstraints(constraints.audio); … … 115 113 auto request = UserMediaRequest::create(*document, { MediaStreamRequest::Type::UserMedia, WTFMove(audioConstraints), WTFMove(videoConstraints) }, WTFMove(promise)); 116 114 request->start(); 117 118 return; 119 } 120 121 ExceptionOr<void> MediaDevices::getDisplayMedia(const StreamConstraints& constraints, Promise&& promise) const 115 } 116 117 void MediaDevices::getDisplayMedia(const StreamConstraints& constraints, Promise&& promise) const 122 118 { 123 119 auto* document = this->document(); 124 120 if (!document) 125 return Exception { InvalidStateError }; 121 return; 122 123 if (!m_disableGetDisplayMediaUserGestureConstraint && !UserGestureIndicator::processingUserGesture()) { 124 promise.reject(Exception { InvalidAccessError, "getDisplayMedia must be called from a user gesture handler."_s }); 125 return; 126 } 126 127 127 128 auto request = UserMediaRequest::create(*document, { MediaStreamRequest::Type::DisplayMedia, { }, createMediaConstraints(constraints.video) }, WTFMove(promise)); 128 129 request->start(); 129 130 return { };131 130 } 132 131 -
trunk/Source/WebCore/Modules/mediastream/MediaDevices.h
r243887 r244749 77 77 }; 78 78 void getUserMedia(const StreamConstraints&, Promise&&) const; 79 ExceptionOr<void>getDisplayMedia(const StreamConstraints&, Promise&&) const;79 void getDisplayMedia(const StreamConstraints&, Promise&&) const; 80 80 void enumerateDevices(EnumerateDevicesPromise&&) const; 81 81 MediaTrackSupportedConstraints getSupportedConstraints(); … … 83 83 using RefCounted<MediaDevices>::ref; 84 84 using RefCounted<MediaDevices>::deref; 85 86 void setDisableGetDisplayMediaUserGestureConstraint(bool value) { m_disableGetDisplayMediaUserGestureConstraint = value; } 85 87 86 88 private: … … 108 110 const EventNames& m_eventNames; // Need to cache this so we can use it from GC threads. 109 111 bool m_listeningForDeviceChanges { false }; 112 bool m_disableGetDisplayMediaUserGestureConstraint { false }; 110 113 }; 111 114 -
trunk/Source/WebCore/Modules/mediastream/NavigatorMediaDevices.h
r241183 r244749 48 48 static NavigatorMediaDevices* from(Navigator*); 49 49 50 static MediaDevices* mediaDevices(Navigator&);50 WEBCORE_TESTSUPPORT_EXPORT static MediaDevices* mediaDevices(Navigator&); 51 51 MediaDevices* mediaDevices() const; 52 52 -
trunk/Source/WebCore/page/DOMWindow.h
r243887 r244749 159 159 BarProp& statusbar(); 160 160 BarProp& toolbar(); 161 Navigator& navigator();161 WEBCORE_EXPORT Navigator& navigator(); 162 162 Navigator* optionalNavigator() const { return m_navigator.get(); } 163 163 Navigator& clientInformation() { return navigator(); } -
trunk/Source/WebCore/testing/Internals.cpp
r244675 r244749 109 109 #include "LoaderStrategy.h" 110 110 #include "MallocStatistics.h" 111 #include "MediaDevices.h" 111 112 #include "MediaEngineConfigurationFactory.h" 112 113 #include "MediaPlayer.h" … … 119 120 #include "MockPageOverlay.h" 120 121 #include "MockPageOverlayClient.h" 122 #include "NavigatorMediaDevices.h" 121 123 #include "NetworkLoadInformation.h" 122 124 #include "Page.h" … … 4706 4708 } 4707 4709 4710 void Internals::setDisableGetDisplayMediaUserGestureConstraint(bool value) 4711 { 4712 Document* document = contextDocument(); 4713 if (!document || !document->domWindow()) 4714 return; 4715 4716 if (auto* mediaDevices = NavigatorMediaDevices::mediaDevices(document->domWindow()->navigator())) 4717 mediaDevices->setDisableGetDisplayMediaUserGestureConstraint(value); 4718 } 4708 4719 #endif 4709 4720 -
trunk/Source/WebCore/testing/Internals.h
r244307 r244749 707 707 void setMediaStreamTrackIdentifier(MediaStreamTrack&, String&& id); 708 708 void setMediaStreamSourceInterrupted(MediaStreamTrack&, bool); 709 void setDisableGetDisplayMediaUserGestureConstraint(bool); 709 710 #endif 710 711 -
trunk/Source/WebCore/testing/Internals.idl
r244307 r244749 680 680 [Conditional=MEDIA_STREAM] void setMediaStreamTrackIdentifier(MediaStreamTrack track, DOMString identifier); 681 681 [Conditional=MEDIA_STREAM] void setMediaStreamSourceInterrupted(MediaStreamTrack track, boolean interrupted); 682 [Conditional=MEDIA_STREAM] void setDisableGetDisplayMediaUserGestureConstraint(boolean value); 682 683 683 684 unsigned long long documentIdentifier(Document document); -
trunk/Tools/ChangeLog
r244730 r244749 1 2019-04-29 Youenn Fablet <youenn@apple.com> 2 3 getDisplayMedia should be called on user gesture 4 https://bugs.webkit.org/show_bug.cgi?id=197356 5 <rdar://problem/50296074> 6 7 Reviewed by Eric Carlson. 8 9 Update test configuration to inject internals 10 so that we can use it to simulate a user click to call getDisplayMedia. 11 12 * TestWebKitAPI/Tests/WebKit/getDisplayMedia.html: 13 * TestWebKitAPI/Tests/WebKitCocoa/GetDisplayMedia.mm: 14 (TestWebKitAPI::GetDisplayMediaTest::SetUp): 15 1 16 2019-04-26 Stephanie Lewis <slewis@apple.com> 2 17 -
trunk/Tools/TestWebKitAPI/Tests/WebKit/getDisplayMedia.html
r226412 r244749 8 8 function promptForCapture(constraints) 9 9 { 10 navigator.mediaDevices.getDisplayMedia(constraints) 11 .then((s) => { 12 stream = s; 13 video.srcObject = stream; 14 if (window.webkit) 15 window.webkit.messageHandlers.testHandler.postMessage('allowed'); 16 }) 17 .catch((error) => { 18 if (window.webkit) 19 window.webkit.messageHandlers.testHandler.postMessage('denied'); 10 window.internals.withUserGesture(async () => { 11 navigator.mediaDevices.getDisplayMedia(constraints) 12 .then((s) => { 13 stream = s; 14 video.srcObject = stream; 15 if (window.webkit) 16 window.webkit.messageHandlers.testHandler.postMessage('allowed'); 17 }) 18 .catch((error) => { 19 if (window.webkit) 20 window.webkit.messageHandlers.testHandler.postMessage('denied'); 21 }); 20 22 }); 21 23 } -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/GetDisplayMedia.mm
r242339 r244749 94 94 { 95 95 m_configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 96 auto context = adoptWK(TestWebKitAPI::Util::createContextForInjectedBundleTest("InternalsInjectedBundleTest")); 97 m_configuration.get().processPool = (WKProcessPool *)context.get(); 96 98 97 99 auto handler = adoptNS([[GetDisplayMediaMessageHandler alloc] init]);
Note:
See TracChangeset
for help on using the changeset viewer.