Changeset 211193 in webkit
- Timestamp:
- Jan 25, 2017 6:18:00 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r211192 r211193 1 2017-01-25 Matt Rajca <mrajca@apple.com> 2 3 Notify clients when the user plays media otherwise prevented from autoplaying 4 https://bugs.webkit.org/show_bug.cgi?id=167390 5 6 Reviewed by Alex Christensen. 7 8 The API is tested. 9 10 * html/HTMLMediaElement.cpp: 11 (WebCore::HTMLMediaElement::playInternal): 12 * page/ChromeClient.h: 13 1 14 2017-01-25 Wenson Hsieh <wenson_hsieh@apple.com> 2 15 -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r211097 r211193 3168 3168 3169 3169 if (ScriptController::processingUserGestureForMedia() && m_preventedFromPlayingWithoutUserGesture) { 3170 // FIXME: notify clients a user gesture was made and started playback of an element that was otherwise prevented from playing. 3170 if (Page* page = document().page()) 3171 page->chrome().client().didPlayMediaPreventedFromPlayingWithoutUserGesture(); 3171 3172 m_preventedFromPlayingWithoutUserGesture = false; 3172 3173 } -
trunk/Source/WebCore/page/ChromeClient.h
r211042 r211193 421 421 422 422 virtual void isPlayingMediaDidChange(MediaProducer::MediaStateFlags, uint64_t) { } 423 virtual void didPlayMediaPreventedFromPlayingWithoutUserGesture() { } 423 424 424 425 #if ENABLE(MEDIA_SESSION) -
trunk/Source/WebKit2/ChangeLog
r211192 r211193 1 2017-01-25 Matt Rajca <mrajca@apple.com> 2 3 Notify clients when the user plays media otherwise prevented from autoplaying 4 https://bugs.webkit.org/show_bug.cgi?id=167390 5 6 Reviewed by Alex Christensen. 7 8 * UIProcess/API/APIUIClient.h: 9 (API::UIClient::didPlayMediaPreventedFromPlayingWithoutUserGesture): 10 * UIProcess/API/C/WKPage.cpp: 11 (WKPageSetPageUIClient): 12 * UIProcess/API/C/WKPageUIClient.h: 13 * UIProcess/WebPageProxy.cpp: 14 (WebKit::WebPageProxy::didPlayMediaPreventedFromPlayingWithoutUserGesture): 15 * UIProcess/WebPageProxy.h: 16 * UIProcess/WebPageProxy.messages.in: 17 * WebProcess/WebCoreSupport/WebChromeClient.cpp: 18 (WebKit::WebChromeClient::didPlayMediaPreventedFromPlayingWithoutUserGesture): 19 * WebProcess/WebCoreSupport/WebChromeClient.h: 20 1 21 2017-01-25 Wenson Hsieh <wenson_hsieh@apple.com> 2 22 -
trunk/Source/WebKit2/UIProcess/API/APIUIClient.h
r209010 r211193 153 153 virtual void didBeginCaptureSession() { } 154 154 virtual void didEndCaptureSession() { } 155 virtual void didPlayMediaPreventedFromPlayingWithoutUserGesture(WebKit::WebPageProxy&) { } 155 156 156 157 #if ENABLE(MEDIA_SESSION) -
trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp
r209558 r211193 2236 2236 } 2237 2237 #endif 2238 2239 void didPlayMediaPreventedFromPlayingWithoutUserGesture(WebPageProxy& page) override 2240 { 2241 if (!m_client.didPlayMediaPreventedFromPlayingWithoutUserGesture) 2242 return; 2243 2244 m_client.didPlayMediaPreventedFromPlayingWithoutUserGesture(toAPI(&page), m_client.base.clientInfo); 2245 } 2238 2246 }; 2239 2247 -
trunk/Source/WebKit2/UIProcess/API/C/WKPageUIClient.h
r208903 r211193 103 103 typedef void (*WKPageDidClickAutoFillButtonCallback)(WKPageRef page, WKTypeRef userData, const void *clientInfo); 104 104 typedef void (*WKPageMediaSessionMetadataDidChangeCallback)(WKPageRef page, WKMediaSessionMetadataRef metadata, const void* clientInfo); 105 typedef void (*WKDidPlayMediaPreventedFromPlayingWithoutUserGesture)(WKPageRef page, const void* clientInfo); 105 106 typedef void (*WKFullscreenMayReturnToInlineCallback)(WKPageRef page, const void* clientInfo); 106 107 … … 726 727 WKRequestPointerLockCallback requestPointerLock; 727 728 WKDidLosePointerLockCallback didLosePointerLock; 729 WKDidPlayMediaPreventedFromPlayingWithoutUserGesture didPlayMediaPreventedFromPlayingWithoutUserGesture; 728 730 } WKPageUIClientV8; 729 731 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r211165 r211193 6528 6528 #endif 6529 6529 6530 void WebPageProxy::didPlayMediaPreventedFromPlayingWithoutUserGesture() 6531 { 6532 m_uiClient->didPlayMediaPreventedFromPlayingWithoutUserGesture(*this); 6533 } 6534 6530 6535 #if PLATFORM(MAC) 6531 6536 void WebPageProxy::removeNavigationGestureSnapshot() -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r211165 r211193 1059 1059 bool hasActiveVideoStream() const { return m_mediaState & WebCore::MediaProducer::HasActiveVideoCaptureDevice; } 1060 1060 WebCore::MediaProducer::MediaStateFlags mediaStateFlags() const { return m_mediaState; } 1061 void didPlayMediaPreventedFromPlayingWithoutUserGesture(); 1061 1062 1062 1063 #if PLATFORM(MAC) -
trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in
r211165 r211193 440 440 441 441 IsPlayingMediaDidChange(unsigned state, uint64_t sourceElementID) 442 DidPlayMediaPreventedFromPlayingWithoutUserGesture() 442 443 443 444 #if ENABLE(MEDIA_SESSION) -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
r211042 r211193 1085 1085 } 1086 1086 1087 void WebChromeClient::didPlayMediaPreventedFromPlayingWithoutUserGesture() 1088 { 1089 m_page.send(Messages::WebPageProxy::DidPlayMediaPreventedFromPlayingWithoutUserGesture()); 1090 } 1091 1087 1092 #if ENABLE(MEDIA_SESSION) 1088 1093 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
r211042 r211193 298 298 299 299 void isPlayingMediaDidChange(WebCore::MediaProducer::MediaStateFlags, uint64_t) final; 300 void didPlayMediaPreventedFromPlayingWithoutUserGesture() final; 300 301 301 302 #if ENABLE(MEDIA_SESSION) -
trunk/Tools/ChangeLog
r211174 r211193 1 2017-01-25 Matt Rajca <mrajca@apple.com> 2 3 Notify clients when the user plays media otherwise prevented from autoplaying 4 https://bugs.webkit.org/show_bug.cgi?id=167390 5 6 Reviewed by Alex Christensen. 7 8 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 9 * TestWebKitAPI/Tests/WebKit2/autoplay-with-controls.html: Added. 10 * TestWebKitAPI/Tests/WebKit2/js-play-with-controls.html: Added. 11 * TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm: 12 (didPlayMediaPreventedFromPlayingWithoutUserGesture): 13 (TEST): 14 * TestWebKitAPI/cocoa/TestWKWebView.h: 15 * TestWebKitAPI/cocoa/TestWKWebView.mm: 16 (-[TestWKWebViewHostWindow _mouseUpAtPoint:]): 17 (-[TestWKWebView waitForLoad]): 18 (-[TestWKWebView mouseUpAtPoint:]): 19 * WebKitTestRunner/TestController.cpp: 20 (WTR::TestController::createOtherPage): 21 (WTR::TestController::createWebViewWithOptions): 22 1 23 2017-01-25 Matt Rajca <mrajca@apple.com> 2 24 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r211097 r211193 510 510 C95984F51E36BC6B002C0D45 /* autoplay-no-audio-check.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C95984F31E36BC55002C0D45 /* autoplay-no-audio-check.html */; }; 511 511 C95984F71E36BCEF002C0D45 /* test-without-audio-track.mp4 in Copy Resources */ = {isa = PBXBuildFile; fileRef = C95984F61E36BCD7002C0D45 /* test-without-audio-track.mp4 */; }; 512 C99B675C1E39721A00FC6C80 /* autoplay-with-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C99B675A1E3971FC00FC6C80 /* autoplay-with-controls.html */; }; 513 C99B675D1E39722000FC6C80 /* js-play-with-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C99B675B1E3971FC00FC6C80 /* js-play-with-controls.html */; }; 514 C99B675F1E39736F00FC6C80 /* no-autoplay-with-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C99B675E1E39735C00FC6C80 /* no-autoplay-with-controls.html */; }; 512 515 CD59F53419E9110D00CF1835 /* file-with-mse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD59F53219E910AA00CF1835 /* file-with-mse.html */; }; 513 516 CD59F53519E9110D00CF1835 /* test-mse.mp4 in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD59F53319E910BC00CF1835 /* test-mse.mp4 */; }; … … 608 611 dstSubfolderSpec = 7; 609 612 files = ( 613 C99B675F1E39736F00FC6C80 /* no-autoplay-with-controls.html in Copy Resources */, 614 C99B675D1E39722000FC6C80 /* js-play-with-controls.html in Copy Resources */, 615 C99B675C1E39721A00FC6C80 /* autoplay-with-controls.html in Copy Resources */, 610 616 C95984F71E36BCEF002C0D45 /* test-without-audio-track.mp4 in Copy Resources */, 611 617 C95984F41E36BC6B002C0D45 /* autoplay-check.html in Copy Resources */, … … 1275 1281 C95984F31E36BC55002C0D45 /* autoplay-no-audio-check.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autoplay-no-audio-check.html"; sourceTree = "<group>"; }; 1276 1282 C95984F61E36BCD7002C0D45 /* test-without-audio-track.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = "test-without-audio-track.mp4"; sourceTree = "<group>"; }; 1283 C99B675A1E3971FC00FC6C80 /* autoplay-with-controls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autoplay-with-controls.html"; sourceTree = "<group>"; }; 1284 C99B675B1E3971FC00FC6C80 /* js-play-with-controls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "js-play-with-controls.html"; sourceTree = "<group>"; }; 1285 C99B675E1E39735C00FC6C80 /* no-autoplay-with-controls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "no-autoplay-with-controls.html"; sourceTree = "<group>"; }; 1277 1286 CD225C071C45A69200140761 /* ParsedContentRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParsedContentRange.cpp; sourceTree = "<group>"; }; 1278 1287 CD5393C71757BA9700C07123 /* MD5.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MD5.cpp; sourceTree = "<group>"; }; … … 1962 1971 C95984F21E36BC55002C0D45 /* autoplay-check.html */, 1963 1972 C95984F31E36BC55002C0D45 /* autoplay-no-audio-check.html */, 1973 C99B675A1E3971FC00FC6C80 /* autoplay-with-controls.html */, 1964 1974 7C486BA01AA1254B003F6F9B /* bundle-file.html */, 1965 1975 9BD4239B1E04BFD000200395 /* chinese-character-with-image.html */, … … 1982 1992 BCBD372E125ABBE600D2C29F /* icon.png */, 1983 1993 CE3524F51B142BBB0028A7C5 /* input-focus-blur.html */, 1994 C99B675B1E3971FC00FC6C80 /* js-play-with-controls.html */, 1984 1995 8349D3C31DB9724F004A9F65 /* link-with-download-attribute.html */, 1985 1996 378E647816326FDF00B6C676 /* link-with-title.html */, … … 1992 2003 7A1458FB1AD5C03500E06772 /* mouse-button-listener.html */, 1993 2004 33E79E05137B5FCE00E32D99 /* mouse-move-listener.html */, 2005 C99B675E1E39735C00FC6C80 /* no-autoplay-with-controls.html */, 1994 2006 CEA6CF2719CCF69D0064F5A7 /* open-and-close-window.html */, 1995 2007 F6FDDDD514241C48004F1729 /* push-state.html */, -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm
r211174 r211193 40 40 #if WK_API_ENABLED 41 41 42 @interface WKWebView () 43 - (WKPageRef)_pageForTesting; 44 @end 45 42 46 static bool doneCompiling; 43 47 static bool receivedAlert; … … 214 218 } 215 219 216 #endif 220 #if PLATFORM(MAC) 221 static void didPlayMediaPreventedFromPlayingWithoutUserGesture(WKPageRef page, const void* clientInfo) 222 { 223 receivedAlert = true; 224 } 225 226 TEST(WebKit2, WebsitePoliciesPlayAfterPreventedAutoplay) 227 { 228 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 229 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 336, 276) configuration:configuration.get()]); 230 231 auto delegate = adoptNS([[AutoplayPoliciesDelegate alloc] init]); 232 [delegate setAutoplayPolicy:_WKWebsiteAutoplayPolicyDeny]; 233 [webView setNavigationDelegate:delegate.get()]; 234 235 WKPageUIClientV8 uiClient; 236 memset(&uiClient, 0, sizeof(uiClient)); 237 238 uiClient.base.version = 8; 239 uiClient.didPlayMediaPreventedFromPlayingWithoutUserGesture = didPlayMediaPreventedFromPlayingWithoutUserGesture; 240 241 WKPageSetPageUIClient([webView _pageForTesting], &uiClient.base); 242 NSPoint playButtonClickPoint = NSMakePoint(20, 256); 243 244 receivedAlert = false; 245 NSURLRequest *jsPlayRequest = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"js-play-with-controls" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]; 246 [webView loadRequest:jsPlayRequest]; 247 [webView waitForMessage:@"loaded"]; 248 [webView mouseDownAtPoint:playButtonClickPoint simulatePressure:NO]; 249 [webView mouseUpAtPoint:playButtonClickPoint]; 250 TestWebKitAPI::Util::run(&receivedAlert); 251 252 receivedAlert = false; 253 [webView loadHTMLString:@"" baseURL:nil]; 254 255 NSURLRequest *autoplayRequest = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"autoplay-with-controls" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]; 256 [webView loadRequest:autoplayRequest]; 257 [webView waitForMessage:@"loaded"]; 258 [webView mouseDownAtPoint:playButtonClickPoint simulatePressure:NO]; 259 [webView mouseUpAtPoint:playButtonClickPoint]; 260 TestWebKitAPI::Util::run(&receivedAlert); 261 262 receivedAlert = false; 263 [webView loadHTMLString:@"" baseURL:nil]; 264 265 NSURLRequest *noAutoplayRequest = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"no-autoplay-with-controls" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]; 266 [webView loadRequest:noAutoplayRequest]; 267 [webView waitForMessage:@"loaded"]; 268 [webView mouseDownAtPoint:playButtonClickPoint simulatePressure:NO]; 269 [webView mouseUpAtPoint:playButtonClickPoint]; 270 [webView waitForMessage:@"played"]; 271 ASSERT_FALSE(receivedAlert); 272 } 273 #endif 274 275 #endif -
trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h
r211045 r211193 45 45 // Simulates clicking with a pressure-sensitive device, if possible. 46 46 - (void)mouseDownAtPoint:(NSPoint)point simulatePressure:(BOOL)simulatePressure; 47 - (void)mouseUpAtPoint:(NSPoint)point; 47 48 - (void)typeCharacter:(char)character; 48 49 @end -
trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm
r211045 r211193 121 121 #endif 122 122 } 123 124 - (void)_mouseUpAtPoint:(NSPoint)point 125 { 126 [self sendEvent:[NSEvent mouseEventWithType:NSEventTypeLeftMouseUp location:point modifierFlags:0 timestamp:GetCurrentEventTime() windowNumber:self.windowNumber context:[NSGraphicsContext currentContext] eventNumber:++gEventNumber clickCount:1 pressure:0]]; 127 } 123 128 #endif // PLATFORM(MAC) 124 129 … … 251 256 } 252 257 258 - (void)mouseUpAtPoint:(NSPoint)point 259 { 260 [_hostWindow _mouseUpAtPoint:point]; 261 } 262 253 263 - (void)typeCharacter:(char)character { 254 264 NSString *characterAsString = [NSString stringWithFormat:@"%c" , character]; -
trunk/Tools/WebKitTestRunner/TestController.cpp
r210446 r211193 280 280 requestPointerLock, 281 281 0, 282 0, // didPlayMediaPreventedFromPlayingWithoutUserGesture 282 283 }; 283 284 WKPageSetPageUIClient(newPage, &otherPageUIClient.base); … … 552 553 requestPointerLock, 553 554 0, 555 0, // didPlayMediaPreventedFromPlayingWithoutUserGesture 554 556 }; 555 557 WKPageSetPageUIClient(m_mainWebView->page(), &pageUIClient.base);
Note: See TracChangeset
for help on using the changeset viewer.