<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[203464] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/203464">203464</a></dd>
<dt>Author</dt> <dd>wenson_hsieh@apple.com</dd>
<dt>Date</dt> <dd>2016-07-20 12:25:16 -0700 (Wed, 20 Jul 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Media controls don't appear when pausing a small autoplaying video
https://bugs.webkit.org/show_bug.cgi?id=159972
<rdar://problem/27180657>
Reviewed by Beth Dakin.
Source/WebCore:
When pausing an autoplaying video, remove behavior restrictions for the
initial user gesture and show media controls.
New WebKit API test. See VideoControlsManagerSingleSmallAutoplayingVideo.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::pause):
Tools:
Adds a new test that verifies media controls show up when pausing a small autoplayed video. Also adds mechanisms
for simulating basic user interaction in VideoControlsManager.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm:
(-[WKWebView mouseDownAtPoint:]):
(-[DidPlayMessageHandler userContentController:didReceiveScriptMessage:]):
(-[OnLoadMessageHandler initWithWKWebView:handler:]):
(-[OnLoadMessageHandler userContentController:didReceiveScriptMessage:]):
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKit2Cocoa/autoplaying-video-with-audio.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementcpp">trunk/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2CocoaVideoControlsManagermm">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2Cocoaautoplayingvideowithaudiohtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/autoplaying-video-with-audio.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (203463 => 203464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-07-20 19:21:51 UTC (rev 203463)
+++ trunk/Source/WebCore/ChangeLog        2016-07-20 19:25:16 UTC (rev 203464)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-07-20 Wenson Hsieh <wenson_hsieh@apple.com>
+
+ Media controls don't appear when pausing a small autoplaying video
+ https://bugs.webkit.org/show_bug.cgi?id=159972
+ <rdar://problem/27180657>
+
+ Reviewed by Beth Dakin.
+
+ When pausing an autoplaying video, remove behavior restrictions for the
+ initial user gesture and show media controls.
+
+ New WebKit API test. See VideoControlsManagerSingleSmallAutoplayingVideo.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::pause):
+
</ins><span class="cx"> 2016-07-20 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> Fix null handling of HTMLMediaElement.mediaGroup
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (203463 => 203464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp        2016-07-20 19:21:51 UTC (rev 203463)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp        2016-07-20 19:25:16 UTC (rev 203464)
</span><span class="lines">@@ -3155,6 +3155,9 @@
</span><span class="cx"> if (!m_mediaSession->playbackPermitted(*this))
</span><span class="cx"> return;
</span><span class="cx">
</span><ins>+ if (ScriptController::processingUserGestureForMedia())
+ removeBehaviorsRestrictionsAfterFirstUserGesture();
+
</ins><span class="cx"> pauseInternal();
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (203463 => 203464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-07-20 19:21:51 UTC (rev 203463)
+++ trunk/Tools/ChangeLog        2016-07-20 19:25:16 UTC (rev 203464)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2016-07-20 Wenson Hsieh <wenson_hsieh@apple.com>
+
+ Media controls don't appear when pausing a small autoplaying video
+ https://bugs.webkit.org/show_bug.cgi?id=159972
+ <rdar://problem/27180657>
+
+ Reviewed by Beth Dakin.
+
+ Adds a new test that verifies media controls show up when pausing a small autoplayed video. Also adds mechanisms
+ for simulating basic user interaction in VideoControlsManager.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm:
+ (-[WKWebView mouseDownAtPoint:]):
+ (-[DidPlayMessageHandler userContentController:didReceiveScriptMessage:]):
+ (-[OnLoadMessageHandler initWithWKWebView:handler:]):
+ (-[OnLoadMessageHandler userContentController:didReceiveScriptMessage:]):
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/WebKit2Cocoa/autoplaying-video-with-audio.html: Added.
+
</ins><span class="cx"> 2016-07-20 Per Arne Vollan <pvollan@apple.com>
</span><span class="cx">
</span><span class="cx"> [Win] MathML fonts are not found.
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (203463 => 203464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-07-20 19:21:51 UTC (rev 203463)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-07-20 19:25:16 UTC (rev 203464)
</span><span class="lines">@@ -51,6 +51,7 @@
</span><span class="cx">                 2D51A0C71C8BF00C00765C45 /* DOMHTMLVideoElementWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D51A0C51C8BF00400765C45 /* DOMHTMLVideoElementWrapper.mm */; };
</span><span class="cx">                 2DC4CF771D2D9DD800ECCC94 /* DataDetection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DC4CF761D2D9DD800ECCC94 /* DataDetection.mm */; };
</span><span class="cx">                 2DD7D3AF178227B30026E1E3 /* lots-of-text-vertical-lr.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2DD7D3AE178227AC0026E1E3 /* lots-of-text-vertical-lr.html */; };
</span><ins>+                2E14A5291D3FE96B0010F35B /* autoplaying-video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E14A5281D3FE8B80010F35B /* autoplaying-video-with-audio.html */; };
</ins><span class="cx">                 2E7765CD16C4D80A00BA2BB1 /* mainIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E7765CC16C4D80A00BA2BB1 /* mainIOS.mm */; };
</span><span class="cx">                 2E7765CF16C4D81100BA2BB1 /* mainMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E7765CE16C4D81100BA2BB1 /* mainMac.mm */; };
</span><span class="cx">                 33BE5AF9137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33BE5AF8137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp */; };
</span><span class="lines">@@ -494,6 +495,7 @@
</span><span class="cx">                                 5C9E59411D3EB5AC00E3C62E /* ApplicationCache.db in Copy Resources */,
</span><span class="cx">                                 5C9E59421D3EB5AC00E3C62E /* ApplicationCache.db-shm in Copy Resources */,
</span><span class="cx">                                 5C9E59431D3EB5AC00E3C62E /* ApplicationCache.db-wal in Copy Resources */,
</span><ins>+                                2E14A5291D3FE96B0010F35B /* autoplaying-video-with-audio.html in Copy Resources */,
</ins><span class="cx">                                 7CCB99231D3B4A46003922F6 /* open-multiple-external-url.html in Copy Resources */,
</span><span class="cx">                                 932AE53D1D371047005DFFAF /* focus-inputs.html in Copy Resources */,
</span><span class="cx">                                 46C519E61D3563FD00DAA51A /* LocalStorageNullEntries.html in Copy Resources */,
</span><span class="lines">@@ -687,6 +689,7 @@
</span><span class="cx">                 2DD355351BD08378005DF4A7 /* AutoLayoutIntegration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AutoLayoutIntegration.mm; sourceTree = "<group>"; };
</span><span class="cx">                 2DD7D3A9178205D00026E1E3 /* ResizeReversePaginatedWebView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResizeReversePaginatedWebView.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 2DD7D3AE178227AC0026E1E3 /* lots-of-text-vertical-lr.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "lots-of-text-vertical-lr.html"; sourceTree = "<group>"; };
</span><ins>+                2E14A5281D3FE8B80010F35B /* autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autoplaying-video-with-audio.html"; sourceTree = "<group>"; };
</ins><span class="cx">                 2E7765CC16C4D80A00BA2BB1 /* mainIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = mainIOS.mm; sourceTree = "<group>"; };
</span><span class="cx">                 2E7765CE16C4D81100BA2BB1 /* mainMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = mainMac.mm; sourceTree = "<group>"; };
</span><span class="cx">                 333B9CE11277F23100FEFCE3 /* PreventEmptyUserAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PreventEmptyUserAgent.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -1318,6 +1321,7 @@
</span><span class="cx">                                 5C9E593E1D3EB1DE00E3C62E /* ApplicationCache.db */,
</span><span class="cx">                                 5C9E593F1D3EB1DE00E3C62E /* ApplicationCache.db-shm */,
</span><span class="cx">                                 5C9E59401D3EB1DE00E3C62E /* ApplicationCache.db-wal */,
</span><ins>+                                2E14A5281D3FE8B80010F35B /* autoplaying-video-with-audio.html */,
</ins><span class="cx">                                 93CFA8661CEB9DE1000565A8 /* autofocused-text-input.html */,
</span><span class="cx">                                 A16F66B91C40EA2000BD4D24 /* ContentFiltering.html */,
</span><span class="cx">                                 5714ECB81CA8B58800051AC8 /* DownloadRequestOriginalURL.html */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2CocoaVideoControlsManagermm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm (203463 => 203464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm        2016-07-20 19:21:51 UTC (rev 203463)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm        2016-07-20 19:25:16 UTC (rev 203464)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx">
</span><span class="cx"> #import "PlatformUtilities.h"
</span><ins>+#import <Carbon/Carbon.h>
</ins><span class="cx"> #import <WebKit/WKWebViewConfigurationPrivate.h>
</span><span class="cx"> #import <WebKit/WKWebViewPrivate.h>
</span><span class="cx"> #import <wtf/RetainPtr.h>
</span><span class="lines">@@ -35,6 +36,20 @@
</span><span class="cx"> static bool testedControlsManagerAfterPlaying;
</span><span class="cx"> static bool receivedScriptMessage;
</span><span class="cx">
</span><ins>+@interface WKWebView (UserInteraction)
+
+- (void)mouseDownAtPoint:(NSPoint)point;
+
+@end
+
+@implementation WKWebView (UserInteraction)
+
+- (void)mouseDownAtPoint:(NSPoint)point {
+ [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]];
+}
+
+@end
+
</ins><span class="cx"> @interface DidPlayMessageHandler : NSObject <WKScriptMessageHandler> {
</span><span class="cx"> RetainPtr<WKWebView> _webView;
</span><span class="cx"> }
</span><span class="lines">@@ -61,7 +76,7 @@
</span><span class="cx"> receivedScriptMessage = true;
</span><span class="cx">
</span><span class="cx"> NSString *bodyString = (NSString *)[message body];
</span><del>- if ([bodyString isEqualToString:@"playing"]) {
</del><ins>+ if ([bodyString isEqualToString:@"playing"] || [bodyString isEqualToString:@"paused"]) {
</ins><span class="cx"> BOOL hasControlsManager = [_webView _hasActiveVideoForControlsManager];
</span><span class="cx"> if (self.expectedToHaveControlsManager)
</span><span class="cx"> EXPECT_TRUE(hasControlsManager);
</span><span class="lines">@@ -72,6 +87,40 @@
</span><span class="cx"> }
</span><span class="cx"> @end
</span><span class="cx">
</span><ins>+@interface OnLoadMessageHandler : NSObject <WKScriptMessageHandler> {
+ RetainPtr<WKWebView> _webView;
+}
+
+@property (nonatomic, strong) dispatch_block_t onloadHandler;
+
+- (instancetype)initWithWKWebView:(WKWebView*)webView handler:(dispatch_block_t)handler;
+@end
+
+@implementation OnLoadMessageHandler
+
+- (instancetype)initWithWKWebView:(WKWebView*)webView handler:(dispatch_block_t)handler
+{
+ if (!(self = [super init]))
+ return nil;
+
+ _webView = webView;
+ _onloadHandler = handler;
+
+ return self;
+}
+
+- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
+{
+ if (![(NSString *)[message body] isEqualToString:@"loaded"])
+ return;
+
+ if (_onloadHandler)
+ _onloadHandler();
+
+ _onloadHandler = nil;
+}
+@end
+
</ins><span class="cx"> namespace TestWebKitAPI {
</span><span class="cx">
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerSingleLargeVideo)
</span><span class="lines">@@ -116,6 +165,31 @@
</span><span class="cx"> TestWebKitAPI::Util::run(&receivedScriptMessage);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+TEST(VideoControlsManager, VideoControlsManagerSingleSmallAutoplayingVideo)
+{
+ 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()]);
+ [[configuration userContentController] addScriptMessageHandler:playbackHandler.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"];
+
+ // A small video should have a controls manager after the first user gesture, which includes pausing the video. The expectation is YES.
+ [playbackHandler setExpectedToHaveControlsManager:YES];
+ NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"autoplaying-video-with-audio" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+ [webView loadRequest:request];
+
+ TestWebKitAPI::Util::run(&testedControlsManagerAfterPlaying);
+ TestWebKitAPI::Util::run(&receivedScriptMessage);
+}
+
</ins><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerSingleLargeVideoWithoutAudio)
</span><span class="cx"> {
</span><span class="cx"> RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2Cocoaautoplayingvideowithaudiohtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/autoplaying-video-with-audio.html (0 => 203464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/autoplaying-video-with-audio.html         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/autoplaying-video-with-audio.html        2016-07-20 19:25:16 UTC (rev 203464)
</span><span class="lines">@@ -0,0 +1,40 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+ <script>
+ var timeout;
+
+ function beginTest() {
+ timeout = window.setTimeout(stillPlaying, 5000);
+ window.addEventListener("mousedown", pauseVideo);
+ try {
+ window.webkit.messageHandlers.onloadHandler.postMessage('loaded');
+ } catch(e) { }
+ }
+
+ function pauseVideo() {
+ document.getElementsByTagName('video')[0].pause();
+ window.clearTimeout(timeout);
+ }
+
+ function handlePaused() {
+ // Wait until the next runloop to allow media controls to update.
+ setTimeout(function() {
+ try {
+ window.webkit.messageHandlers.playingHandler.postMessage('paused');
+ } catch(e) { }
+ }, 0);
+ }
+
+ function stillPlaying() {
+ try {
+ window.webkit.messageHandlers.playingHandler.postMessage('playing');
+ } catch(e) { }
+ }
+
+ </script>
+</head>
+<body onload="beginTest()">
+ <video controls autoplay src="video-with-audio.mp4" webkit-playsinline onpause="handlePaused()"></video>
+</body>
+</html>
</ins></span></pre>
</div>
</div>
</body>
</html>