Diff
Modified: trunk/Source/WebCore/ChangeLog (203689 => 203690)
--- trunk/Source/WebCore/ChangeLog 2016-07-25 17:21:49 UTC (rev 203689)
+++ trunk/Source/WebCore/ChangeLog 2016-07-25 17:49:17 UTC (rev 203690)
@@ -1,3 +1,27 @@
+2016-07-25 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Media controls on apple.com don't disappear when movie finishes playing
+ https://bugs.webkit.org/show_bug.cgi?id=160068
+ <rdar://problem/26668526>
+
+ Reviewed by Darin Adler.
+
+ When a video ends, it should cause media controls to hide. While current logic
+ mostly accounts for this, it does not account for programmatic seeks causing
+ the video to lose its 'ended' status before querying for whether or not to
+ show media controls.
+
+ Three new API tests: large-video-seek-after-ending.html
+ large-video-hides-controls-after-seek-to-end.html
+ large-video-seek-to-beginning-and-play-after-ending.html
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::mediaPlayerTimeChanged):
+ (WebCore::HTMLMediaElement::setPlaying):
+ * html/MediaElementSession.cpp:
+ (WebCore::MediaElementSession::canControlControlsManager):
+ * html/MediaElementSession.h:
+
2016-07-25 Frederic Wang <fw...@igalia.com>
Introduce a MathMLOperatorElement class
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (203689 => 203690)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2016-07-25 17:21:49 UTC (rev 203689)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2016-07-25 17:49:17 UTC (rev 203690)
@@ -4411,6 +4411,7 @@
if (!m_sentEndEvent) {
m_sentEndEvent = true;
scheduleEvent(eventNames().endedEvent);
+ m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureToControlControlsManager | MediaElementSession::RequirePlaybackToControlControlsManager);
}
// If the media element has a current media controller, then report the controller state
// for the media element's current media controller.
@@ -4431,6 +4432,7 @@
if (!m_sentEndEvent && m_player && m_player->ended()) {
m_sentEndEvent = true;
scheduleEvent(eventNames().endedEvent);
+ m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureToControlControlsManager | MediaElementSession::RequirePlaybackToControlControlsManager);
m_paused = true;
setPlaying(false);
}
@@ -4936,6 +4938,9 @@
void HTMLMediaElement::setPlaying(bool playing)
{
+ if (playing && m_mediaSession)
+ m_mediaSession->removeBehaviorRestriction(MediaElementSession::RequirePlaybackToControlControlsManager);
+
if (m_playing == playing)
return;
Modified: trunk/Source/WebCore/html/MediaElementSession.cpp (203689 => 203690)
--- trunk/Source/WebCore/html/MediaElementSession.cpp 2016-07-25 17:21:49 UTC (rev 203689)
+++ trunk/Source/WebCore/html/MediaElementSession.cpp 2016-07-25 17:49:17 UTC (rev 203690)
@@ -243,6 +243,11 @@
return true;
}
+ if (hasBehaviorRestriction(RequirePlaybackToControlControlsManager) && !m_element.isPlaying()) {
+ LOG(Media, "MediaElementSession::canControlControlsManager - returning FALSE: Needs to be playing");
+ return false;
+ }
+
if (m_element.muted()) {
LOG(Media, "MediaElementSession::canControlControlsManager - returning FALSE: Muted");
return false;
Modified: trunk/Source/WebCore/html/MediaElementSession.h (203689 => 203690)
--- trunk/Source/WebCore/html/MediaElementSession.h 2016-07-25 17:21:49 UTC (rev 203689)
+++ trunk/Source/WebCore/html/MediaElementSession.h 2016-07-25 17:49:17 UTC (rev 203690)
@@ -95,6 +95,7 @@
InvisibleAutoplayNotPermitted = 1 << 11,
OverrideUserGestureRequirementForMainContent = 1 << 12,
RequireUserGestureToControlControlsManager = 1 << 13,
+ RequirePlaybackToControlControlsManager = 1 << 14,
AllRestrictions = ~NoRestrictions,
};
typedef unsigned BehaviorRestrictions;
Modified: trunk/Tools/ChangeLog (203689 => 203690)
--- trunk/Tools/ChangeLog 2016-07-25 17:21:49 UTC (rev 203689)
+++ trunk/Tools/ChangeLog 2016-07-25 17:49:17 UTC (rev 203690)
@@ -1,3 +1,24 @@
+2016-07-25 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Media controls on apple.com don't disappear when movie finishes playing
+ https://bugs.webkit.org/show_bug.cgi?id=160068
+ <rdar://problem/26668526>
+
+ Reviewed by Darin Adler.
+
+ Adds new API tests. Please see WebCore ChangeLog for more details.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm:
+ (-[MediaPlaybackMessageHandler initWithWKWebView:finalMessageString:]):
+ (-[MediaPlaybackMessageHandler userContentController:didReceiveScriptMessage:]):
+ (TestWebKitAPI::TEST):
+ (-[DidPlayMessageHandler initWithWKWebView:]): Deleted.
+ (-[DidPlayMessageHandler userContentController:didReceiveScriptMessage:]): Deleted.
+ * TestWebKitAPI/Tests/WebKit2Cocoa/large-video-hides-controls-after-seek-to-end.html: Added.
+ * TestWebKitAPI/Tests/WebKit2Cocoa/large-video-seek-after-ending.html: Added.
+ * TestWebKitAPI/Tests/WebKit2Cocoa/large-video-seek-to-beginning-and-play-after-ending.html: Added.
+
2016-07-25 Philippe Normand <pnorm...@igalia.com>
Unreviewed, fix test-webkitpy after r203674.
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (203689 => 203690)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2016-07-25 17:21:49 UTC (rev 203689)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2016-07-25 17:49:17 UTC (rev 203690)
@@ -53,6 +53,9 @@
2DC4CF771D2D9DD800ECCC94 /* DataDetection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DC4CF761D2D9DD800ECCC94 /* DataDetection.mm */; };
2DD7D3AF178227B30026E1E3 /* lots-of-text-vertical-lr.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2DD7D3AE178227AC0026E1E3 /* lots-of-text-vertical-lr.html */; };
2E14A5291D3FE96B0010F35B /* autoplaying-video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E14A5281D3FE8B80010F35B /* autoplaying-video-with-audio.html */; };
+ 2E1B7B001D41ABA7007558B4 /* large-video-seek-after-ending.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E1B7AFF1D41A95F007558B4 /* large-video-seek-after-ending.html */; };
+ 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 */; };
+ 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 */; };
2E7765CD16C4D80A00BA2BB1 /* mainIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E7765CC16C4D80A00BA2BB1 /* mainIOS.mm */; };
2E7765CF16C4D81100BA2BB1 /* mainMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E7765CE16C4D81100BA2BB1 /* mainMac.mm */; };
33BE5AF9137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33BE5AF8137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp */; };
@@ -498,6 +501,9 @@
dstSubfolderSpec = 7;
files = (
515BE16F1D428BB100DD7C68 /* StoreBlobToBeDeleted.html in Copy Resources */,
+ 2E1DFDF11D42E1E400714A00 /* large-video-seek-to-beginning-and-play-after-ending.html in Copy Resources */,
+ 2E1B7B021D41B1B9007558B4 /* large-video-hides-controls-after-seek-to-end.html in Copy Resources */,
+ 2E1B7B001D41ABA7007558B4 /* large-video-seek-after-ending.html in Copy Resources */,
5C9E59411D3EB5AC00E3C62E /* ApplicationCache.db in Copy Resources */,
5C9E59421D3EB5AC00E3C62E /* ApplicationCache.db-shm in Copy Resources */,
5C9E59431D3EB5AC00E3C62E /* ApplicationCache.db-wal in Copy Resources */,
@@ -698,6 +704,9 @@
2DD7D3A9178205D00026E1E3 /* ResizeReversePaginatedWebView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResizeReversePaginatedWebView.cpp; sourceTree = "<group>"; };
2DD7D3AE178227AC0026E1E3 /* lots-of-text-vertical-lr.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "lots-of-text-vertical-lr.html"; sourceTree = "<group>"; };
2E14A5281D3FE8B80010F35B /* autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autoplaying-video-with-audio.html"; sourceTree = "<group>"; };
+ 2E1B7AFF1D41A95F007558B4 /* large-video-seek-after-ending.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-seek-after-ending.html"; sourceTree = "<group>"; };
+ 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>"; };
+ 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>"; };
2E7765CC16C4D80A00BA2BB1 /* mainIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = mainIOS.mm; sourceTree = "<group>"; };
2E7765CE16C4D81100BA2BB1 /* mainMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = mainMac.mm; sourceTree = "<group>"; };
333B9CE11277F23100FEFCE3 /* PreventEmptyUserAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PreventEmptyUserAgent.cpp; sourceTree = "<group>"; };
@@ -1335,6 +1344,8 @@
A16F66B81C40E9E100BD4D24 /* Resources */ = {
isa = PBXGroup;
children = (
+ 2E1DFDF01D42E14400714A00 /* large-video-seek-to-beginning-and-play-after-ending.html */,
+ 2E1B7B011D41B1B3007558B4 /* large-video-hides-controls-after-seek-to-end.html */,
5C9E593E1D3EB1DE00E3C62E /* ApplicationCache.db */,
5C9E593F1D3EB1DE00E3C62E /* ApplicationCache.db-shm */,
5C9E59401D3EB1DE00E3C62E /* ApplicationCache.db-wal */,
@@ -1369,6 +1380,7 @@
515BE16E1D4288FF00DD7C68 /* StoreBlobToBeDeleted.html */,
51714EB21CF8C761004723C4 /* WebProcessKillIDBCleanup-1.html */,
51714EB31CF8C761004723C4 /* WebProcessKillIDBCleanup-2.html */,
+ 2E1B7AFF1D41A95F007558B4 /* large-video-seek-after-ending.html */,
);
name = Resources;
sourceTree = "<group>";
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm (203689 => 203690)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm 2016-07-25 17:21:49 UTC (rev 203689)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm 2016-07-25 17:49:17 UTC (rev 203690)
@@ -54,23 +54,25 @@
@end
-@interface DidPlayMessageHandler : NSObject <WKScriptMessageHandler> {
+@interface MediaPlaybackMessageHandler : NSObject <WKScriptMessageHandler> {
RetainPtr<WKWebView> _webView;
}
@property (nonatomic) BOOL expectedToHaveControlsManager;
+@property (nonatomic, retain) NSString *finalMessageString;
-- (instancetype)initWithWKWebView:(WKWebView*)webView;
+- (instancetype)initWithWKWebView:(WKWebView*)webView finalMessageString:(NSString *)finalMessageString;
@end
-@implementation DidPlayMessageHandler
+@implementation MediaPlaybackMessageHandler
-- (instancetype)initWithWKWebView:(WKWebView*)webView
+- (instancetype)initWithWKWebView:(WKWebView*)webView finalMessageString:(NSString *)finalMessageString
{
if (!(self = [super init]))
return nil;
_webView = webView;
+ _finalMessageString = finalMessageString;
return self;
}
@@ -80,7 +82,7 @@
receivedScriptMessage = true;
NSString *bodyString = (NSString *)[message body];
- if ([bodyString isEqualToString:@"playing"] || [bodyString isEqualToString:@"paused"]) {
+ if ([bodyString isEqualToString:self.finalMessageString]) {
BOOL hasControlsManager = [_webView _hasActiveVideoForControlsManager];
if (self.expectedToHaveControlsManager)
EXPECT_TRUE(hasControlsManager);
@@ -132,7 +134,7 @@
RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
- RetainPtr<DidPlayMessageHandler> handler = adoptNS([[DidPlayMessageHandler alloc] initWithWKWebView:webView.get()]);
+ RetainPtr<MediaPlaybackMessageHandler> handler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"playing"]);
[[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"];
RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
@@ -153,7 +155,7 @@
RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
- RetainPtr<DidPlayMessageHandler> handler = adoptNS([[DidPlayMessageHandler alloc] initWithWKWebView:webView.get()]);
+ RetainPtr<MediaPlaybackMessageHandler> handler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"playing"]);
[[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"];
RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
@@ -174,7 +176,7 @@
RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
- RetainPtr<DidPlayMessageHandler> playbackHandler = adoptNS([[DidPlayMessageHandler alloc] initWithWKWebView:webView.get()]);
+ RetainPtr<MediaPlaybackMessageHandler> playbackHandler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"paused"]);
[[configuration userContentController] addScriptMessageHandler:playbackHandler.get() name:@"playingHandler"];
RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
@@ -194,12 +196,77 @@
TestWebKitAPI::Util::run(&receivedScriptMessage);
}
+TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoSeeksAfterEnding)
+{
+ RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
+ RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
+ RetainPtr<MediaPlaybackMessageHandler> handler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"ended"]);
+ [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"];
+
+ RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
+ [[window contentView] addSubview:webView.get()];
+
+ // Since the video has ended, the expectation is NO even if the page programmatically seeks to the beginning.
+ [handler setExpectedToHaveControlsManager:NO];
+ NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"large-video-seek-after-ending" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+ [webView loadRequest:request];
+
+ TestWebKitAPI::Util::run(&testedControlsManagerAfterPlaying);
+ TestWebKitAPI::Util::run(&receivedScriptMessage);
+}
+
+TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoSeeksAndPlaysAfterEnding)
+{
+ RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
+ RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
+ RetainPtr<MediaPlaybackMessageHandler> handler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"replaying"]);
+ [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"];
+
+ RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
+ [[window contentView] addSubview:webView.get()];
+
+ // Since the video is still playing, the expectation is YES even if the video has ended once.
+ [handler setExpectedToHaveControlsManager:YES];
+ NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"large-video-seek-to-beginning-and-play-after-ending" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+ [webView loadRequest:request];
+
+ TestWebKitAPI::Util::run(&testedControlsManagerAfterPlaying);
+ TestWebKitAPI::Util::run(&receivedScriptMessage);
+}
+
+TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoHidesControlsAfterSeekingToEnd)
+{
+ RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
+ RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
+ RetainPtr<MediaPlaybackMessageHandler> handler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"ended"]);
+ [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"];
+
+ RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
+ [[window contentView] addSubview:webView.get()];
+
+ RetainPtr<OnLoadMessageHandler> _onloadHandler_ = adoptNS([[OnLoadMessageHandler alloc] initWithWKWebView:webView.get() handler:^() {
+ [webView mouseDownAtPoint:NSMakePoint(50, 50)];
+ }]);
+ [[configuration userContentController] addScriptMessageHandler:onloadHandler.get() name:@"onloadHandler"];
+
+ // Since the video has ended, the expectation is NO.
+ [handler setExpectedToHaveControlsManager:NO];
+ NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"large-video-hides-controls-after-seek-to-end" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+ [webView loadRequest:request];
+
+ TestWebKitAPI::Util::run(&testedControlsManagerAfterPlaying);
+ TestWebKitAPI::Util::run(&receivedScriptMessage);
+}
+
TEST(VideoControlsManager, VideoControlsManagerSingleLargeVideoWithoutAudio)
{
RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
- RetainPtr<DidPlayMessageHandler> handler = adoptNS([[DidPlayMessageHandler alloc] initWithWKWebView:webView.get()]);
+ RetainPtr<MediaPlaybackMessageHandler> handler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"playing"]);
[[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"];
RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
@@ -220,7 +287,7 @@
RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
- RetainPtr<DidPlayMessageHandler> handler = adoptNS([[DidPlayMessageHandler alloc] initWithWKWebView:webView.get()]);
+ RetainPtr<MediaPlaybackMessageHandler> handler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"playing"]);
[[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"];
RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-hides-controls-after-seek-to-end.html (0 => 203690)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-hides-controls-after-seek-to-end.html (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-hides-controls-after-seek-to-end.html 2016-07-25 17:49:17 UTC (rev 203690)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script>
+
+ function handleEnded() {
+ // The media controls should be updated on the next runloop.
+ setTimeout(function() {
+ try {
+ window.webkit.messageHandlers.playingHandler.postMessage("ended");
+ } catch(e) { }
+ }, 0);
+ }
+
+ function seekToEnd() {
+ var video = document.getElementsByTagName("video")[0];
+ video.currentTime = video.duration;
+ }
+
+ function beginTest() {
+ try {
+ window.webkit.messageHandlers.onloadHandler.postMessage("loaded");
+ } catch(e) { }
+ }
+
+ </script>
+</head>
+<body _onmousedown_=seekToEnd() _onload_=beginTest()>
+ <video autoplay _onended_=handleEnded() src="" webkit-playsinline style="width: 800px; height: 600px;"></video>
+</body>
+</html>
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-seek-after-ending.html (0 => 203690)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-seek-after-ending.html (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-seek-after-ending.html 2016-07-25 17:49:17 UTC (rev 203690)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script>
+ function seekToBeginningAndFinishTest() {
+ document.querySelector("#test-video").currentTime = 0;
+ // The media controls should be updated on the next runloop.
+ setTimeout(function() {
+ window.webkit.messageHandlers.playingHandler.postMessage("ended");
+ }, 0);
+ }
+
+ function seekToEnd() {
+ document.querySelector("#test-video").currentTime = document.querySelector("#test-video").duration - 0.1;
+ }
+ </script>
+</head>
+<body>
+ <video id="test-video" autoplay _onended_=seekToBeginningAndFinishTest() _onplaying_=seekToEnd() style="width: 800px; height: 600px;" src=""
+</body>
+</html>
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-seek-to-beginning-and-play-after-ending.html (0 => 203690)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-seek-to-beginning-and-play-after-ending.html (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-seek-to-beginning-and-play-after-ending.html 2016-07-25 17:49:17 UTC (rev 203690)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script>
+ function seekToBeginningAndFinishTest() {
+ var video = document.querySelector("#test-video");
+ video.currentTime = 0;
+ video.play();
+ // The media controls should be updated on the next runloop.
+ setTimeout(function() {
+ window.webkit.messageHandlers.playingHandler.postMessage("replaying");
+ }, 0);
+ }
+
+ function seekToEnd() {
+ document.querySelector("#test-video").currentTime = document.querySelector("#test-video").duration - 0.1;
+ }
+ </script>
+</head>
+<body>
+ <video id="test-video" autoplay _onended_=seekToBeginningAndFinishTest() _onplaying_=seekToEnd() style="width: 800px; height: 600px;" src=""
+</body>
+</html>