<!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>[203871] branches/safari-602-branch</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/203871">203871</a></dd>
<dt>Author</dt> <dd>bshafiei@apple.com</dd>
<dt>Date</dt> <dd>2016-07-29 00:11:41 -0700 (Fri, 29 Jul 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/203690">r203690</a>. rdar://problem/26668526</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari602branchSourceWebCoreChangeLog">branches/safari-602-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari602branchSourceWebCorehtmlHTMLMediaElementcpp">branches/safari-602-branch/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
<li><a href="#branchessafari602branchSourceWebCorehtmlMediaElementSessioncpp">branches/safari-602-branch/Source/WebCore/html/MediaElementSession.cpp</a></li>
<li><a href="#branchessafari602branchSourceWebCorehtmlMediaElementSessionh">branches/safari-602-branch/Source/WebCore/html/MediaElementSession.h</a></li>
<li><a href="#branchessafari602branchToolsChangeLog">branches/safari-602-branch/Tools/ChangeLog</a></li>
<li><a href="#branchessafari602branchToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
<li><a href="#branchessafari602branchToolsTestWebKitAPITestsWebKit2CocoaVideoControlsManagermm">branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari602branchToolsTestWebKitAPITestsWebKit2Cocoalargevideohidescontrolsafterseektoendhtml">branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-hides-controls-after-seek-to-end.html</a></li>
<li><a href="#branchessafari602branchToolsTestWebKitAPITestsWebKit2Cocoalargevideoseekafterendinghtml">branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-seek-after-ending.html</a></li>
<li><a href="#branchessafari602branchToolsTestWebKitAPITestsWebKit2Cocoalargevideoseektobeginningandplayafterendinghtml">branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-seek-to-beginning-and-play-after-ending.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari602branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/ChangeLog (203870 => 203871)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebCore/ChangeLog        2016-07-29 07:11:36 UTC (rev 203870)
+++ branches/safari-602-branch/Source/WebCore/ChangeLog        2016-07-29 07:11:41 UTC (rev 203871)
</span><span class="lines">@@ -1,5 +1,33 @@
</span><span class="cx"> 2016-07-28 Babak Shafiei <bshafiei@apple.com>
</span><span class="cx">
</span><ins>+ Merge r203690. rdar://problem/26668526
+
+ 2016-07-25 Wenson Hsieh <wenson_hsieh@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-28 Babak Shafiei <bshafiei@apple.com>
+
</ins><span class="cx"> Merge r203683. rdar://problem/27525634
</span><span class="cx">
</span><span class="cx"> 2016-07-25 Carlos Garcia Campos <cgarcia@igalia.com>
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/html/HTMLMediaElement.cpp (203870 => 203871)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebCore/html/HTMLMediaElement.cpp        2016-07-29 07:11:36 UTC (rev 203870)
+++ branches/safari-602-branch/Source/WebCore/html/HTMLMediaElement.cpp        2016-07-29 07:11:41 UTC (rev 203871)
</span><span class="lines">@@ -4411,6 +4411,7 @@
</span><span class="cx"> if (!m_sentEndEvent) {
</span><span class="cx"> m_sentEndEvent = true;
</span><span class="cx"> scheduleEvent(eventNames().endedEvent);
</span><ins>+ m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureToControlControlsManager | MediaElementSession::RequirePlaybackToControlControlsManager);
</ins><span class="cx"> }
</span><span class="cx"> // If the media element has a current media controller, then report the controller state
</span><span class="cx"> // for the media element's current media controller.
</span><span class="lines">@@ -4431,6 +4432,7 @@
</span><span class="cx"> if (!m_sentEndEvent && m_player && m_player->ended()) {
</span><span class="cx"> m_sentEndEvent = true;
</span><span class="cx"> scheduleEvent(eventNames().endedEvent);
</span><ins>+ m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureToControlControlsManager | MediaElementSession::RequirePlaybackToControlControlsManager);
</ins><span class="cx"> m_paused = true;
</span><span class="cx"> setPlaying(false);
</span><span class="cx"> }
</span><span class="lines">@@ -4936,6 +4938,9 @@
</span><span class="cx">
</span><span class="cx"> void HTMLMediaElement::setPlaying(bool playing)
</span><span class="cx"> {
</span><ins>+ if (playing && m_mediaSession)
+ m_mediaSession->removeBehaviorRestriction(MediaElementSession::RequirePlaybackToControlControlsManager);
+
</ins><span class="cx"> if (m_playing == playing)
</span><span class="cx"> return;
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCorehtmlMediaElementSessioncpp"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/html/MediaElementSession.cpp (203870 => 203871)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebCore/html/MediaElementSession.cpp        2016-07-29 07:11:36 UTC (rev 203870)
+++ branches/safari-602-branch/Source/WebCore/html/MediaElementSession.cpp        2016-07-29 07:11:41 UTC (rev 203871)
</span><span class="lines">@@ -243,6 +243,11 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ if (hasBehaviorRestriction(RequirePlaybackToControlControlsManager) && !m_element.isPlaying()) {
+ LOG(Media, "MediaElementSession::canControlControlsManager - returning FALSE: Needs to be playing");
+ return false;
+ }
+
</ins><span class="cx"> if (m_element.muted()) {
</span><span class="cx"> LOG(Media, "MediaElementSession::canControlControlsManager - returning FALSE: Muted");
</span><span class="cx"> return false;
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCorehtmlMediaElementSessionh"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/html/MediaElementSession.h (203870 => 203871)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebCore/html/MediaElementSession.h        2016-07-29 07:11:36 UTC (rev 203870)
+++ branches/safari-602-branch/Source/WebCore/html/MediaElementSession.h        2016-07-29 07:11:41 UTC (rev 203871)
</span><span class="lines">@@ -95,6 +95,7 @@
</span><span class="cx"> InvisibleAutoplayNotPermitted = 1 << 11,
</span><span class="cx"> OverrideUserGestureRequirementForMainContent = 1 << 12,
</span><span class="cx"> RequireUserGestureToControlControlsManager = 1 << 13,
</span><ins>+ RequirePlaybackToControlControlsManager = 1 << 14,
</ins><span class="cx"> AllRestrictions = ~NoRestrictions,
</span><span class="cx"> };
</span><span class="cx"> typedef unsigned BehaviorRestrictions;
</span></span></pre></div>
<a id="branchessafari602branchToolsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Tools/ChangeLog (203870 => 203871)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/ChangeLog        2016-07-29 07:11:36 UTC (rev 203870)
+++ branches/safari-602-branch/Tools/ChangeLog        2016-07-29 07:11:41 UTC (rev 203871)
</span><span class="lines">@@ -1,5 +1,30 @@
</span><span class="cx"> 2016-07-28 Babak Shafiei <bshafiei@apple.com>
</span><span class="cx">
</span><ins>+ Merge r203690. rdar://problem/26668526
+
+ 2016-07-25 Wenson Hsieh <wenson_hsieh@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-28 Babak Shafiei <bshafiei@apple.com>
+
</ins><span class="cx"> Merge r203629. rdar://problem/27438936
</span><span class="cx">
</span><span class="cx"> 2016-07-22 Wenson Hsieh <wenson_hsieh@apple.com>
</span></span></pre></div>
<a id="branchessafari602branchToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (203870 => 203871)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-07-29 07:11:36 UTC (rev 203870)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-07-29 07:11:41 UTC (rev 203871)
</span><span class="lines">@@ -53,6 +53,9 @@
</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><span class="cx">                 2E14A5291D3FE96B0010F35B /* autoplaying-video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E14A5281D3FE8B80010F35B /* autoplaying-video-with-audio.html */; };
</span><ins>+                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 */; };
</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">@@ -498,6 +501,9 @@
</span><span class="cx">                         dstSubfolderSpec = 7;
</span><span class="cx">                         files = (
</span><span class="cx">                                 515BE16F1D428BB100DD7C68 /* StoreBlobToBeDeleted.html in Copy Resources */,
</span><ins>+                                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 */,
</ins><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><span class="lines">@@ -698,6 +704,9 @@
</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><span class="cx">                 2E14A5281D3FE8B80010F35B /* autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autoplaying-video-with-audio.html"; sourceTree = "<group>"; };
</span><ins>+                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>"; };
</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">@@ -1335,6 +1344,8 @@
</span><span class="cx">                 A16F66B81C40E9E100BD4D24 /* Resources */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                2E1DFDF01D42E14400714A00 /* large-video-seek-to-beginning-and-play-after-ending.html */,
+                                2E1B7B011D41B1B3007558B4 /* large-video-hides-controls-after-seek-to-end.html */,
</ins><span class="cx">                                 5C9E593E1D3EB1DE00E3C62E /* ApplicationCache.db */,
</span><span class="cx">                                 5C9E593F1D3EB1DE00E3C62E /* ApplicationCache.db-shm */,
</span><span class="cx">                                 5C9E59401D3EB1DE00E3C62E /* ApplicationCache.db-wal */,
</span><span class="lines">@@ -1369,6 +1380,7 @@
</span><span class="cx">                                 515BE16E1D4288FF00DD7C68 /* StoreBlobToBeDeleted.html */,
</span><span class="cx">                                 51714EB21CF8C761004723C4 /* WebProcessKillIDBCleanup-1.html */,
</span><span class="cx">                                 51714EB31CF8C761004723C4 /* WebProcessKillIDBCleanup-2.html */,
</span><ins>+                                2E1B7AFF1D41A95F007558B4 /* large-video-seek-after-ending.html */,
</ins><span class="cx">                         );
</span><span class="cx">                         name = Resources;
</span><span class="cx">                         sourceTree = "<group>";
</span></span></pre></div>
<a id="branchessafari602branchToolsTestWebKitAPITestsWebKit2CocoaVideoControlsManagermm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm (203870 => 203871)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm        2016-07-29 07:11:36 UTC (rev 203870)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm        2016-07-29 07:11:41 UTC (rev 203871)
</span><span class="lines">@@ -54,23 +54,25 @@
</span><span class="cx">
</span><span class="cx"> @end
</span><span class="cx">
</span><del>-@interface DidPlayMessageHandler : NSObject <WKScriptMessageHandler> {
</del><ins>+@interface MediaPlaybackMessageHandler : NSObject <WKScriptMessageHandler> {
</ins><span class="cx"> RetainPtr<WKWebView> _webView;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> @property (nonatomic) BOOL expectedToHaveControlsManager;
</span><ins>+@property (nonatomic, retain) NSString *finalMessageString;
</ins><span class="cx">
</span><del>-- (instancetype)initWithWKWebView:(WKWebView*)webView;
</del><ins>+- (instancetype)initWithWKWebView:(WKWebView*)webView finalMessageString:(NSString *)finalMessageString;
</ins><span class="cx"> @end
</span><span class="cx">
</span><del>-@implementation DidPlayMessageHandler
</del><ins>+@implementation MediaPlaybackMessageHandler
</ins><span class="cx">
</span><del>-- (instancetype)initWithWKWebView:(WKWebView*)webView
</del><ins>+- (instancetype)initWithWKWebView:(WKWebView*)webView finalMessageString:(NSString *)finalMessageString
</ins><span class="cx"> {
</span><span class="cx"> if (!(self = [super init]))
</span><span class="cx"> return nil;
</span><span class="cx">
</span><span class="cx"> _webView = webView;
</span><ins>+ _finalMessageString = finalMessageString;
</ins><span class="cx">
</span><span class="cx"> return self;
</span><span class="cx"> }
</span><span class="lines">@@ -80,7 +82,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"] || [bodyString isEqualToString:@"paused"]) {
</del><ins>+ if ([bodyString isEqualToString:self.finalMessageString]) {
</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">@@ -132,7 +134,7 @@
</span><span class="cx"> RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
</span><span class="cx"> configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
</span><span class="cx"> RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
</span><del>- RetainPtr<DidPlayMessageHandler> handler = adoptNS([[DidPlayMessageHandler alloc] initWithWKWebView:webView.get()]);
</del><ins>+ RetainPtr<MediaPlaybackMessageHandler> handler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"playing"]);
</ins><span class="cx"> [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"];
</span><span class="cx">
</span><span class="cx"> RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
</span><span class="lines">@@ -153,7 +155,7 @@
</span><span class="cx"> RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
</span><span class="cx"> configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
</span><span class="cx"> RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
</span><del>- RetainPtr<DidPlayMessageHandler> handler = adoptNS([[DidPlayMessageHandler alloc] initWithWKWebView:webView.get()]);
</del><ins>+ RetainPtr<MediaPlaybackMessageHandler> handler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"playing"]);
</ins><span class="cx"> [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"];
</span><span class="cx">
</span><span class="cx"> RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
</span><span class="lines">@@ -174,7 +176,7 @@
</span><span class="cx"> RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
</span><span class="cx"> configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
</span><span class="cx"> RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
</span><del>- RetainPtr<DidPlayMessageHandler> playbackHandler = adoptNS([[DidPlayMessageHandler alloc] initWithWKWebView:webView.get()]);
</del><ins>+ RetainPtr<MediaPlaybackMessageHandler> playbackHandler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"paused"]);
</ins><span class="cx"> [[configuration userContentController] addScriptMessageHandler:playbackHandler.get() name:@"playingHandler"];
</span><span class="cx">
</span><span class="cx"> RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
</span><span class="lines">@@ -194,12 +196,77 @@
</span><span class="cx"> TestWebKitAPI::Util::run(&receivedScriptMessage);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+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);
+}
+
</ins><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerSingleLargeVideoWithoutAudio)
</span><span class="cx"> {
</span><span class="cx"> RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
</span><span class="cx"> configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
</span><span class="cx"> RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
</span><del>- RetainPtr<DidPlayMessageHandler> handler = adoptNS([[DidPlayMessageHandler alloc] initWithWKWebView:webView.get()]);
</del><ins>+ RetainPtr<MediaPlaybackMessageHandler> handler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"playing"]);
</ins><span class="cx"> [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"];
</span><span class="cx">
</span><span class="cx"> RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
</span><span class="lines">@@ -220,7 +287,7 @@
</span><span class="cx"> RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
</span><span class="cx"> configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
</span><span class="cx"> RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
</span><del>- RetainPtr<DidPlayMessageHandler> handler = adoptNS([[DidPlayMessageHandler alloc] initWithWKWebView:webView.get()]);
</del><ins>+ RetainPtr<MediaPlaybackMessageHandler> handler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"playing"]);
</ins><span class="cx"> [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"];
</span><span class="cx">
</span><span class="cx"> RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
</span></span></pre></div>
<a id="branchessafari602branchToolsTestWebKitAPITestsWebKit2Cocoalargevideohidescontrolsafterseektoendhtml"></a>
<div class="addfile"><h4>Added: branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-hides-controls-after-seek-to-end.html (0 => 203871)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-hides-controls-after-seek-to-end.html         (rev 0)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-hides-controls-after-seek-to-end.html        2016-07-29 07:11:41 UTC (rev 203871)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+<!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="large-video-with-audio.mp4" webkit-playsinline style="width: 800px; height: 600px;"></video>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari602branchToolsTestWebKitAPITestsWebKit2Cocoalargevideoseekafterendinghtml"></a>
<div class="addfile"><h4>Added: branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-seek-after-ending.html (0 => 203871)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-seek-after-ending.html         (rev 0)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-seek-after-ending.html        2016-07-29 07:11:41 UTC (rev 203871)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+<!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="large-video-with-audio.mp4"></video>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari602branchToolsTestWebKitAPITestsWebKit2Cocoalargevideoseektobeginningandplayafterendinghtml"></a>
<div class="addfile"><h4>Added: branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-seek-to-beginning-and-play-after-ending.html (0 => 203871)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-seek-to-beginning-and-play-after-ending.html         (rev 0)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-seek-to-beginning-and-play-after-ending.html        2016-07-29 07:11:41 UTC (rev 203871)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+<!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="large-video-with-audio.mp4"></video>
+</body>
+</html>
</ins></span></pre>
</div>
</div>
</body>
</html>