Changeset 203464 in webkit
- Timestamp:
- Jul 20, 2016 12:25:16 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r203463 r203464 1 2016-07-20 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Media controls don't appear when pausing a small autoplaying video 4 https://bugs.webkit.org/show_bug.cgi?id=159972 5 <rdar://problem/27180657> 6 7 Reviewed by Beth Dakin. 8 9 When pausing an autoplaying video, remove behavior restrictions for the 10 initial user gesture and show media controls. 11 12 New WebKit API test. See VideoControlsManagerSingleSmallAutoplayingVideo. 13 14 * html/HTMLMediaElement.cpp: 15 (WebCore::HTMLMediaElement::pause): 16 1 17 2016-07-20 Chris Dumez <cdumez@apple.com> 2 18 -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r203388 r203464 3156 3156 return; 3157 3157 3158 if (ScriptController::processingUserGestureForMedia()) 3159 removeBehaviorsRestrictionsAfterFirstUserGesture(); 3160 3158 3161 pauseInternal(); 3159 3162 } -
trunk/Tools/ChangeLog
r203457 r203464 1 2016-07-20 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Media controls don't appear when pausing a small autoplaying video 4 https://bugs.webkit.org/show_bug.cgi?id=159972 5 <rdar://problem/27180657> 6 7 Reviewed by Beth Dakin. 8 9 Adds a new test that verifies media controls show up when pausing a small autoplayed video. Also adds mechanisms 10 for simulating basic user interaction in VideoControlsManager. 11 12 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 13 * TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm: 14 (-[WKWebView mouseDownAtPoint:]): 15 (-[DidPlayMessageHandler userContentController:didReceiveScriptMessage:]): 16 (-[OnLoadMessageHandler initWithWKWebView:handler:]): 17 (-[OnLoadMessageHandler userContentController:didReceiveScriptMessage:]): 18 (TestWebKitAPI::TEST): 19 * TestWebKitAPI/Tests/WebKit2Cocoa/autoplaying-video-with-audio.html: Added. 20 1 21 2016-07-20 Per Arne Vollan <pvollan@apple.com> 2 22 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r203426 r203464 52 52 2DC4CF771D2D9DD800ECCC94 /* DataDetection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DC4CF761D2D9DD800ECCC94 /* DataDetection.mm */; }; 53 53 2DD7D3AF178227B30026E1E3 /* lots-of-text-vertical-lr.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2DD7D3AE178227AC0026E1E3 /* lots-of-text-vertical-lr.html */; }; 54 2E14A5291D3FE96B0010F35B /* autoplaying-video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E14A5281D3FE8B80010F35B /* autoplaying-video-with-audio.html */; }; 54 55 2E7765CD16C4D80A00BA2BB1 /* mainIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E7765CC16C4D80A00BA2BB1 /* mainIOS.mm */; }; 55 56 2E7765CF16C4D81100BA2BB1 /* mainMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E7765CE16C4D81100BA2BB1 /* mainMac.mm */; }; … … 495 496 5C9E59421D3EB5AC00E3C62E /* ApplicationCache.db-shm in Copy Resources */, 496 497 5C9E59431D3EB5AC00E3C62E /* ApplicationCache.db-wal in Copy Resources */, 498 2E14A5291D3FE96B0010F35B /* autoplaying-video-with-audio.html in Copy Resources */, 497 499 7CCB99231D3B4A46003922F6 /* open-multiple-external-url.html in Copy Resources */, 498 500 932AE53D1D371047005DFFAF /* focus-inputs.html in Copy Resources */, … … 688 690 2DD7D3A9178205D00026E1E3 /* ResizeReversePaginatedWebView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResizeReversePaginatedWebView.cpp; sourceTree = "<group>"; }; 689 691 2DD7D3AE178227AC0026E1E3 /* lots-of-text-vertical-lr.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "lots-of-text-vertical-lr.html"; sourceTree = "<group>"; }; 692 2E14A5281D3FE8B80010F35B /* autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autoplaying-video-with-audio.html"; sourceTree = "<group>"; }; 690 693 2E7765CC16C4D80A00BA2BB1 /* mainIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = mainIOS.mm; sourceTree = "<group>"; }; 691 694 2E7765CE16C4D81100BA2BB1 /* mainMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = mainMac.mm; sourceTree = "<group>"; }; … … 1319 1322 5C9E593F1D3EB1DE00E3C62E /* ApplicationCache.db-shm */, 1320 1323 5C9E59401D3EB1DE00E3C62E /* ApplicationCache.db-wal */, 1324 2E14A5281D3FE8B80010F35B /* autoplaying-video-with-audio.html */, 1321 1325 93CFA8661CEB9DE1000565A8 /* autofocused-text-input.html */, 1322 1326 A16F66B91C40EA2000BD4D24 /* ContentFiltering.html */, -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm
r201165 r203464 27 27 28 28 #import "PlatformUtilities.h" 29 #import <Carbon/Carbon.h> 29 30 #import <WebKit/WKWebViewConfigurationPrivate.h> 30 31 #import <WebKit/WKWebViewPrivate.h> … … 36 37 static bool receivedScriptMessage; 37 38 39 @interface WKWebView (UserInteraction) 40 41 - (void)mouseDownAtPoint:(NSPoint)point; 42 43 @end 44 45 @implementation WKWebView (UserInteraction) 46 47 - (void)mouseDownAtPoint:(NSPoint)point { 48 [self mouseDown:[NSEvent mouseEventWithType:NSEventTypeLeftMouseDown location:NSMakePoint(point.x, point.y) modifierFlags:0 timestamp:GetCurrentEventTime() windowNumber:0 context:[NSGraphicsContext currentContext] eventNumber:0 clickCount:0 pressure:0]]; 49 } 50 51 @end 52 38 53 @interface DidPlayMessageHandler : NSObject <WKScriptMessageHandler> { 39 54 RetainPtr<WKWebView> _webView; … … 62 77 63 78 NSString *bodyString = (NSString *)[message body]; 64 if ([bodyString isEqualToString:@"playing"] ) {79 if ([bodyString isEqualToString:@"playing"] || [bodyString isEqualToString:@"paused"]) { 65 80 BOOL hasControlsManager = [_webView _hasActiveVideoForControlsManager]; 66 81 if (self.expectedToHaveControlsManager) … … 73 88 @end 74 89 90 @interface OnLoadMessageHandler : NSObject <WKScriptMessageHandler> { 91 RetainPtr<WKWebView> _webView; 92 } 93 94 @property (nonatomic, strong) dispatch_block_t onloadHandler; 95 96 - (instancetype)initWithWKWebView:(WKWebView*)webView handler:(dispatch_block_t)handler; 97 @end 98 99 @implementation OnLoadMessageHandler 100 101 - (instancetype)initWithWKWebView:(WKWebView*)webView handler:(dispatch_block_t)handler 102 { 103 if (!(self = [super init])) 104 return nil; 105 106 _webView = webView; 107 _onloadHandler = handler; 108 109 return self; 110 } 111 112 - (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message 113 { 114 if (![(NSString *)[message body] isEqualToString:@"loaded"]) 115 return; 116 117 if (_onloadHandler) 118 _onloadHandler(); 119 120 _onloadHandler = nil; 121 } 122 @end 123 75 124 namespace TestWebKitAPI { 76 125 … … 117 166 } 118 167 168 TEST(VideoControlsManager, VideoControlsManagerSingleSmallAutoplayingVideo) 169 { 170 RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 171 configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone; 172 RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]); 173 RetainPtr<DidPlayMessageHandler> playbackHandler = adoptNS([[DidPlayMessageHandler alloc] initWithWKWebView:webView.get()]); 174 [[configuration userContentController] addScriptMessageHandler:playbackHandler.get() name:@"playingHandler"]; 175 176 RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]); 177 [[window contentView] addSubview:webView.get()]; 178 179 RetainPtr<OnLoadMessageHandler> onloadHandler = adoptNS([[OnLoadMessageHandler alloc] initWithWKWebView:webView.get() handler:^() { 180 [webView mouseDownAtPoint:NSMakePoint(50, 50)]; 181 }]); 182 [[configuration userContentController] addScriptMessageHandler:onloadHandler.get() name:@"onloadHandler"]; 183 184 // A small video should have a controls manager after the first user gesture, which includes pausing the video. The expectation is YES. 185 [playbackHandler setExpectedToHaveControlsManager:YES]; 186 NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"autoplaying-video-with-audio" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]; 187 [webView loadRequest:request]; 188 189 TestWebKitAPI::Util::run(&testedControlsManagerAfterPlaying); 190 TestWebKitAPI::Util::run(&receivedScriptMessage); 191 } 192 119 193 TEST(VideoControlsManager, VideoControlsManagerSingleLargeVideoWithoutAudio) 120 194 {
Note: See TracChangeset
for help on using the changeset viewer.