Changeset 203690 in webkit
- Timestamp:
- Jul 25, 2016 10:49:17 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r203688 r203690 1 2016-07-25 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Media controls on apple.com don't disappear when movie finishes playing 4 https://bugs.webkit.org/show_bug.cgi?id=160068 5 <rdar://problem/26668526> 6 7 Reviewed by Darin Adler. 8 9 When a video ends, it should cause media controls to hide. While current logic 10 mostly accounts for this, it does not account for programmatic seeks causing 11 the video to lose its 'ended' status before querying for whether or not to 12 show media controls. 13 14 Three new API tests: large-video-seek-after-ending.html 15 large-video-hides-controls-after-seek-to-end.html 16 large-video-seek-to-beginning-and-play-after-ending.html 17 18 * html/HTMLMediaElement.cpp: 19 (WebCore::HTMLMediaElement::mediaPlayerTimeChanged): 20 (WebCore::HTMLMediaElement::setPlaying): 21 * html/MediaElementSession.cpp: 22 (WebCore::MediaElementSession::canControlControlsManager): 23 * html/MediaElementSession.h: 24 1 25 2016-07-25 Frederic Wang <fwang@igalia.com> 2 26 -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r203473 r203690 4412 4412 m_sentEndEvent = true; 4413 4413 scheduleEvent(eventNames().endedEvent); 4414 m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureToControlControlsManager | MediaElementSession::RequirePlaybackToControlControlsManager); 4414 4415 } 4415 4416 // If the media element has a current media controller, then report the controller state … … 4432 4433 m_sentEndEvent = true; 4433 4434 scheduleEvent(eventNames().endedEvent); 4435 m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureToControlControlsManager | MediaElementSession::RequirePlaybackToControlControlsManager); 4434 4436 m_paused = true; 4435 4437 setPlaying(false); … … 4937 4939 void HTMLMediaElement::setPlaying(bool playing) 4938 4940 { 4941 if (playing && m_mediaSession) 4942 m_mediaSession->removeBehaviorRestriction(MediaElementSession::RequirePlaybackToControlControlsManager); 4943 4939 4944 if (m_playing == playing) 4940 4945 return; -
trunk/Source/WebCore/html/MediaElementSession.cpp
r203629 r203690 244 244 } 245 245 246 if (hasBehaviorRestriction(RequirePlaybackToControlControlsManager) && !m_element.isPlaying()) { 247 LOG(Media, "MediaElementSession::canControlControlsManager - returning FALSE: Needs to be playing"); 248 return false; 249 } 250 246 251 if (m_element.muted()) { 247 252 LOG(Media, "MediaElementSession::canControlControlsManager - returning FALSE: Muted"); -
trunk/Source/WebCore/html/MediaElementSession.h
r202425 r203690 96 96 OverrideUserGestureRequirementForMainContent = 1 << 12, 97 97 RequireUserGestureToControlControlsManager = 1 << 13, 98 RequirePlaybackToControlControlsManager = 1 << 14, 98 99 AllRestrictions = ~NoRestrictions, 99 100 }; -
trunk/Tools/ChangeLog
r203685 r203690 1 2016-07-25 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Media controls on apple.com don't disappear when movie finishes playing 4 https://bugs.webkit.org/show_bug.cgi?id=160068 5 <rdar://problem/26668526> 6 7 Reviewed by Darin Adler. 8 9 Adds new API tests. Please see WebCore ChangeLog for more details. 10 11 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 12 * TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm: 13 (-[MediaPlaybackMessageHandler initWithWKWebView:finalMessageString:]): 14 (-[MediaPlaybackMessageHandler userContentController:didReceiveScriptMessage:]): 15 (TestWebKitAPI::TEST): 16 (-[DidPlayMessageHandler initWithWKWebView:]): Deleted. 17 (-[DidPlayMessageHandler userContentController:didReceiveScriptMessage:]): Deleted. 18 * TestWebKitAPI/Tests/WebKit2Cocoa/large-video-hides-controls-after-seek-to-end.html: Added. 19 * TestWebKitAPI/Tests/WebKit2Cocoa/large-video-seek-after-ending.html: Added. 20 * TestWebKitAPI/Tests/WebKit2Cocoa/large-video-seek-to-beginning-and-play-after-ending.html: Added. 21 1 22 2016-07-25 Philippe Normand <pnormand@igalia.com> 2 23 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r203622 r203690 54 54 2DD7D3AF178227B30026E1E3 /* lots-of-text-vertical-lr.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2DD7D3AE178227AC0026E1E3 /* lots-of-text-vertical-lr.html */; }; 55 55 2E14A5291D3FE96B0010F35B /* autoplaying-video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E14A5281D3FE8B80010F35B /* autoplaying-video-with-audio.html */; }; 56 2E1B7B001D41ABA7007558B4 /* large-video-seek-after-ending.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E1B7AFF1D41A95F007558B4 /* large-video-seek-after-ending.html */; }; 57 2E1B7B021D41B1B9007558B4 /* large-video-hides-controls-after-seek-to-end.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E1B7B011D41B1B3007558B4 /* large-video-hides-controls-after-seek-to-end.html */; }; 58 2E1DFDF11D42E1E400714A00 /* large-video-seek-to-beginning-and-play-after-ending.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E1DFDF01D42E14400714A00 /* large-video-seek-to-beginning-and-play-after-ending.html */; }; 56 59 2E7765CD16C4D80A00BA2BB1 /* mainIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E7765CC16C4D80A00BA2BB1 /* mainIOS.mm */; }; 57 60 2E7765CF16C4D81100BA2BB1 /* mainMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E7765CE16C4D81100BA2BB1 /* mainMac.mm */; }; … … 499 502 files = ( 500 503 515BE16F1D428BB100DD7C68 /* StoreBlobToBeDeleted.html in Copy Resources */, 504 2E1DFDF11D42E1E400714A00 /* large-video-seek-to-beginning-and-play-after-ending.html in Copy Resources */, 505 2E1B7B021D41B1B9007558B4 /* large-video-hides-controls-after-seek-to-end.html in Copy Resources */, 506 2E1B7B001D41ABA7007558B4 /* large-video-seek-after-ending.html in Copy Resources */, 501 507 5C9E59411D3EB5AC00E3C62E /* ApplicationCache.db in Copy Resources */, 502 508 5C9E59421D3EB5AC00E3C62E /* ApplicationCache.db-shm in Copy Resources */, … … 699 705 2DD7D3AE178227AC0026E1E3 /* lots-of-text-vertical-lr.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "lots-of-text-vertical-lr.html"; sourceTree = "<group>"; }; 700 706 2E14A5281D3FE8B80010F35B /* autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autoplaying-video-with-audio.html"; sourceTree = "<group>"; }; 707 2E1B7AFF1D41A95F007558B4 /* large-video-seek-after-ending.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-seek-after-ending.html"; sourceTree = "<group>"; }; 708 2E1B7B011D41B1B3007558B4 /* large-video-hides-controls-after-seek-to-end.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-hides-controls-after-seek-to-end.html"; sourceTree = "<group>"; }; 709 2E1DFDF01D42E14400714A00 /* large-video-seek-to-beginning-and-play-after-ending.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-seek-to-beginning-and-play-after-ending.html"; sourceTree = "<group>"; }; 701 710 2E7765CC16C4D80A00BA2BB1 /* mainIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = mainIOS.mm; sourceTree = "<group>"; }; 702 711 2E7765CE16C4D81100BA2BB1 /* mainMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = mainMac.mm; sourceTree = "<group>"; }; … … 1336 1345 isa = PBXGroup; 1337 1346 children = ( 1347 2E1DFDF01D42E14400714A00 /* large-video-seek-to-beginning-and-play-after-ending.html */, 1348 2E1B7B011D41B1B3007558B4 /* large-video-hides-controls-after-seek-to-end.html */, 1338 1349 5C9E593E1D3EB1DE00E3C62E /* ApplicationCache.db */, 1339 1350 5C9E593F1D3EB1DE00E3C62E /* ApplicationCache.db-shm */, … … 1370 1381 51714EB21CF8C761004723C4 /* WebProcessKillIDBCleanup-1.html */, 1371 1382 51714EB31CF8C761004723C4 /* WebProcessKillIDBCleanup-2.html */, 1383 2E1B7AFF1D41A95F007558B4 /* large-video-seek-after-ending.html */, 1372 1384 ); 1373 1385 name = Resources; -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm
r203629 r203690 55 55 @end 56 56 57 @interface DidPlayMessageHandler : NSObject <WKScriptMessageHandler> {57 @interface MediaPlaybackMessageHandler : NSObject <WKScriptMessageHandler> { 58 58 RetainPtr<WKWebView> _webView; 59 59 } 60 60 61 61 @property (nonatomic) BOOL expectedToHaveControlsManager; 62 63 - (instancetype)initWithWKWebView:(WKWebView*)webView; 64 @end 65 66 @implementation DidPlayMessageHandler 67 68 - (instancetype)initWithWKWebView:(WKWebView*)webView 62 @property (nonatomic, retain) NSString *finalMessageString; 63 64 - (instancetype)initWithWKWebView:(WKWebView*)webView finalMessageString:(NSString *)finalMessageString; 65 @end 66 67 @implementation MediaPlaybackMessageHandler 68 69 - (instancetype)initWithWKWebView:(WKWebView*)webView finalMessageString:(NSString *)finalMessageString 69 70 { 70 71 if (!(self = [super init])) … … 72 73 73 74 _webView = webView; 75 _finalMessageString = finalMessageString; 74 76 75 77 return self; … … 81 83 82 84 NSString *bodyString = (NSString *)[message body]; 83 if ([bodyString isEqualToString: @"playing"] || [bodyString isEqualToString:@"paused"]) {85 if ([bodyString isEqualToString:self.finalMessageString]) { 84 86 BOOL hasControlsManager = [_webView _hasActiveVideoForControlsManager]; 85 87 if (self.expectedToHaveControlsManager) … … 133 135 configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone; 134 136 RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]); 135 RetainPtr< DidPlayMessageHandler> handler = adoptNS([[DidPlayMessageHandler alloc] initWithWKWebView:webView.get()]);137 RetainPtr<MediaPlaybackMessageHandler> handler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"playing"]); 136 138 [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"]; 137 139 … … 154 156 configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone; 155 157 RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]); 156 RetainPtr< DidPlayMessageHandler> handler = adoptNS([[DidPlayMessageHandler alloc] initWithWKWebView:webView.get()]);158 RetainPtr<MediaPlaybackMessageHandler> handler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"playing"]); 157 159 [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"]; 158 160 … … 175 177 configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone; 176 178 RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]); 177 RetainPtr< DidPlayMessageHandler> playbackHandler = adoptNS([[DidPlayMessageHandler alloc] initWithWKWebView:webView.get()]);179 RetainPtr<MediaPlaybackMessageHandler> playbackHandler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"paused"]); 178 180 [[configuration userContentController] addScriptMessageHandler:playbackHandler.get() name:@"playingHandler"]; 179 181 … … 195 197 } 196 198 199 TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoSeeksAfterEnding) 200 { 201 RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 202 configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone; 203 RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]); 204 RetainPtr<MediaPlaybackMessageHandler> handler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"ended"]); 205 [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"]; 206 207 RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]); 208 [[window contentView] addSubview:webView.get()]; 209 210 // Since the video has ended, the expectation is NO even if the page programmatically seeks to the beginning. 211 [handler setExpectedToHaveControlsManager:NO]; 212 NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"large-video-seek-after-ending" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]; 213 [webView loadRequest:request]; 214 215 TestWebKitAPI::Util::run(&testedControlsManagerAfterPlaying); 216 TestWebKitAPI::Util::run(&receivedScriptMessage); 217 } 218 219 TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoSeeksAndPlaysAfterEnding) 220 { 221 RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 222 configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone; 223 RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]); 224 RetainPtr<MediaPlaybackMessageHandler> handler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"replaying"]); 225 [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"]; 226 227 RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]); 228 [[window contentView] addSubview:webView.get()]; 229 230 // Since the video is still playing, the expectation is YES even if the video has ended once. 231 [handler setExpectedToHaveControlsManager:YES]; 232 NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"large-video-seek-to-beginning-and-play-after-ending" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]; 233 [webView loadRequest:request]; 234 235 TestWebKitAPI::Util::run(&testedControlsManagerAfterPlaying); 236 TestWebKitAPI::Util::run(&receivedScriptMessage); 237 } 238 239 TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoHidesControlsAfterSeekingToEnd) 240 { 241 RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 242 configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone; 243 RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]); 244 RetainPtr<MediaPlaybackMessageHandler> handler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"ended"]); 245 [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"]; 246 247 RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]); 248 [[window contentView] addSubview:webView.get()]; 249 250 RetainPtr<OnLoadMessageHandler> onloadHandler = adoptNS([[OnLoadMessageHandler alloc] initWithWKWebView:webView.get() handler:^() { 251 [webView mouseDownAtPoint:NSMakePoint(50, 50)]; 252 }]); 253 [[configuration userContentController] addScriptMessageHandler:onloadHandler.get() name:@"onloadHandler"]; 254 255 // Since the video has ended, the expectation is NO. 256 [handler setExpectedToHaveControlsManager:NO]; 257 NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"large-video-hides-controls-after-seek-to-end" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]; 258 [webView loadRequest:request]; 259 260 TestWebKitAPI::Util::run(&testedControlsManagerAfterPlaying); 261 TestWebKitAPI::Util::run(&receivedScriptMessage); 262 } 263 197 264 TEST(VideoControlsManager, VideoControlsManagerSingleLargeVideoWithoutAudio) 198 265 { … … 200 267 configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone; 201 268 RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]); 202 RetainPtr< DidPlayMessageHandler> handler = adoptNS([[DidPlayMessageHandler alloc] initWithWKWebView:webView.get()]);269 RetainPtr<MediaPlaybackMessageHandler> handler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"playing"]); 203 270 [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"]; 204 271 … … 221 288 configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone; 222 289 RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]); 223 RetainPtr< DidPlayMessageHandler> handler = adoptNS([[DidPlayMessageHandler alloc] initWithWKWebView:webView.get()]);290 RetainPtr<MediaPlaybackMessageHandler> handler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"playing"]); 224 291 [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"]; 225 292
Note: See TracChangeset
for help on using the changeset viewer.