<!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>[205705] 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/205705">205705</a></dd>
<dt>Author</dt> <dd>bshafiei@apple.com</dd>
<dt>Date</dt> <dd>2016-09-09 01:41:46 -0700 (Fri, 09 Sep 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/205412">r205412</a>. rdar://problem/28014919</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="#branchessafari602branchSourceWebCorehtmlHTMLMediaElementh">branches/safari-602-branch/Source/WebCore/html/HTMLMediaElement.h</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="#branchessafari602branchSourceWebCoreplatformaudioPlatformMediaSessionh">branches/safari-602-branch/Source/WebCore/platform/audio/PlatformMediaSession.h</a></li>
<li><a href="#branchessafari602branchSourceWebCoreplatformaudioPlatformMediaSessionManagercpp">branches/safari-602-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp</a></li>
<li><a href="#branchessafari602branchSourceWebCoreplatformaudioPlatformMediaSessionManagerh">branches/safari-602-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h</a></li>
<li><a href="#branchessafari602branchSourceWebCoreplatformcocoaWebPlaybackSessionModelMediaElementmm">branches/safari-602-branch/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.mm</a></li>
<li><a href="#branchessafari602branchSourceWebKit2ChangeLog">branches/safari-602-branch/Source/WebKit2/ChangeLog</a></li>
<li><a href="#branchessafari602branchSourceWebKit2UIProcessAPICocoaWKWebViewmm">branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#branchessafari602branchSourceWebKit2UIProcessAPICocoaWKWebViewPrivateh">branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h</a></li>
<li><a href="#branchessafari602branchSourceWebKit2UIProcessCocoaWebPlaybackSessionManagerProxyh">branches/safari-602-branch/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h</a></li>
<li><a href="#branchessafari602branchSourceWebKit2UIProcessCocoaWebPlaybackSessionManagerProxymessagesin">branches/safari-602-branch/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.messages.in</a></li>
<li><a href="#branchessafari602branchSourceWebKit2UIProcessCocoaWebPlaybackSessionManagerProxymm">branches/safari-602-branch/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm</a></li>
<li><a href="#branchessafari602branchSourceWebKit2UIProcessPageClienth">branches/safari-602-branch/Source/WebKit2/UIProcess/PageClient.h</a></li>
<li><a href="#branchessafari602branchSourceWebKit2UIProcessWebPageProxycpp">branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#branchessafari602branchSourceWebKit2UIProcessWebPageProxyh">branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#branchessafari602branchSourceWebKit2UIProcessmacPageClientImplh">branches/safari-602-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.h</a></li>
<li><a href="#branchessafari602branchSourceWebKit2UIProcessmacPageClientImplmm">branches/safari-602-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm</a></li>
<li><a href="#branchessafari602branchSourceWebKit2WebProcesscocoaWebPlaybackSessionManagerh">branches/safari-602-branch/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.h</a></li>
<li><a href="#branchessafari602branchSourceWebKit2WebProcesscocoaWebPlaybackSessionManagermessagesin">branches/safari-602-branch/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.messages.in</a></li>
<li><a href="#branchessafari602branchSourceWebKit2WebProcesscocoaWebPlaybackSessionManagermm">branches/safari-602-branch/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.mm</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="#branchessafari602branchToolsTestWebKitAPITestsWebKit2Cocoalargevideoplayingscrollawayhtml">branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-playing-scroll-away.html</a></li>
<li><a href="#branchessafari602branchToolsTestWebKitAPITestsWebKit2Cocoalargevideosautoplayingclicktopausehtml">branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-click-to-pause.html</a></li>
<li><a href="#branchessafari602branchToolsTestWebKitAPITestsWebKit2Cocoalargevideosautoplayingscrolltovideohtml">branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-scroll-to-video.html</a></li>
<li><a href="#branchessafari602branchToolsTestWebKitAPITestsWebKit2Cocoalargevideospausedvideohidescontrolshtml">branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-paused-video-hides-controls.html</a></li>
<li><a href="#branchessafari602branchToolsTestWebKitAPITestsWebKit2Cocoalargevideosplayingmutedvideohidescontrolshtml">branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-muted-video-hides-controls.html</a></li>
<li><a href="#branchessafari602branchToolsTestWebKitAPITestsWebKit2Cocoalargevideosplayingvideokeepscontrolshtml">branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-video-keeps-controls.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 (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebCore/ChangeLog        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebCore/ChangeLog        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -1,3 +1,71 @@
</span><ins>+2016-09-09 Babak Shafiei <bshafiei@apple.com>
+
+ Merge r205412. rdar://problem/28014919
+
+ 2016-09-03 Wenson Hsieh <wenson_hsieh@apple.com>
+
+ Refactor the heuristic for showing media controls to take all media sessions into account
+ https://bugs.webkit.org/show_bug.cgi?id=161503
+ <rdar://problem/28033783>
+
+ Reviewed by Darin Adler.
+
+ Currently, when selecting a media session to show playback controls for, we grab the first media session that
+ passes our heuristic. Using this method, we are unable to take additional factors into account, such as whether
+ another media session's element is scrolled in view, or if another media session has been interacted with more
+ recently. To address this, we make the following changes:
+
+ 1. Consider the list of all MediaElementSessions.
+
+ 2. Select only the MediaElementSessions capable of showing media controls and sort the list by a special
+ heuristic that takes visibility and time of last user interaction into account. The first element on
+ this list is the strongest candidate for main content.
+
+ 3. If this strongest candidate is visible in the viewport, or it is playing with audio, we return this
+ as the chosen candidate. Otherwise, we return this session only if no other non-candidate video could be
+ confused as the main content (i.e. the non-candidate video is not only visible in the viewport, but also
+ large enough to be considered main content).
+
+ Using this new method of determining the video to show controls for, we retain previous behavior for pages with
+ a single video. On pages with multiple videos, the above logic ensures that if the current controlled video is
+ paused, scrolled out of view, and then a new video is scrolled into view, we will either hide media controls to
+ avoid confusion if that video could be confused for main content (using the mechanism in step 3), or we
+ hook up the media controls to the new video if it satisfies main content (using the mechanism in step 2).
+
+ This patch also adds 6 new TestWebKitAPI unit tests.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::mediaElementSessionInfoForSession):
+ (WebCore::preferMediaControlsForCandidateSessionOverOtherCandidateSession):
+ (WebCore::mediaSessionMayBeConfusedWithMainContent):
+ (WebCore::bestMediaSessionForShowingPlaybackControlsManager):
+ (WebCore::HTMLMediaElement::didAttachRenderers):
+ (WebCore::HTMLMediaElement::layoutSizeChanged):
+ (WebCore::HTMLMediaElement::isVisibleInViewportChanged):
+ (WebCore::HTMLMediaElement::resetPlaybackSessionState):
+ (WebCore::HTMLMediaElement::isVisibleInViewport):
+ (WebCore::HTMLMediaElement::updatePlaybackControlsManager):
+ * html/HTMLMediaElement.h:
+ * html/MediaElementSession.cpp:
+ (WebCore::MediaElementSession::removeBehaviorRestriction):
+ (WebCore::MediaElementSession::canShowControlsManager):
+ (WebCore::MediaElementSession::isLargeEnoughForMainContent):
+ (WebCore::MediaElementSession::mostRecentUserInteractionTime):
+ (WebCore::MediaElementSession::wantsToObserveViewportVisibilityForMediaControls):
+ (WebCore::MediaElementSession::wantsToObserveViewportVisibilityForAutoplay):
+ (WebCore::MediaElementSession::resetPlaybackSessionState):
+ (WebCore::MediaElementSession::canControlControlsManager): Deleted.
+ * html/MediaElementSession.h:
+ * platform/audio/PlatformMediaSession.h:
+ (WebCore::PlatformMediaSession::resetPlaybackSessionState):
+ (WebCore::PlatformMediaSession::canControlControlsManager): Deleted.
+ * platform/audio/PlatformMediaSessionManager.cpp:
+ (WebCore::PlatformMediaSessionManager::currentSessionsMatching):
+ (WebCore::PlatformMediaSessionManager::currentSessionMatching): Deleted.
+ * platform/audio/PlatformMediaSessionManager.h:
+ * platform/cocoa/WebPlaybackSessionModelMediaElement.mm:
+ (WebPlaybackSessionModelMediaElement::setMediaElement):
+
</ins><span class="cx"> 2016-08-31 Babak Shafiei <bshafiei@apple.com>
</span><span class="cx">
</span><span class="cx"> Merge r205193. rdar://problem/27529052
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/html/HTMLMediaElement.cpp (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebCore/html/HTMLMediaElement.cpp        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebCore/html/HTMLMediaElement.cpp        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -346,6 +346,79 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+struct MediaElementSessionInfo {
+ const MediaElementSession* session;
+
+ double timeOfLastUserInteraction;
+ bool canShowControlsManager : 1;
+ bool isVisibleInViewportOrFullscreen : 1;
+ bool isLargeEnoughForMainContent : 1;
+ bool isPlayingAudio : 1;
+};
+
+static MediaElementSessionInfo mediaElementSessionInfoForSession(const MediaElementSession& session)
+{
+ const HTMLMediaElement& element = session.element();
+ return {
+ &session,
+ session.mostRecentUserInteractionTime(),
+ session.canShowControlsManager(),
+ element.isFullscreen() || element.isVisibleInViewport(),
+ session.isLargeEnoughForMainContent(),
+ element.isPlaying() && element.hasAudio() && !element.muted()
+ };
+}
+
+static bool preferMediaControlsForCandidateSessionOverOtherCandidateSession(const MediaElementSessionInfo& session, const MediaElementSessionInfo& otherSession)
+{
+ // Prioritize visible media over offscreen media.
+ if (session.isVisibleInViewportOrFullscreen != otherSession.isVisibleInViewportOrFullscreen)
+ return session.isVisibleInViewportOrFullscreen;
+
+ // As a tiebreaker, prioritize elements that the user recently interacted with.
+ return session.timeOfLastUserInteraction > otherSession.timeOfLastUserInteraction;
+}
+
+static bool mediaSessionMayBeConfusedWithMainContent(const MediaElementSessionInfo& session)
+{
+ if (!session.isVisibleInViewportOrFullscreen)
+ return false;
+
+ if (!session.isLargeEnoughForMainContent)
+ return false;
+
+ // Even if this video is not a candidate, if it is visible to the user and large enough
+ // to be main content, it poses a risk for being confused with main content.
+ return true;
+}
+
+static const MediaElementSession* bestMediaSessionForShowingPlaybackControlsManager()
+{
+ auto allSessions = PlatformMediaSessionManager::sharedManager().currentSessionsMatching([] (const PlatformMediaSession& session) {
+ return is<MediaElementSession>(session);
+ });
+
+ Vector<MediaElementSessionInfo> candidateSessions;
+ bool atLeastOneNonCandidateMayBeConfusedForMainContent = false;
+ for (auto& session : allSessions) {
+ auto mediaElementSessionInfo = mediaElementSessionInfoForSession(downcast<MediaElementSession>(*session));
+ if (mediaElementSessionInfo.canShowControlsManager)
+ candidateSessions.append(mediaElementSessionInfo);
+ else if (mediaSessionMayBeConfusedWithMainContent(mediaElementSessionInfo))
+ atLeastOneNonCandidateMayBeConfusedForMainContent = true;
+ }
+
+ if (!candidateSessions.size())
+ return nullptr;
+
+ std::sort(candidateSessions.begin(), candidateSessions.end(), preferMediaControlsForCandidateSessionOverOtherCandidateSession);
+ auto strongestSessionCandidate = candidateSessions.first();
+ if (!strongestSessionCandidate.isVisibleInViewportOrFullscreen && !strongestSessionCandidate.isPlayingAudio && atLeastOneNonCandidateMayBeConfusedForMainContent)
+ return nullptr;
+
+ return strongestSessionCandidate.session;
+}
+
</ins><span class="cx"> HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& document, bool createdByParser)
</span><span class="cx"> : HTMLElement(tagName, document)
</span><span class="cx"> , ActiveDOMObject(&document)
</span><span class="lines">@@ -837,8 +910,7 @@
</span><span class="cx"> {
</span><span class="cx"> if (auto* renderer = this->renderer()) {
</span><span class="cx"> renderer->updateFromElement();
</span><del>- if (m_mediaSession->hasBehaviorRestriction(MediaElementSession::InvisibleAutoplayNotPermitted)
- || m_mediaSession->hasBehaviorRestriction(MediaElementSession::OverrideUserGestureRequirementForMainContent))
</del><ins>+ if (m_mediaSession && m_mediaSession->wantsToObserveViewportVisibilityForAutoplay())
</ins><span class="cx"> renderer->registerForVisibleInViewportCallback();
</span><span class="cx"> }
</span><span class="cx"> updateShouldAutoplay();
</span><span class="lines">@@ -4023,6 +4095,11 @@
</span><span class="cx"> m_receivedLayoutSizeChanged = true;
</span><span class="cx"> scheduleUpdatePlaybackControlsManager();
</span><span class="cx"> }
</span><ins>+
+ // If the video is a candidate for main content, we should register it for viewport visibility callbacks
+ // if it hasn't already been registered.
+ if (renderer() && m_mediaSession && !m_mediaSession->wantsToObserveViewportVisibilityForAutoplay() && m_mediaSession->wantsToObserveViewportVisibilityForMediaControls())
+ renderer()->registerForVisibleInViewportCallback();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void HTMLMediaElement::visibilityDidChange()
</span><span class="lines">@@ -7131,6 +7208,7 @@
</span><span class="cx"> void HTMLMediaElement::isVisibleInViewportChanged()
</span><span class="cx"> {
</span><span class="cx"> updateShouldAutoplay();
</span><ins>+ scheduleUpdatePlaybackControlsManager();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void HTMLMediaElement::updateShouldAutoplay()
</span><span class="lines">@@ -7159,6 +7237,18 @@
</span><span class="cx"> play();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void HTMLMediaElement::resetPlaybackSessionState()
+{
+ if (m_mediaSession)
+ m_mediaSession->resetPlaybackSessionState();
+}
+
+bool HTMLMediaElement::isVisibleInViewport() const
+{
+ auto renderer = this->renderer();
+ return renderer && renderer->visibleInViewportState() == RenderElement::VisibleInViewport;
+}
+
</ins><span class="cx"> void HTMLMediaElement::updatePlaybackControlsManager()
</span><span class="cx"> {
</span><span class="cx"> Page* page = document().page();
</span><span class="lines">@@ -7165,14 +7255,11 @@
</span><span class="cx"> if (!page)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- PlatformMediaSession* session = PlatformMediaSessionManager::sharedManager().currentSessionMatching([] (const PlatformMediaSession& session) {
- return session.canControlControlsManager();
- });
-
- if (!is<MediaElementSession>(session))
</del><ins>+ // FIXME: Ensure that the renderer here should be up to date.
+ if (auto bestMediaSession = bestMediaSessionForShowingPlaybackControlsManager())
+ page->chrome().client().setUpPlaybackControlsManager(bestMediaSession->element());
+ else
</ins><span class="cx"> page->chrome().client().clearPlaybackControlsManager();
</span><del>- else
- page->chrome().client().setUpPlaybackControlsManager(downcast<MediaElementSession>(session)->element());
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void HTMLMediaElement::scheduleUpdatePlaybackControlsManager()
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCorehtmlHTMLMediaElementh"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/html/HTMLMediaElement.h (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebCore/html/HTMLMediaElement.h        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebCore/html/HTMLMediaElement.h        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -468,6 +468,9 @@
</span><span class="cx">
</span><span class="cx"> RenderMedia* renderer() const;
</span><span class="cx">
</span><ins>+ void resetPlaybackSessionState();
+ bool isVisibleInViewport() const;
+
</ins><span class="cx"> protected:
</span><span class="cx"> HTMLMediaElement(const QualifiedName&, Document&, bool createdByParser);
</span><span class="cx"> virtual ~HTMLMediaElement();
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCorehtmlMediaElementSessioncpp"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/html/MediaElementSession.cpp (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebCore/html/MediaElementSession.cpp        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebCore/html/MediaElementSession.cpp        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -48,6 +48,7 @@
</span><span class="cx"> #include "ScriptController.h"
</span><span class="cx"> #include "SourceBuffer.h"
</span><span class="cx"> #include <wtf/spi/darwin/dyldSPI.h>
</span><ins>+#include <wtf/CurrentTime.h>
</ins><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> #include "AudioSession.h"
</span><span class="lines">@@ -137,6 +138,9 @@
</span><span class="cx">
</span><span class="cx"> void MediaElementSession::removeBehaviorRestriction(BehaviorRestrictions restriction)
</span><span class="cx"> {
</span><ins>+ if (restriction & RequireUserGestureToControlControlsManager)
+ m_mostRecentUserInteractionTime = monotonicallyIncreasingTime();
+
</ins><span class="cx"> LOG(Media, "MediaElementSession::removeBehaviorRestriction - removing %s", restrictionName(restriction).utf8().data());
</span><span class="cx"> m_restrictions &= ~restriction;
</span><span class="cx"> }
</span><span class="lines">@@ -212,69 +216,89 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool MediaElementSession::canControlControlsManager() const
</del><ins>+bool MediaElementSession::canShowControlsManager() const
</ins><span class="cx"> {
</span><span class="cx"> if (m_element.isFullscreen()) {
</span><del>- LOG(Media, "MediaElementSession::canControlControlsManager - returning TRUE: Is fullscreen");
</del><ins>+ LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Is fullscreen");
</ins><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (!m_element.hasAudio()) {
</span><del>- LOG(Media, "MediaElementSession::canControlControlsManager - returning FALSE: No audio");
</del><ins>+ LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: No audio");
</ins><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (m_element.document().activeDOMObjectsAreSuspended()) {
</span><del>- LOG(Media, "MediaElementSession::canControlControlsManager - returning FALSE: activeDOMObjectsAreSuspended()");
</del><ins>+ LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: activeDOMObjectsAreSuspended()");
</ins><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (!playbackPermitted(m_element)) {
</span><del>- LOG(Media, "MediaElementSession::canControlControlsManager - returning FALSE: Playback not permitted");
</del><ins>+ LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Playback not permitted");
</ins><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (!hasBehaviorRestriction(RequireUserGestureToControlControlsManager) || ScriptController::processingUserGestureForMedia()) {
</span><del>- LOG(Media, "MediaElementSession::canControlControlsManager - returning TRUE: No user gesture required");
</del><ins>+ LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: No user gesture required");
</ins><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (hasBehaviorRestriction(RequirePlaybackToControlControlsManager) && !m_element.isPlaying()) {
</span><del>- LOG(Media, "MediaElementSession::canControlControlsManager - returning FALSE: Needs to be playing");
</del><ins>+ LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Needs to be playing");
</ins><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (m_element.muted()) {
</span><del>- LOG(Media, "MediaElementSession::canControlControlsManager - returning FALSE: Muted");
</del><ins>+ LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Muted");
</ins><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (m_element.isVideo()) {
</span><span class="cx"> if (!m_element.renderer()) {
</span><del>- LOG(Media, "MediaElementSession::canControlControlsManager - returning FALSE: No renderer");
</del><ins>+ LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: No renderer");
</ins><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (m_element.document().isMediaDocument()) {
</span><del>- LOG(Media, "MediaElementSession::canControlControlsManager - returning TRUE: Is media document");
</del><ins>+ LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Is media document");
</ins><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (!m_element.hasVideo()) {
</span><del>- LOG(Media, "MediaElementSession::canControlControlsManager - returning FALSE: No video");
</del><ins>+ LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: No video");
</ins><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (isElementLargeEnoughForMainContent(m_element)) {
- LOG(Media, "MediaElementSession::canControlControlsManager - returning TRUE: Is main content");
</del><ins>+ if (isLargeEnoughForMainContent()) {
+ LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Is main content");
</ins><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- LOG(Media, "MediaElementSession::canControlControlsManager - returning FALSE: No user gesture");
</del><ins>+ LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: No user gesture");
</ins><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool MediaElementSession::isLargeEnoughForMainContent() const
+{
+ return isElementLargeEnoughForMainContent(m_element);
+}
+
+double MediaElementSession::mostRecentUserInteractionTime() const
+{
+ return m_mostRecentUserInteractionTime;
+}
+
+bool MediaElementSession::wantsToObserveViewportVisibilityForMediaControls() const
+{
+ return isLargeEnoughForMainContent();
+}
+
+bool MediaElementSession::wantsToObserveViewportVisibilityForAutoplay() const
+{
+ return hasBehaviorRestriction(InvisibleAutoplayNotPermitted) || hasBehaviorRestriction(OverrideUserGestureRequirementForMainContent);
+}
+
</ins><span class="cx"> #if ENABLE(WIRELESS_PLAYBACK_TARGET)
</span><span class="cx"> void MediaElementSession::showPlaybackTargetPicker(const HTMLMediaElement& element)
</span><span class="cx"> {
</span><span class="lines">@@ -502,6 +526,12 @@
</span><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void MediaElementSession::resetPlaybackSessionState()
+{
+ m_mostRecentUserInteractionTime = 0;
+ addBehaviorRestriction(RequireUserGestureToControlControlsManager | RequirePlaybackToControlControlsManager);
+}
+
</ins><span class="cx"> bool MediaElementSession::allowsPictureInPicture(const HTMLMediaElement& element) const
</span><span class="cx"> {
</span><span class="cx"> Settings* settings = element.document().settings();
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCorehtmlMediaElementSessionh"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/html/MediaElementSession.h (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebCore/html/MediaElementSession.h        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebCore/html/MediaElementSession.h        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -54,8 +54,6 @@
</span><span class="cx"> bool pageAllowsDataLoading(const HTMLMediaElement&) const;
</span><span class="cx"> bool pageAllowsPlaybackAfterResuming(const HTMLMediaElement&) const;
</span><span class="cx">
</span><del>- bool canControlControlsManager() const override;
-
</del><span class="cx"> #if ENABLE(WIRELESS_PLAYBACK_TARGET)
</span><span class="cx"> void showPlaybackTargetPicker(const HTMLMediaElement&);
</span><span class="cx"> bool hasWirelessPlaybackTargets(const HTMLMediaElement&) const;
</span><span class="lines">@@ -78,6 +76,8 @@
</span><span class="cx">
</span><span class="cx"> void mediaEngineUpdated(const HTMLMediaElement&);
</span><span class="cx">
</span><ins>+ void resetPlaybackSessionState() override;
+
</ins><span class="cx"> // Restrictions to modify default behaviors.
</span><span class="cx"> enum BehaviorRestrictionFlags {
</span><span class="cx"> NoRestrictions = 0,
</span><span class="lines">@@ -111,6 +111,12 @@
</span><span class="cx">
</span><span class="cx"> HTMLMediaElement& element() const { return m_element; }
</span><span class="cx">
</span><ins>+ bool wantsToObserveViewportVisibilityForMediaControls() const;
+ bool wantsToObserveViewportVisibilityForAutoplay() const;
+ bool canShowControlsManager() const;
+ bool isLargeEnoughForMainContent() const;
+ double mostRecentUserInteractionTime() const;
+
</ins><span class="cx"> private:
</span><span class="cx">
</span><span class="cx"> #if ENABLE(WIRELESS_PLAYBACK_TARGET)
</span><span class="lines">@@ -140,6 +146,8 @@
</span><span class="cx"> bool m_hasPlaybackTargetAvailabilityListeners { false };
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+ double m_mostRecentUserInteractionTime { 0 };
+
</ins><span class="cx"> mutable bool m_isMainContent { false };
</span><span class="cx"> Timer m_mainContentCheckTimer;
</span><span class="cx"> };
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCoreplatformaudioPlatformMediaSessionh"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/platform/audio/PlatformMediaSession.h (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebCore/platform/audio/PlatformMediaSession.h        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebCore/platform/audio/PlatformMediaSession.h        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -139,7 +139,6 @@
</span><span class="cx">
</span><span class="cx"> bool shouldOverrideBackgroundLoadingRestriction() const;
</span><span class="cx">
</span><del>- virtual bool canControlControlsManager() const { return false; }
</del><span class="cx"> virtual bool canPlayToWirelessPlaybackTarget() const { return false; }
</span><span class="cx"> virtual bool isPlayingToWirelessPlaybackTarget() const { return m_isPlayingToWirelessPlaybackTarget; }
</span><span class="cx"> void isPlayingToWirelessPlaybackTargetChanged(bool);
</span><span class="lines">@@ -160,6 +159,7 @@
</span><span class="cx"> void setCanProduceAudio(bool);
</span><span class="cx">
</span><span class="cx"> void scheduleClientDataBufferingCheck();
</span><ins>+ virtual void resetPlaybackSessionState() { }
</ins><span class="cx">
</span><span class="cx"> protected:
</span><span class="cx"> PlatformMediaSessionClient& client() const { return m_client; }
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCoreplatformaudioPlatformMediaSessionManagercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -278,13 +278,14 @@
</span><span class="cx"> return m_sessions[0];
</span><span class="cx"> }
</span><span class="cx">
</span><del>-PlatformMediaSession* PlatformMediaSessionManager::currentSessionMatching(std::function<bool(const PlatformMediaSession &)> filter)
</del><ins>+Vector<PlatformMediaSession*> PlatformMediaSessionManager::currentSessionsMatching(std::function<bool(const PlatformMediaSession &)> filter)
</ins><span class="cx"> {
</span><ins>+ Vector<PlatformMediaSession*> matchingSessions;
</ins><span class="cx"> for (auto& session : m_sessions) {
</span><span class="cx"> if (filter(*session))
</span><del>- return session;
</del><ins>+ matchingSessions.append(session);
</ins><span class="cx"> }
</span><del>- return nullptr;
</del><ins>+ return matchingSessions;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool PlatformMediaSessionManager::sessionCanLoadMedia(const PlatformMediaSession& session) const
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCoreplatformaudioPlatformMediaSessionManagerh"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -92,7 +92,7 @@
</span><span class="cx"> void setCurrentSession(PlatformMediaSession&);
</span><span class="cx"> PlatformMediaSession* currentSession();
</span><span class="cx">
</span><del>- PlatformMediaSession* currentSessionMatching(std::function<bool(const PlatformMediaSession&)>);
</del><ins>+ Vector<PlatformMediaSession*> currentSessionsMatching(std::function<bool(const PlatformMediaSession&)>);
</ins><span class="cx">
</span><span class="cx"> void sessionIsPlayingToWirelessPlaybackTargetChanged(PlatformMediaSession&);
</span><span class="cx"> void sessionCanProduceAudioChanged(PlatformMediaSession&);
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCoreplatformcocoaWebPlaybackSessionModelMediaElementmm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.mm (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.mm        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.mm        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -94,6 +94,9 @@
</span><span class="cx"> }
</span><span class="cx"> m_isListening = false;
</span><span class="cx">
</span><ins>+ if (m_mediaElement)
+ m_mediaElement->resetPlaybackSessionState();
+
</ins><span class="cx"> m_mediaElement = mediaElement;
</span><span class="cx">
</span><span class="cx"> if (!m_mediaElement)
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/ChangeLog (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/ChangeLog        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebKit2/ChangeLog        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -1,5 +1,43 @@
</span><span class="cx"> 2016-09-09 Babak Shafiei <bshafiei@apple.com>
</span><span class="cx">
</span><ins>+ Merge r205412. rdar://problem/28014919
+
+ 2016-09-03 Wenson Hsieh <wenson_hsieh@apple.com>
+
+ Refactor the heuristic for showing media controls to take all media sessions into account
+ https://bugs.webkit.org/show_bug.cgi?id=161503
+ <rdar://problem/28033783>
+
+ Reviewed by Darin Adler.
+
+ Adds an SPI testing hook for sending the element ID of the currently controlled video element from the web
+ process to the UI process. See VideoControlsManager.mm in Tools/TestWebKitAPI/ for usage.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _requestControlledElementID]):
+ (-[WKWebView _handleControlledElementIDResponse:]):
+ (-[WKWebView _hasActiveVideoForControlsManager]): Deleted.
+ * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+ * UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h:
+ * UIProcess/Cocoa/WebPlaybackSessionManagerProxy.messages.in:
+ * UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm:
+ (WebKit::WebPlaybackSessionManagerProxy::handleControlledElementIDResponse):
+ (WebKit::WebPlaybackSessionManagerProxy::requestControlledElementID):
+ * UIProcess/PageClient.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::requestControlledElementID):
+ (WebKit::WebPageProxy::handleControlledElementIDResponse):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/mac/PageClientImpl.h:
+ * UIProcess/mac/PageClientImpl.mm:
+ (WebKit::PageClientImpl::handleControlledElementIDResponse):
+ * WebProcess/cocoa/WebPlaybackSessionManager.h:
+ * WebProcess/cocoa/WebPlaybackSessionManager.messages.in:
+ * WebProcess/cocoa/WebPlaybackSessionManager.mm:
+ (WebKit::WebPlaybackSessionManager::handleControlledElementIDRequest):
+
+2016-09-09 Babak Shafiei <bshafiei@apple.com>
+
</ins><span class="cx"> Merge r204911. rdar://problem/28175524
</span><span class="cx">
</span><span class="cx"> 2016-08-24 Anders Carlsson <andersca@apple.com>
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -4541,6 +4541,17 @@
</span><span class="cx"> {
</span><span class="cx"> return _page && _page->hasActiveVideoForControlsManager();
</span><span class="cx"> }
</span><ins>+
+- (void)_requestControlledElementID
+{
+ if (_page)
+ _page->requestControlledElementID();
+}
+
+- (void)_handleControlledElementIDResponse:(NSString *)identifier
+{
+ // Overridden by subclasses.
+}
</ins><span class="cx"> #endif // PLATFORM(MAC)
</span><span class="cx">
</span><span class="cx"> // Execute the supplied block after the next transaction from the WebProcess.
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2UIProcessAPICocoaWKWebViewPrivateh"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -268,6 +268,8 @@
</span><span class="cx">
</span><span class="cx"> #if !TARGET_OS_IPHONE
</span><span class="cx"> @property (nonatomic, readonly) BOOL _hasActiveVideoForControlsManager WK_API_AVAILABLE(macosx(WK_MAC_TBA));
</span><ins>+- (void)_requestControlledElementID WK_API_AVAILABLE(macosx(WK_MAC_TBA));
+- (void)_handleControlledElementIDResponse:(NSString *)identifier WK_API_AVAILABLE(macosx(WK_MAC_TBA));
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> - (void)_doAfterNextPresentationUpdate:(void (^)(void))updateBlock WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2UIProcessCocoaWebPlaybackSessionManagerProxyh"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -140,6 +140,7 @@
</span><span class="cx"> void invalidate();
</span><span class="cx">
</span><span class="cx"> PlatformWebPlaybackSessionInterface* controlsManagerInterface();
</span><ins>+ void requestControlledElementID();
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> friend class WebPlaybackSessionModelContext;
</span><span class="lines">@@ -170,6 +171,7 @@
</span><span class="cx"> void setWirelessVideoPlaybackDisabled(uint64_t contextId, bool);
</span><span class="cx"> void setDuration(uint64_t contextId, double duration);
</span><span class="cx"> void setRate(uint64_t contextId, bool isPlaying, double rate);
</span><ins>+ void handleControlledElementIDResponse(uint64_t, String) const;
</ins><span class="cx">
</span><span class="cx"> // Messages to WebPlaybackSessionManager
</span><span class="cx"> void play(uint64_t contextId);
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2UIProcessCocoaWebPlaybackSessionManagerProxymessagesin"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.messages.in (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.messages.in        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.messages.in        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -35,5 +35,7 @@
</span><span class="cx"> SetRate(uint64_t contextId, bool isPlaying, double rate)
</span><span class="cx"> SetUpPlaybackControlsManagerWithID(uint64_t contextId)
</span><span class="cx"> ClearPlaybackControlsManager()
</span><ins>+
+ HandleControlledElementIDResponse(uint64_t contextId, String id)
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2UIProcessCocoaWebPlaybackSessionManagerProxymm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -343,6 +343,19 @@
</span><span class="cx"> interface->setRate(isPlaying, rate);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+
+void WebPlaybackSessionManagerProxy::handleControlledElementIDResponse(uint64_t contextId, String identifier) const
+{
+#if PLATFORM(MAC)
+ if (contextId == m_controlsManagerContextId)
+ m_page->handleControlledElementIDResponse(identifier);
+#else
+ UNUSED_PARAM(contextId);
+ UNUSED_PARAM(identifier);
+#endif
+}
+
+
</ins><span class="cx"> #pragma mark Messages to WebPlaybackSessionManager
</span><span class="cx">
</span><span class="cx"> void WebPlaybackSessionManagerProxy::play(uint64_t contextId)
</span><span class="lines">@@ -405,6 +418,12 @@
</span><span class="cx"> m_page->send(Messages::WebPlaybackSessionManager::SelectLegibleMediaOption(contextId, index), m_page->pageID());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebPlaybackSessionManagerProxy::requestControlledElementID()
+{
+ if (m_controlsManagerContextId)
+ m_page->send(Messages::WebPlaybackSessionManager::HandleControlledElementIDRequest(m_controlsManagerContextId), m_page->pageID());
+}
+
</ins><span class="cx"> PlatformWebPlaybackSessionInterface* WebPlaybackSessionManagerProxy::controlsManagerInterface()
</span><span class="cx"> {
</span><span class="cx"> if (!m_controlsManagerContextId)
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2UIProcessPageClienth"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/PageClient.h (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/UIProcess/PageClient.h        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/PageClient.h        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -248,6 +248,7 @@
</span><span class="cx"> virtual void recordAutocorrectionResponse(WebCore::AutocorrectionResponseType, const String& replacedString, const String& replacementString) = 0;
</span><span class="cx"> virtual void recommendedScrollbarStyleDidChange(WebCore::ScrollbarStyle) = 0;
</span><span class="cx"> virtual void removeNavigationGestureSnapshot() = 0;
</span><ins>+ virtual void handleControlledElementIDResponse(const String&) = 0;
</ins><span class="cx">
</span><span class="cx"> virtual CGRect boundsOfLayerInLayerBackedWindowCoordinates(CALayer *) const = 0;
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -6280,6 +6280,19 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebPageProxy::requestControlledElementID() const
+{
+#if ENABLE(VIDEO_PRESENTATION_MODE)
+ if (m_playbackSessionManager)
+ m_playbackSessionManager->requestControlledElementID();
+#endif
+}
+
+void WebPageProxy::handleControlledElementIDResponse(const String& identifier) const
+{
+ m_pageClient.handleControlledElementIDResponse(identifier);
+}
+
</ins><span class="cx"> bool WebPageProxy::isPlayingVideoInEnhancedFullscreen() const
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(VIDEO_PRESENTATION_MODE)
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.h (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.h        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.h        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -1031,6 +1031,8 @@
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> void videoControlsManagerDidChange();
</span><span class="cx"> bool hasActiveVideoForControlsManager() const;
</span><ins>+ void requestControlledElementID() const;
+ void handleControlledElementIDResponse(const String&) const;
</ins><span class="cx"> bool isPlayingVideoInEnhancedFullscreen() const;
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2UIProcessmacPageClientImplh"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.h (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -207,6 +207,7 @@
</span><span class="cx"> void didFailLoadForMainFrame() override;
</span><span class="cx"> void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType) override;
</span><span class="cx"> void removeNavigationGestureSnapshot() override;
</span><ins>+ void handleControlledElementIDResponse(const String&) override;
</ins><span class="cx">
</span><span class="cx"> void didPerformImmediateActionHitTest(const WebHitTestResultData&, bool contentPreventsDefault, API::Object*) override;
</span><span class="cx"> void* immediateActionAnimationControllerForHitTestResult(RefPtr<API::HitTestResult>, uint64_t, RefPtr<API::Object>) override;
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2UIProcessmacPageClientImplmm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -756,6 +756,13 @@
</span><span class="cx"> gestureController->removeSwipeSnapshot();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void PageClientImpl::handleControlledElementIDResponse(const String& identifier)
+{
+#if WK_API_ENABLED
+ [m_webView _handleControlledElementIDResponse:nsStringFromWebCoreString(identifier)];
+#endif
+}
+
</ins><span class="cx"> void PageClientImpl::didChangeBackgroundColor()
</span><span class="cx"> {
</span><span class="cx"> notImplemented();
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2WebProcesscocoaWebPlaybackSessionManagerh"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.h (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.h        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.h        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -138,6 +138,7 @@
</span><span class="cx"> void endScanning(uint64_t contextId);
</span><span class="cx"> void selectAudioMediaOption(uint64_t contextId, uint64_t index);
</span><span class="cx"> void selectLegibleMediaOption(uint64_t contextId, uint64_t index);
</span><ins>+ void handleControlledElementIDRequest(uint64_t contextId);
</ins><span class="cx">
</span><span class="cx"> WebPage* m_page;
</span><span class="cx"> HashMap<WebCore::HTMLMediaElement*, uint64_t> m_mediaElements;
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2WebProcesscocoaWebPlaybackSessionManagermessagesin"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.messages.in (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.messages.in        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.messages.in        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -35,5 +35,6 @@
</span><span class="cx"> EndScanning(uint64_t contextId)
</span><span class="cx"> SelectAudioMediaOption(uint64_t contextId, uint64_t index)
</span><span class="cx"> SelectLegibleMediaOption(uint64_t contextId, uint64_t index)
</span><ins>+ HandleControlledElementIDRequest(uint64_t contextId)
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2WebProcesscocoaWebPlaybackSessionManagermm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.mm (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.mm        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.mm        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -417,6 +417,13 @@
</span><span class="cx"> ensureModel(contextId).selectLegibleMediaOption(index);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebPlaybackSessionManager::handleControlledElementIDRequest(uint64_t contextId)
+{
+ auto element = ensureModel(contextId).mediaElement();
+ if (element)
+ m_page->send(Messages::WebPlaybackSessionManagerProxy::HandleControlledElementIDResponse(contextId, element->getIdAttribute()));
+}
+
</ins><span class="cx"> } // namespace WebKit
</span><span class="cx">
</span><span class="cx"> #endif // PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
</span></span></pre></div>
<a id="branchessafari602branchToolsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Tools/ChangeLog (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/ChangeLog        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Tools/ChangeLog        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2016-09-09 Babak Shafiei <bshafiei@apple.com>
+
+ Merge r205412. rdar://problem/28014919
+
+ 2016-09-03 Wenson Hsieh <wenson_hsieh@apple.com>
+
+ Refactor the heuristic for showing media controls to take all media sessions into account
+ https://bugs.webkit.org/show_bug.cgi?id=161503
+ <rdar://problem/28033783>
+
+ Reviewed by Darin Adler.
+
+ Adds new unit tests verifying the behavior of media playback controls when scrolling another video into view.
+ Please see the WebCore ChangeLog for more details about this change. Also refactors existing
+ VideoControlsManager tests by folding duplicated setup and testing logic into helper methods to make the unit
+ tests more readable.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm:
+ (-[MessageHandler initWithMessage:handler:]):
+ (-[MessageHandler userContentController:didReceiveScriptMessage:]):
+ (-[VideoControlsManagerTestWebView performAfterLoading:]):
+ (-[VideoControlsManagerTestWebView loadTestPageNamed:]):
+ (-[VideoControlsManagerTestWebView loadTestPageNamed:andExpectControlsManager:afterReceivingMessage:]):
+ (-[VideoControlsManagerTestWebView performAfterReceivingMessage:action:]):
+ (-[VideoControlsManagerTestWebView controlledElementID]):
+ (-[VideoControlsManagerTestWebView _handleControlledElementIDResponse:]):
+ (TestWebKitAPI::setUpWebViewForTestingVideoControlsManager):
+ (TestWebKitAPI::TEST):
+ (-[MediaPlaybackMessageHandler initWithWKWebView:finalMessageString:]): Deleted.
+ (-[MediaPlaybackMessageHandler userContentController:didReceiveScriptMessage:]): Deleted.
+ (-[OnLoadMessageHandler initWithWKWebView:handler:]): Deleted.
+ (-[OnLoadMessageHandler userContentController:didReceiveScriptMessage:]): Deleted.
+ (-[WKWebView performAfterLoading:]): Deleted.
+ * TestWebKitAPI/Tests/WebKit2Cocoa/large-video-playing-scroll-away.html: Added.
+ * TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-click-to-pause.html: Added.
+ * TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-scroll-to-video.html: Added.
+ * TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-paused-video-hides-controls.html: Added.
+ * TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-muted-video-hides-controls.html: Added.
+ * TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-video-keeps-controls.html: Added.
+
</ins><span class="cx"> 2016-08-31 Babak Shafiei <bshafiei@apple.com>
</span><span class="cx">
</span><span class="cx"> Merge r204989. rdar://problem/28015116
</span></span></pre></div>
<a id="branchessafari602branchToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -60,6 +60,12 @@
</span><span class="cx">                 2E1DFDED1D42A51100714A00 /* large-videos-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E1DFDEC1D42A41C00714A00 /* large-videos-with-audio.html */; };
</span><span class="cx">                 2E1DFDEF1D42A6F200714A00 /* large-videos-with-audio-autoplay.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E1DFDEE1D42A6EB00714A00 /* large-videos-with-audio-autoplay.html */; };
</span><span class="cx">                 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 */; };
</span><ins>+                2E691AEA1D78B53600129407 /* large-videos-paused-video-hides-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E691AE81D78B52B00129407 /* large-videos-paused-video-hides-controls.html */; };
+                2E691AEB1D78B53600129407 /* large-videos-playing-video-keeps-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E691AE91D78B52B00129407 /* large-videos-playing-video-keeps-controls.html */; };
+                2E691AED1D78B91000129407 /* large-videos-playing-muted-video-hides-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E691AEC1D78B90200129407 /* large-videos-playing-muted-video-hides-controls.html */; };
+                2E691AEF1D79DE8400129407 /* large-videos-autoplaying-click-to-pause.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E691AEE1D79DE6F00129407 /* large-videos-autoplaying-click-to-pause.html */; };
+                2E691AF11D79E51A00129407 /* large-videos-autoplaying-scroll-to-video.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E691AF01D79E51400129407 /* large-videos-autoplaying-scroll-to-video.html */; };
+                2E691AF31D79E75E00129407 /* large-video-playing-scroll-away.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E691AF21D79E75400129407 /* large-video-playing-scroll-away.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">@@ -562,6 +568,12 @@
</span><span class="cx">                                 7AE9E5091AE5AE8B00CF874B /* test.pdf in Copy Resources */,
</span><span class="cx">                                 7A1458FC1AD5C07000E06772 /* mouse-button-listener.html in Copy Resources */,
</span><span class="cx">                                 7C486BA11AA12567003F6F9B /* bundle-file.html in Copy Resources */,
</span><ins>+                                2E691AF31D79E75E00129407 /* large-video-playing-scroll-away.html in Copy Resources */,
+                                2E691AF11D79E51A00129407 /* large-videos-autoplaying-scroll-to-video.html in Copy Resources */,
+                                2E691AEF1D79DE8400129407 /* large-videos-autoplaying-click-to-pause.html in Copy Resources */,
+                                2E691AED1D78B91000129407 /* large-videos-playing-muted-video-hides-controls.html in Copy Resources */,
+                                2E691AEA1D78B53600129407 /* large-videos-paused-video-hides-controls.html in Copy Resources */,
+                                2E691AEB1D78B53600129407 /* large-videos-playing-video-keeps-controls.html in Copy Resources */,
</ins><span class="cx">                                 1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */,
</span><span class="cx">                                 1C2B81861C89259D00A5529F /* webfont.html in Copy Resources */,
</span><span class="cx">                                 379028B914FAC24C007E6B43 /* acceptsFirstMouse.html in Copy Resources */,
</span><span class="lines">@@ -722,6 +734,12 @@
</span><span class="cx">                 2E1DFDEC1D42A41C00714A00 /* large-videos-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-videos-with-audio.html"; sourceTree = "<group>"; };
</span><span class="cx">                 2E1DFDEE1D42A6EB00714A00 /* large-videos-with-audio-autoplay.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-videos-with-audio-autoplay.html"; sourceTree = "<group>"; };
</span><span class="cx">                 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>"; };
</span><ins>+                2E691AE81D78B52B00129407 /* large-videos-paused-video-hides-controls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-videos-paused-video-hides-controls.html"; sourceTree = "<group>"; };
+                2E691AE91D78B52B00129407 /* large-videos-playing-video-keeps-controls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-videos-playing-video-keeps-controls.html"; sourceTree = "<group>"; };
+                2E691AEC1D78B90200129407 /* large-videos-playing-muted-video-hides-controls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-videos-playing-muted-video-hides-controls.html"; sourceTree = "<group>"; };
+                2E691AEE1D79DE6F00129407 /* large-videos-autoplaying-click-to-pause.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-videos-autoplaying-click-to-pause.html"; sourceTree = "<group>"; };
+                2E691AF01D79E51400129407 /* large-videos-autoplaying-scroll-to-video.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-videos-autoplaying-scroll-to-video.html"; sourceTree = "<group>"; };
+                2E691AF21D79E75400129407 /* large-video-playing-scroll-away.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-playing-scroll-away.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">@@ -1367,6 +1385,12 @@
</span><span class="cx">                                 2E1DFDF01D42E14400714A00 /* large-video-seek-to-beginning-and-play-after-ending.html */,
</span><span class="cx">                                 2E1B7B011D41B1B3007558B4 /* large-video-hides-controls-after-seek-to-end.html */,
</span><span class="cx">                                 2E1DFDEE1D42A6EB00714A00 /* large-videos-with-audio-autoplay.html */,
</span><ins>+                                2E691AF21D79E75400129407 /* large-video-playing-scroll-away.html */,
+                                2E691AF01D79E51400129407 /* large-videos-autoplaying-scroll-to-video.html */,
+                                2E691AEE1D79DE6F00129407 /* large-videos-autoplaying-click-to-pause.html */,
+                                2E691AEC1D78B90200129407 /* large-videos-playing-muted-video-hides-controls.html */,
+                                2E691AE81D78B52B00129407 /* large-videos-paused-video-hides-controls.html */,
+                                2E691AE91D78B52B00129407 /* large-videos-playing-video-keeps-controls.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></pre></div>
<a id="branchessafari602branchToolsTestWebKitAPITestsWebKit2CocoaVideoControlsManagermm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm (205704 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm        2016-09-09 08:41:37 UTC (rev 205704)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -37,66 +37,30 @@
</span><span class="cx">
</span><span class="cx"> #if WK_API_ENABLED && PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
</span><span class="cx">
</span><del>-static bool testedControlsManagerAfterPlaying;
-static bool receivedScriptMessage;
</del><ins>+@interface WKWebView (WKWebViewAdditions)
</ins><span class="cx">
</span><del>-@interface MediaPlaybackMessageHandler : NSObject <WKScriptMessageHandler> {
- RetainPtr<WKWebView> _webView;
-}
</del><ins>+- (void)_interactWithMediaControlsForTesting;
</ins><span class="cx">
</span><del>-@property (nonatomic) BOOL expectedToHaveControlsManager;
-@property (nonatomic, retain) NSString *finalMessageString;
-
-- (instancetype)initWithWKWebView:(WKWebView*)webView finalMessageString:(NSString *)finalMessageString;
</del><span class="cx"> @end
</span><span class="cx">
</span><del>-@implementation MediaPlaybackMessageHandler
-
-- (instancetype)initWithWKWebView:(WKWebView*)webView finalMessageString:(NSString *)finalMessageString
-{
- if (!(self = [super init]))
- return nil;
-
- _webView = webView;
- _finalMessageString = finalMessageString;
-
- return self;
</del><ins>+@interface MessageHandler : NSObject <WKScriptMessageHandler> {
+ dispatch_block_t _handler;
+ NSString *_message;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
-{
- receivedScriptMessage = true;
</del><ins>+- (instancetype)initWithMessage:(NSString *)message handler:(dispatch_block_t)handler;
</ins><span class="cx">
</span><del>- NSString *bodyString = (NSString *)[message body];
- if ([bodyString isEqualToString:self.finalMessageString]) {
- BOOL hasControlsManager = [_webView _hasActiveVideoForControlsManager];
- if (self.expectedToHaveControlsManager)
- EXPECT_TRUE(hasControlsManager);
- else
- EXPECT_FALSE(hasControlsManager);
- testedControlsManagerAfterPlaying = true;
- }
-}
</del><span class="cx"> @end
</span><span class="cx">
</span><del>-@interface OnLoadMessageHandler : NSObject <WKScriptMessageHandler> {
- RetainPtr<WKWebView> _webView;
-}
</del><ins>+@implementation MessageHandler
</ins><span class="cx">
</span><del>-@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
</del><ins>+- (instancetype)initWithMessage:(NSString *)message handler:(dispatch_block_t)handler
</ins><span class="cx"> {
</span><span class="cx"> if (!(self = [super init]))
</span><span class="cx"> return nil;
</span><span class="cx">
</span><del>- _webView = webView;
- _onloadHandler = handler;
</del><ins>+ _handler = [handler copy];
+ _message = message;
</ins><span class="cx">
</span><span class="cx"> return self;
</span><span class="cx"> }
</span><span class="lines">@@ -103,30 +67,28 @@
</span><span class="cx">
</span><span class="cx"> - (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
</span><span class="cx"> {
</span><del>- if (![(NSString *)[message body] isEqualToString:@"loaded"])
- return;
-
- if (_onloadHandler)
- _onloadHandler();
-
- _onloadHandler = nil;
</del><ins>+ if ([(NSString *)[message body] isEqualToString:_message] && _handler)
+ _handler();
</ins><span class="cx"> }
</span><del>-@end
</del><span class="cx">
</span><del>-@interface WKWebView (WKWebViewAdditions)
-
-- (void)_interactWithMediaControlsForTesting;
-
</del><span class="cx"> @end
</span><span class="cx">
</span><del>-@interface WKWebView (TestingAdditions)
</del><ins>+@interface VideoControlsManagerTestWebView : WKWebView
</ins><span class="cx">
</span><span class="cx"> - (void)mouseDownAtPoint:(NSPoint)point;
</span><span class="cx"> - (void)performAfterLoading:(dispatch_block_t)actions;
</span><ins>+- (void)loadTestPageNamed:(NSString *)pageName;
+- (void)loadTestPageNamed:(NSString *)pageName andExpectControlsManager:(BOOL)expectControlsManager afterReceivingMessage:(NSString *)message;
+- (void)performAfterReceivingMessage:(NSString *)message action:(dispatch_block_t)action;
</ins><span class="cx">
</span><ins>+@property (nonatomic, readonly) NSString *controlledElementID;
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><del>-@implementation WKWebView (TestingAdditions)
</del><ins>+@implementation VideoControlsManagerTestWebView {
+ bool _isDoneQueryingControlledElementID;
+ NSString *_controlledElementID;
+}
</ins><span class="cx">
</span><span class="cx"> - (void)mouseDownAtPoint:(NSPoint)point {
</span><span class="cx"> [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]];
</span><span class="lines">@@ -133,78 +95,103 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)performAfterLoading:(dispatch_block_t)actions {
</span><del>- OnLoadMessageHandler *handler = [[OnLoadMessageHandler alloc] initWithWKWebView:self handler:actions];
</del><ins>+ MessageHandler *handler = [[MessageHandler alloc] initWithMessage:@"loaded" handler:actions];
</ins><span class="cx"> NSString *onloadScript = @"window.onload = function() { window.webkit.messageHandlers.onloadHandler.postMessage('loaded'); }";
</span><span class="cx"> WKUserScript *script = [[WKUserScript alloc] initWithSource:onloadScript injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:NO];
</span><del>- [[[self configuration] userContentController] addUserScript:script];
- [[[self configuration] userContentController] addScriptMessageHandler:handler name:@"onloadHandler"];
</del><ins>+
+ WKUserContentController* contentController = [[self configuration] userContentController];
+ [contentController addUserScript:script];
+ [contentController addScriptMessageHandler:handler name:@"onloadHandler"];
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+- (void)loadTestPageNamed:(NSString *)pageName
+{
+ NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:pageName withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+ [self loadRequest:request];
+}
+
+- (void)loadTestPageNamed:(NSString *)pageName andExpectControlsManager:(BOOL)expectControlsManager afterReceivingMessage:(NSString *)message
+{
+ __block bool doneWaiting = false;
+ [self performAfterReceivingMessage:message action:^ {
+ BOOL hasVideoForControlsManager = [self _hasActiveVideoForControlsManager];
+ if (expectControlsManager)
+ EXPECT_TRUE(hasVideoForControlsManager);
+ else
+ EXPECT_FALSE(hasVideoForControlsManager);
+ doneWaiting = true;
+ }];
+
+ [self loadTestPageNamed:pageName];
+ TestWebKitAPI::Util::run(&doneWaiting);
+}
+
+- (void)performAfterReceivingMessage:(NSString *)message action:(dispatch_block_t)action
+{
+ RetainPtr<MessageHandler> handler = adoptNS([[MessageHandler alloc] initWithMessage:message handler:action]);
+ [[[self configuration] userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"];
+}
+
+- (NSString *)controlledElementID
+{
+ _isDoneQueryingControlledElementID = false;
+ [self _requestControlledElementID];
+ TestWebKitAPI::Util::run(&_isDoneQueryingControlledElementID);
+ return _controlledElementID;
+}
+
+- (void)_handleControlledElementIDResponse:(NSString *)identifier
+{
+ _controlledElementID = [identifier copy];
+ _isDoneQueryingControlledElementID = true;
+}
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> namespace TestWebKitAPI {
</span><span class="cx">
</span><del>-TEST(VideoControlsManager, VideoControlsManagerSingleLargeVideo)
</del><ins>+RetainPtr<VideoControlsManagerTestWebView*> setUpWebViewForTestingVideoControlsManager(NSRect frame)
</ins><span class="cx"> {
</span><span class="cx"> RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
</span><span class="cx"> configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
</span><del>- 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:@"playing"]);
- [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"];
-
</del><ins>+ RetainPtr<VideoControlsManagerTestWebView> webView = adoptNS([[VideoControlsManagerTestWebView alloc] initWithFrame:frame configuration:configuration.get()]);
</ins><span class="cx"> RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
</span><span class="cx"> [[window contentView] addSubview:webView.get()];
</span><span class="cx">
</span><ins>+ return webView;
+}
+
+TEST(VideoControlsManager, VideoControlsManagerSingleLargeVideo)
+{
+ RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
+
</ins><span class="cx"> // A large video with audio should have a controls manager even if it is played via script like this video.
</span><span class="cx"> // So the expectation is YES.
</span><del>- [handler setExpectedToHaveControlsManager:YES];
- NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"large-video-with-audio" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
- [webView loadRequest:request];
-
- TestWebKitAPI::Util::run(&testedControlsManagerAfterPlaying);
- TestWebKitAPI::Util::run(&receivedScriptMessage);
</del><ins>+ [webView loadTestPageNamed:@"large-video-with-audio" andExpectControlsManager:YES afterReceivingMessage:@"playing"];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerSingleSmallVideo)
</span><span class="cx"> {
</span><del>- 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:@"playing"]);
- [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"];
</del><ins>+ RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
</ins><span class="cx">
</span><del>- RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
- [[window contentView] addSubview:webView.get()];
-
</del><span class="cx"> // A small video will not have a controls manager unless it started playing because of a user gesture. Since this
</span><span class="cx"> // video is started with a script, the expectation is NO.
</span><del>- [handler setExpectedToHaveControlsManager:NO];
- NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"video-with-audio" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
- [webView loadRequest:request];
-
- TestWebKitAPI::Util::run(&testedControlsManagerAfterPlaying);
- TestWebKitAPI::Util::run(&receivedScriptMessage);
</del><ins>+ [webView loadTestPageNamed:@"video-with-audio" andExpectControlsManager:NO afterReceivingMessage:@"playing"];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerMultipleVideosWithAudio)
</span><span class="cx"> {
</span><del>- 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()]);
</del><ins>+ RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
</ins><span class="cx">
</span><span class="cx"> __block BOOL didShowMediaControls;
</span><span class="cx"> __block bool isDoneLoading = false;
</span><span class="cx">
</span><del>- 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:^() {
</del><ins>+ [webView performAfterLoading:^ {
</ins><span class="cx"> didShowMediaControls = [webView _hasActiveVideoForControlsManager];
</span><span class="cx"> isDoneLoading = true;
</span><del>- }]);
- [[configuration userContentController] addScriptMessageHandler:onloadHandler.get() name:@"onloadHandler"];
</del><ins>+ }];
</ins><span class="cx">
</span><del>- NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"large-videos-with-audio" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
- [webView loadRequest:request];
</del><ins>+ [webView loadTestPageNamed:@"large-videos-with-audio"];
</ins><span class="cx">
</span><span class="cx"> TestWebKitAPI::Util::run(&isDoneLoading);
</span><span class="cx"> EXPECT_FALSE(didShowMediaControls);
</span><span class="lines">@@ -212,175 +199,157 @@
</span><span class="cx">
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerMultipleVideosWithAudioAndAutoplay)
</span><span class="cx"> {
</span><del>- 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()]);
</del><ins>+ RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
</ins><span class="cx">
</span><span class="cx"> __block BOOL didShowMediaControls;
</span><span class="cx"> __block bool isDoneLoading = false;
</span><span class="cx">
</span><del>- 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:^() {
</del><ins>+ [webView performAfterLoading:^ {
</ins><span class="cx"> didShowMediaControls = [webView _hasActiveVideoForControlsManager];
</span><span class="cx"> isDoneLoading = true;
</span><del>- }]);
- [[configuration userContentController] addScriptMessageHandler:onloadHandler.get() name:@"onloadHandler"];
</del><ins>+ }];
</ins><span class="cx">
</span><del>- NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"large-videos-with-audio-autoplay" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
- [webView loadRequest:request];
</del><ins>+ [webView loadTestPageNamed:@"large-videos-with-audio-autoplay"];
</ins><span class="cx">
</span><span class="cx"> TestWebKitAPI::Util::run(&isDoneLoading);
</span><span class="cx"> EXPECT_TRUE(didShowMediaControls);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-TEST(VideoControlsManager, VideoControlsManagerSingleSmallAutoplayingVideo)
</del><ins>+TEST(VideoControlsManager, VideoControlsManagerMultipleVideosScrollPausedVideoOutOfView)
</ins><span class="cx"> {
</span><del>- 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> playbackHandler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"paused"]);
- [[configuration userContentController] addScriptMessageHandler:playbackHandler.get() name:@"playingHandler"];
</del><ins>+ RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500));
</ins><span class="cx">
</span><del>- RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
- [[window contentView] addSubview:webView.get()];
</del><ins>+ [webView loadTestPageNamed:@"large-videos-paused-video-hides-controls" andExpectControlsManager:NO afterReceivingMessage:@"paused"];
+}
</ins><span class="cx">
</span><del>- RetainPtr<OnLoadMessageHandler> onloadHandler = adoptNS([[OnLoadMessageHandler alloc] initWithWKWebView:webView.get() handler:^() {
- [webView mouseDownAtPoint:NSMakePoint(50, 50)];
- }]);
- [[configuration userContentController] addScriptMessageHandler:onloadHandler.get() name:@"onloadHandler"];
</del><ins>+TEST(VideoControlsManager, VideoControlsManagerMultipleVideosScrollPlayingVideoWithSoundOutOfView)
+{
+ RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500));
</ins><span class="cx">
</span><del>- // 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];
</del><ins>+ [webView loadTestPageNamed:@"large-videos-playing-video-keeps-controls" andExpectControlsManager:YES afterReceivingMessage:@"playing"];
+}
</ins><span class="cx">
</span><del>- TestWebKitAPI::Util::run(&testedControlsManagerAfterPlaying);
- TestWebKitAPI::Util::run(&receivedScriptMessage);
</del><ins>+TEST(VideoControlsManager, VideoControlsManagerMultipleVideosScrollPlayingMutedVideoOutOfView)
+{
+ RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500));
+
+ [webView loadTestPageNamed:@"large-videos-playing-muted-video-hides-controls" andExpectControlsManager:NO afterReceivingMessage:@"playing"];
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoSeeksAfterEnding)
</del><ins>+TEST(VideoControlsManager, VideoControlsManagerMultipleVideosShowControlsForLastInteractedVideo)
</ins><span class="cx"> {
</span><del>- 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"];
</del><ins>+ RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 800, 600));
+ NSPoint clickPoint = NSMakePoint(400, 300);
</ins><span class="cx">
</span><del>- RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
- [[window contentView] addSubview:webView.get()];
</del><ins>+ [webView performAfterLoading:^ {
+ [webView mouseDownAtPoint:clickPoint];
+ }];
</ins><span class="cx">
</span><del>- // 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];
</del><ins>+ __block bool firstVideoPaused = false;
+ __block bool secondVideoPaused = false;
+ [webView performAfterReceivingMessage:@"paused" action:^ {
+ NSString *controlledElementID = [webView controlledElementID];
+ if (firstVideoPaused) {
+ secondVideoPaused = true;
+ EXPECT_TRUE([controlledElementID isEqualToString:@"second"]);
+ } else {
+ [webView mouseDownAtPoint:clickPoint];
+ EXPECT_TRUE([controlledElementID isEqualToString:@"first"]);
+ }
+ firstVideoPaused = true;
+ }];
</ins><span class="cx">
</span><del>- TestWebKitAPI::Util::run(&testedControlsManagerAfterPlaying);
- TestWebKitAPI::Util::run(&receivedScriptMessage);
</del><ins>+ [webView loadTestPageNamed:@"large-videos-autoplaying-click-to-pause"];
+ TestWebKitAPI::Util::run(&secondVideoPaused);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoSeeksAndPlaysAfterEnding)
</del><ins>+TEST(VideoControlsManager, VideoControlsManagerMultipleVideosSwitchControlledVideoWhenScrolling)
</ins><span class="cx"> {
</span><del>- 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"];
</del><ins>+ RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 800, 600));
</ins><span class="cx">
</span><del>- RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
- [[window contentView] addSubview:webView.get()];
</del><ins>+ __block bool scrolledSecondVideoIntoView = false;
+ [webView loadTestPageNamed:@"large-videos-autoplaying-scroll-to-video"];
+ [webView performAfterReceivingMessage:@"scrolled" action:^ {
+ scrolledSecondVideoIntoView = true;
+ }];
</ins><span class="cx">
</span><del>- // 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];
</del><ins>+ TestWebKitAPI::Util::run(&scrolledSecondVideoIntoView);
+ EXPECT_TRUE([[webView controlledElementID] isEqualToString:@"second"]);
+}
</ins><span class="cx">
</span><del>- TestWebKitAPI::Util::run(&testedControlsManagerAfterPlaying);
- TestWebKitAPI::Util::run(&receivedScriptMessage);
</del><ins>+TEST(VideoControlsManager, VideoControlsManagerMultipleVideosScrollOnlyLargeVideoOutOfView)
+{
+ RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500));
+
+ [webView loadTestPageNamed:@"large-video-playing-scroll-away" andExpectControlsManager:YES afterReceivingMessage:@"scrolled"];
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+TEST(VideoControlsManager, VideoControlsManagerSingleSmallAutoplayingVideo)
+{
+ RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
+
+ [webView performAfterLoading:^ {
+ [webView mouseDownAtPoint:NSMakePoint(50, 50)];
+ }];
+
+ [webView loadTestPageNamed:@"autoplaying-video-with-audio" andExpectControlsManager:YES afterReceivingMessage:@"paused"];
+}
+
+TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoSeeksAfterEnding)
+{
+ RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
+
+ // Since the video has ended, the expectation is NO even if the page programmatically seeks to the beginning.
+ [webView loadTestPageNamed:@"large-video-seek-after-ending" andExpectControlsManager:NO afterReceivingMessage:@"ended"];
+}
+
+TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoSeeksAndPlaysAfterEnding)
+{
+ RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
+
+ // Since the video is still playing, the expectation is YES even if the video has ended once.
+ [webView loadTestPageNamed:@"large-video-seek-to-beginning-and-play-after-ending" andExpectControlsManager:YES afterReceivingMessage:@"replaying"];
+}
+
</ins><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoAfterSeekingToEnd)
</span><span class="cx"> {
</span><del>- 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"];
</del><ins>+ RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
</ins><span class="cx">
</span><del>- 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:^() {
</del><ins>+ [webView performAfterLoading:^ {
</ins><span class="cx"> [webView mouseDownAtPoint:NSMakePoint(50, 50)];
</span><del>- }]);
- [[configuration userContentController] addScriptMessageHandler:onloadHandler.get() name:@"onloadHandler"];
</del><ins>+ }];
</ins><span class="cx">
</span><span class="cx"> // We expect there to be media controls, since this is a user gestured seek to the end.
</span><span class="cx"> // This is akin to seeking to the end by scrubbing in the controls.
</span><del>- [handler setExpectedToHaveControlsManager:YES];
- 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);
</del><ins>+ [webView loadTestPageNamed:@"large-video-hides-controls-after-seek-to-end" andExpectControlsManager:YES afterReceivingMessage:@"ended"];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerSingleLargeVideoWithoutAudio)
</span><span class="cx"> {
</span><del>- 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:@"playing"]);
- [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"];
</del><ins>+ RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
</ins><span class="cx">
</span><del>- RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
- [[window contentView] addSubview:webView.get()];
-
</del><span class="cx"> // A large video with no audio will not have a controls manager unless it started playing because of a user gesture. Since this
</span><span class="cx"> // video is started with a script, the expectation is NO.
</span><del>- [handler setExpectedToHaveControlsManager:NO];
- NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"large-video-without-audio" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
- [webView loadRequest:request];
-
- TestWebKitAPI::Util::run(&testedControlsManagerAfterPlaying);
- TestWebKitAPI::Util::run(&receivedScriptMessage);
</del><ins>+ [webView loadTestPageNamed:@"large-video-without-audio" andExpectControlsManager:NO afterReceivingMessage:@"playing"];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerAudioElementStartedWithScript)
</span><span class="cx"> {
</span><del>- 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:@"playing"]);
- [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"];
</del><ins>+ RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
</ins><span class="cx">
</span><del>- RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
- [[window contentView] addSubview:webView.get()];
-
</del><span class="cx"> // An audio element MUST be started with a user gesture in order to have a controls manager, so the expectation is NO.
</span><del>- [handler setExpectedToHaveControlsManager:NO];
- NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"audio-only" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
- [webView loadRequest:request];
-
- TestWebKitAPI::Util::run(&testedControlsManagerAfterPlaying);
- TestWebKitAPI::Util::run(&receivedScriptMessage);
</del><ins>+ [webView loadTestPageNamed:@"audio-only" andExpectControlsManager:NO afterReceivingMessage:@"playing"];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerTearsDownMediaControlsOnDealloc)
</span><span class="cx"> {
</span><del>- 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()]);
</del><ins>+ RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
</ins><span class="cx">
</span><del>- RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
- [[window contentView] addSubview:webView.get()];
-
</del><span class="cx"> NSURL *urlOfVideo = [[NSBundle mainBundle] URLForResource:@"video-with-audio" withExtension:@"mp4" subdirectory:@"TestWebKitAPI.resources"];
</span><span class="cx"> [webView loadFileURL:urlOfVideo allowingReadAccessToURL:[urlOfVideo URLByDeletingLastPathComponent]];
</span><span class="cx">
</span><span class="cx"> __block bool finishedTest = false;
</span><del>- [webView performAfterLoading:^()
- {
</del><ins>+ [webView performAfterLoading:^ {
</ins><span class="cx"> // Verify that we tear down the media controls properly, such that we don't crash when the web view is released.
</span><span class="cx"> if ([webView respondsToSelector:@selector(_interactWithMediaControlsForTesting)])
</span><span class="cx"> [webView _interactWithMediaControlsForTesting];
</span><span class="lines">@@ -394,16 +363,10 @@
</span><span class="cx">
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerSmallVideoInMediaDocument)
</span><span class="cx"> {
</span><del>- 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<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
- [[window contentView] addSubview:webView.get()];
-
</del><ins>+ RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
+
</ins><span class="cx"> __block bool finishedLoad = false;
</span><del>- [webView performAfterLoading:^()
- {
</del><ins>+ [webView performAfterLoading:^ {
</ins><span class="cx"> finishedLoad = true;
</span><span class="cx"> }];
</span><span class="cx">
</span><span class="lines">@@ -418,40 +381,16 @@
</span><span class="cx">
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerLongSkinnyVideoInWideMainFrame)
</span><span class="cx"> {
</span><del>- RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
- configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
- RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 1600, 800) configuration:configuration.get()]);
- RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
- [[window contentView] addSubview:webView.get()];
</del><ins>+ RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 1600, 800));
</ins><span class="cx">
</span><del>- RetainPtr<MediaPlaybackMessageHandler> handler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"playing"]);
- [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"];
- [handler setExpectedToHaveControlsManager:NO];
-
- NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"skinny-autoplaying-video-with-audio" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
- [webView loadRequest:request];
-
- TestWebKitAPI::Util::run(&testedControlsManagerAfterPlaying);
- TestWebKitAPI::Util::run(&receivedScriptMessage);
</del><ins>+ [webView loadTestPageNamed:@"skinny-autoplaying-video-with-audio" andExpectControlsManager:NO afterReceivingMessage:@"playing"];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerFullSizeVideoInWideMainFrame)
</span><span class="cx"> {
</span><del>- RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
- configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
- RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 1600, 800) configuration:configuration.get()]);
- RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
- [[window contentView] addSubview:webView.get()];
</del><ins>+ RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 1600, 800));
</ins><span class="cx">
</span><del>- RetainPtr<MediaPlaybackMessageHandler> handler = adoptNS([[MediaPlaybackMessageHandler alloc] initWithWKWebView:webView.get() finalMessageString:@"playing"]);
- [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"];
- [handler setExpectedToHaveControlsManager:YES];
-
- NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"full-size-autoplaying-video-with-audio" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
- [webView loadRequest:request];
-
- TestWebKitAPI::Util::run(&testedControlsManagerAfterPlaying);
- TestWebKitAPI::Util::run(&receivedScriptMessage);
</del><ins>+ [webView loadTestPageNamed:@"full-size-autoplaying-video-with-audio" andExpectControlsManager:YES afterReceivingMessage:@"playing"];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace TestWebKitAPI
</span></span></pre></div>
<a id="branchessafari602branchToolsTestWebKitAPITestsWebKit2Cocoalargevideoplayingscrollawayhtml"></a>
<div class="addfile"><h4>Added: branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-playing-scroll-away.html (0 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-playing-scroll-away.html         (rev 0)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-playing-scroll-away.html        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+<!DOCTYPE html>
+<html>
+ <head>
+ <style>
+ video {
+ width: 480px;
+ height: 320px;
+ }
+ div {
+ margin-top: 5000px;
+ }
+ </style>
+ <script>
+ function handleLoaded() {
+ document.querySelector("div").scrollIntoView();
+ setTimeout(function() {
+ window.webkit.messageHandlers.playingHandler.postMessage("scrolled");
+ }, 0);
+ }
+ </script>
+ </head>
+ <body onload=handleLoaded()>
+ <video autoplay loop id="first" src="large-video-with-audio.mp4"></video>
+ <br>
+ <div>hello world!</div>
+ </body>
+<html>
</ins></span></pre></div>
<a id="branchessafari602branchToolsTestWebKitAPITestsWebKit2Cocoalargevideosautoplayingclicktopausehtml"></a>
<div class="addfile"><h4>Added: branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-click-to-pause.html (0 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-click-to-pause.html         (rev 0)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-click-to-pause.html        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+<!DOCTYPE html>
+<html>
+ <head>
+ <style>
+ video {
+ width: 480px;
+ height: 320px;
+ }
+ </style>
+ <script>
+ var isFirstClick = true;
+ function handleMouseDown() {
+ document.querySelector(isFirstClick ? "#first" : "#second").pause();
+ isFirstClick = false;
+ }
+
+ function handleFirstPause() {
+ setTimeout(function() {
+ try {
+ window.webkit.messageHandlers.playingHandler.postMessage("paused");
+ } catch(e) { }
+ }, 0);
+ }
+
+ function handleSecondPause() {
+ setTimeout(function() {
+ try {
+ window.webkit.messageHandlers.playingHandler.postMessage("paused");
+ } catch(e) { }
+ }, 0);
+ }
+ </script>
+ </head>
+ <body onmousedown=handleMouseDown()>
+ <video autoplay loop id="first" src="large-video-with-audio.mp4" onpause=handleFirstPause()></video>
+ <video autoplay loop id="second" src="large-video-with-audio.mp4" onpause=handleSecondPause()></video>
+ </body>
+<html>
</ins></span></pre></div>
<a id="branchessafari602branchToolsTestWebKitAPITestsWebKit2Cocoalargevideosautoplayingscrolltovideohtml"></a>
<div class="addfile"><h4>Added: branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-scroll-to-video.html (0 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-scroll-to-video.html         (rev 0)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-scroll-to-video.html        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+<!DOCTYPE html>
+<html>
+ <head>
+ <style>
+ video {
+ width: 480px;
+ height: 320px;
+ }
+ #second {
+ margin-top: 5000px;
+ }
+ </style>
+ <script>
+ function handleLoaded() {
+ document.querySelector("#second").scrollIntoView();
+ setTimeout(function() {
+ window.webkit.messageHandlers.playingHandler.postMessage("scrolled");
+ }, 0);
+ }
+ </script>
+ </head>
+ <body onload=handleLoaded()>
+ <video autoplay loop id="first" src="large-video-with-audio.mp4"></video>
+ <br>
+ <video autoplay loop id="second" src="large-video-with-audio.mp4"></video>
+ </body>
+<html>
</ins></span></pre></div>
<a id="branchessafari602branchToolsTestWebKitAPITestsWebKit2Cocoalargevideospausedvideohidescontrolshtml"></a>
<div class="addfile"><h4>Added: branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-paused-video-hides-controls.html (0 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-paused-video-hides-controls.html         (rev 0)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-paused-video-hides-controls.html        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -0,0 +1,30 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<style>
+ video {
+ width: 480px;
+ height: 320px;
+ }
+ #bar {
+ margin-top: 5000px;
+ }
+</style>
+<script>
+ function handleLoaded() {
+ document.querySelector("#bar").scrollIntoView();
+ document.querySelector("#foo").pause();
+ }
+ function handlePaused() {
+ setTimeout(function() {
+ try {
+ window.webkit.messageHandlers.playingHandler.postMessage("paused");
+ } catch(e) { }
+ }, 0);
+ }
+</script>
+<body onload=handleLoaded()>
+ <video autoplay loop id="foo" onpause=handlePaused()><source src="large-video-with-audio.mp4"></video>
+ <br>
+ <video id="bar"><source src="large-video-with-audio.mp4"></video>
+</body>
+<html>
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="branchessafari602branchToolsTestWebKitAPITestsWebKit2Cocoalargevideosplayingmutedvideohidescontrolshtml"></a>
<div class="addfile"><h4>Added: branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-muted-video-hides-controls.html (0 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-muted-video-hides-controls.html         (rev 0)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-muted-video-hides-controls.html        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -0,0 +1,28 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<style>
+ video {
+ width: 480px;
+ height: 320px;
+ }
+ #bar {
+ margin-top: 5000px;
+ }
+</style>
+<script>
+ function handleLoaded() {
+ document.querySelector("#foo").muted = true;
+ document.querySelector("#bar").scrollIntoView();
+ setTimeout(function() {
+ try {
+ window.webkit.messageHandlers.playingHandler.postMessage("playing");
+ } catch(e) { }
+ }, 0);
+ }
+</script>
+<body onload=handleLoaded()>
+ <video autoplay loop id="foo"><source src="large-video-with-audio.mp4"></video>
+ <br>
+ <video id="bar"><source src="large-video-with-audio.mp4"></video>
+</body>
+<html>
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="branchessafari602branchToolsTestWebKitAPITestsWebKit2Cocoalargevideosplayingvideokeepscontrolshtml"></a>
<div class="addfile"><h4>Added: branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-video-keeps-controls.html (0 => 205705)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-video-keeps-controls.html         (rev 0)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-video-keeps-controls.html        2016-09-09 08:41:46 UTC (rev 205705)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<style>
+ video {
+ width: 480px;
+ height: 320px;
+ }
+ #bar {
+ margin-top: 5000px;
+ }
+</style>
+<script>
+ function handleLoaded() {
+ document.querySelector("#bar").scrollIntoView();
+ setTimeout(function() {
+ try {
+ window.webkit.messageHandlers.playingHandler.postMessage("playing");
+ } catch(e) { }
+ }, 0);
+ }
+</script>
+<body onload=handleLoaded()>
+ <video autoplay loop id="foo"><source src="large-video-with-audio.mp4"></video>
+ <br>
+ <video id="bar"><source src="large-video-with-audio.mp4"></video>
+</body>
+<html>
</ins><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>
</body>
</html>