<!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>[205417] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/205417">205417</a></dd>
<dt>Author</dt> <dd>wenson_hsieh@apple.com</dd>
<dt>Date</dt> <dd>2016-09-03 22:45:10 -0700 (Sat, 03 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Media controls behave strangely when videos mute from within a playing handler
https://bugs.webkit.org/show_bug.cgi?id=161559
&lt;rdar://problem/28018438&gt;

Reviewed by Darin Adler.

Source/WebCore:

Defer showing media controls until after the media element has fired its onplaying handler. This handles cases
where videos that autoplay may initially meet the criteria for main content, but once the video begins to play,
the page may change the media in some way (e.g. muting) that makes the video no longer main content. This causes
media controls to flicker in and out.

These changes are covered by existing unit tests, which have been refactored to check media controller state
after all autoplaying videos have begun playing. Also adds an additional unit test.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::notifyAboutPlaying):
(WebCore::HTMLMediaElement::hasEverNotifiedAboutPlaying):
* html/HTMLMediaElement.h:
* html/MediaElementSession.cpp:
(WebCore::MediaElementSession::canShowControlsManager):

Tools:

Accounts for changes when determining whether or not to show media controls for autoplaying videos that have not
begun playing yet. Rather than check for a controlled media element upon page load, we force tests to wait until
all autoplaying videos have actually begun playing. This extends to tests that involve interaction, such as
clicking or scrolling.

* TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm:
(-[VideoControlsManagerTestWebView callJavascriptFunction:]):
(-[VideoControlsManagerTestWebView expectControlsManager:afterReceivingMessage:]):
(-[VideoControlsManagerTestWebView performAfterReceivingMessage:action:]):
(-[VideoControlsManagerTestWebView waitForPageToLoadWithAutoplayingVideos:]):
(TestWebKitAPI::TEST):
(-[VideoControlsManagerTestWebView loadTestPageNamed:andExpectControlsManager:afterReceivingMessage:]): Deleted.
* TestWebKitAPI/Tests/WebKit2Cocoa/autoplaying-video-with-audio.html:
* TestWebKitAPI/Tests/WebKit2Cocoa/large-video-hides-controls-after-seek-to-end.html:
* TestWebKitAPI/Tests/WebKit2Cocoa/large-video-playing-scroll-away.html:
* TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-click-to-pause.html:
* TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-scroll-to-video.html:
* TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-paused-video-hides-controls.html:
* TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-muted-video-hides-controls.html:
* TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-video-keeps-controls.html:
* TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-with-audio-autoplay.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementcpp">trunk/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementh">trunk/Source/WebCore/html/HTMLMediaElement.h</a></li>
<li><a href="#trunkSourceWebCorehtmlMediaElementSessioncpp">trunk/Source/WebCore/html/MediaElementSession.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2CocoaVideoControlsManagermm">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2Cocoaautoplayingvideowithaudiohtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/autoplaying-video-with-audio.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2Cocoalargevideohidescontrolsafterseektoendhtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-hides-controls-after-seek-to-end.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2Cocoalargevideoplayingscrollawayhtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-playing-scroll-away.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2Cocoalargevideosautoplayingclicktopausehtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-click-to-pause.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2Cocoalargevideosautoplayingscrolltovideohtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-scroll-to-video.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2Cocoalargevideospausedvideohidescontrolshtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-paused-video-hides-controls.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2Cocoalargevideosplayingmutedvideohidescontrolshtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-muted-video-hides-controls.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2Cocoalargevideosplayingvideokeepscontrolshtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-video-keeps-controls.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2Cocoalargevideoswithaudioautoplayhtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-with-audio-autoplay.html</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2Cocoalargevideomutesonplayinghtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-mutes-onplaying.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (205416 => 205417)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-04 05:09:28 UTC (rev 205416)
+++ trunk/Source/WebCore/ChangeLog        2016-09-04 05:45:10 UTC (rev 205417)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2016-09-03  Wenson Hsieh  &lt;wenson_hsieh@apple.com&gt;
+
+        Media controls behave strangely when videos mute from within a playing handler
+        https://bugs.webkit.org/show_bug.cgi?id=161559
+        &lt;rdar://problem/28018438&gt;
+
+        Reviewed by Darin Adler.
+
+        Defer showing media controls until after the media element has fired its onplaying handler. This handles cases
+        where videos that autoplay may initially meet the criteria for main content, but once the video begins to play,
+        the page may change the media in some way (e.g. muting) that makes the video no longer main content. This causes
+        media controls to flicker in and out.
+
+        These changes are covered by existing unit tests, which have been refactored to check media controller state
+        after all autoplaying videos have begun playing. Also adds an additional unit test.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::notifyAboutPlaying):
+        (WebCore::HTMLMediaElement::hasEverNotifiedAboutPlaying):
+        * html/HTMLMediaElement.h:
+        * html/MediaElementSession.cpp:
+        (WebCore::MediaElementSession::canShowControlsManager):
+
</ins><span class="cx"> 2016-09-03  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Update the semantics of defined-ness of custom elements per spec changes
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (205416 => 205417)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp        2016-09-04 05:09:28 UTC (rev 205416)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp        2016-09-04 05:45:10 UTC (rev 205417)
</span><span class="lines">@@ -481,6 +481,7 @@
</span><span class="cx">     , m_elementIsHidden(document.hidden())
</span><span class="cx">     , m_creatingControls(false)
</span><span class="cx">     , m_receivedLayoutSizeChanged(false)
</span><ins>+    , m_hasEverNotifiedAboutPlaying(false)
</ins><span class="cx"> #if ENABLE(MEDIA_CONTROLS_SCRIPT)
</span><span class="cx">     , m_mediaControlsDependOnPageScaleFactor(false)
</span><span class="cx">     , m_haveSetUpCaptionContainer(false)
</span><span class="lines">@@ -1014,8 +1015,16 @@
</span><span class="cx"> {
</span><span class="cx">     dispatchEvent(Event::create(eventNames().playingEvent, false, true));
</span><span class="cx">     resolvePendingPlayPromises();
</span><ins>+
+    m_hasEverNotifiedAboutPlaying = true;
+    scheduleUpdatePlaybackControlsManager();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool HTMLMediaElement::hasEverNotifiedAboutPlaying() const
+{
+    return m_hasEverNotifiedAboutPlaying;
+}
+
</ins><span class="cx"> void HTMLMediaElement::pendingActionTimerFired()
</span><span class="cx"> {
</span><span class="cx">     Ref&lt;HTMLMediaElement&gt; protectedThis(*this); // loadNextSourceChild may fire 'beforeload', which can make arbitrary DOM mutations.
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (205416 => 205417)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.h        2016-09-04 05:09:28 UTC (rev 205416)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h        2016-09-04 05:45:10 UTC (rev 205417)
</span><span class="lines">@@ -470,6 +470,7 @@
</span><span class="cx"> 
</span><span class="cx">     void resetPlaybackSessionState();
</span><span class="cx">     bool isVisibleInViewport() const;
</span><ins>+    bool hasEverNotifiedAboutPlaying() const;
</ins><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     HTMLMediaElement(const QualifiedName&amp;, Document&amp;, bool createdByParser);
</span><span class="lines">@@ -943,6 +944,7 @@
</span><span class="cx">     bool m_elementIsHidden : 1;
</span><span class="cx">     bool m_creatingControls : 1;
</span><span class="cx">     bool m_receivedLayoutSizeChanged : 1;
</span><ins>+    bool m_hasEverNotifiedAboutPlaying : 1;
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(MEDIA_CONTROLS_SCRIPT)
</span><span class="cx">     bool m_mediaControlsDependOnPageScaleFactor : 1;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlMediaElementSessioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/MediaElementSession.cpp (205416 => 205417)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/MediaElementSession.cpp        2016-09-04 05:09:28 UTC (rev 205416)
+++ trunk/Source/WebCore/html/MediaElementSession.cpp        2016-09-04 05:45:10 UTC (rev 205417)
</span><span class="lines">@@ -228,6 +228,11 @@
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if (m_element.document().isMediaDocument()) {
+        LOG(Media, &quot;MediaElementSession::canShowControlsManager - returning TRUE: Is media document&quot;);
+        return true;
+    }
+
</ins><span class="cx">     if (m_element.document().activeDOMObjectsAreSuspended()) {
</span><span class="cx">         LOG(Media, &quot;MediaElementSession::canShowControlsManager - returning FALSE: activeDOMObjectsAreSuspended()&quot;);
</span><span class="cx">         return false;
</span><span class="lines">@@ -253,6 +258,11 @@
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if (!m_element.hasEverNotifiedAboutPlaying()) {
+        LOG(Media, &quot;MediaElementSession::canShowControlsManager - returning FALSE: Hasn't fired playing notification&quot;);
+        return false;
+    }
+
</ins><span class="cx">     if (m_element.isVideo()) {
</span><span class="cx">         if (!m_element.renderer()) {
</span><span class="cx">             LOG(Media, &quot;MediaElementSession::canShowControlsManager - returning FALSE: No renderer&quot;);
</span><span class="lines">@@ -259,11 +269,6 @@
</span><span class="cx">             return false;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (m_element.document().isMediaDocument()) {
-            LOG(Media, &quot;MediaElementSession::canShowControlsManager - returning TRUE: Is media document&quot;);
-            return true;
-        }
-
</del><span class="cx">         if (!m_element.hasVideo()) {
</span><span class="cx">             LOG(Media, &quot;MediaElementSession::canShowControlsManager - returning FALSE: No video&quot;);
</span><span class="cx">             return false;
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (205416 => 205417)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-09-04 05:09:28 UTC (rev 205416)
+++ trunk/Tools/ChangeLog        2016-09-04 05:45:10 UTC (rev 205417)
</span><span class="lines">@@ -1,5 +1,35 @@
</span><span class="cx"> 2016-09-03  Wenson Hsieh  &lt;wenson_hsieh@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Media controls behave strangely when videos mute from within a playing handler
+        https://bugs.webkit.org/show_bug.cgi?id=161559
+        &lt;rdar://problem/28018438&gt;
+
+        Reviewed by Darin Adler.
+
+        Accounts for changes when determining whether or not to show media controls for autoplaying videos that have not
+        begun playing yet. Rather than check for a controlled media element upon page load, we force tests to wait until
+        all autoplaying videos have actually begun playing. This extends to tests that involve interaction, such as
+        clicking or scrolling.
+
+        * TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm:
+        (-[VideoControlsManagerTestWebView callJavascriptFunction:]):
+        (-[VideoControlsManagerTestWebView expectControlsManager:afterReceivingMessage:]):
+        (-[VideoControlsManagerTestWebView performAfterReceivingMessage:action:]):
+        (-[VideoControlsManagerTestWebView waitForPageToLoadWithAutoplayingVideos:]):
+        (TestWebKitAPI::TEST):
+        (-[VideoControlsManagerTestWebView loadTestPageNamed:andExpectControlsManager:afterReceivingMessage:]): Deleted.
+        * TestWebKitAPI/Tests/WebKit2Cocoa/autoplaying-video-with-audio.html:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/large-video-hides-controls-after-seek-to-end.html:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/large-video-playing-scroll-away.html:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-click-to-pause.html:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-scroll-to-video.html:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-paused-video-hides-controls.html:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-muted-video-hides-controls.html:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-video-keeps-controls.html:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-with-audio-autoplay.html:
+
+2016-09-03  Wenson Hsieh  &lt;wenson_hsieh@apple.com&gt;
+
</ins><span class="cx">         Refactor the heuristic for showing media controls to take all media sessions into account
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=161503
</span><span class="cx">         &lt;rdar://problem/28033783&gt;
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (205416 => 205417)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-09-04 05:09:28 UTC (rev 205416)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-09-04 05:45:10 UTC (rev 205417)
</span><span class="lines">@@ -64,6 +64,7 @@
</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>+                2E54F40D1D7BC84200921ADF /* large-video-mutes-onplaying.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E54F40C1D7BC83900921ADF /* large-video-mutes-onplaying.html */; };
</ins><span class="cx">                 2E691AEA1D78B53600129407 /* large-videos-paused-video-hides-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E691AE81D78B52B00129407 /* large-videos-paused-video-hides-controls.html */; };
</span><span class="cx">                 2E691AEB1D78B53600129407 /* large-videos-playing-video-keeps-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E691AE91D78B52B00129407 /* large-videos-playing-video-keeps-controls.html */; };
</span><span class="cx">                 2E691AED1D78B91000129407 /* large-videos-playing-muted-video-hides-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E691AEC1D78B90200129407 /* large-videos-playing-muted-video-hides-controls.html */; };
</span><span class="lines">@@ -526,6 +527,7 @@
</span><span class="cx">                         dstPath = TestWebKitAPI.resources;
</span><span class="cx">                         dstSubfolderSpec = 7;
</span><span class="cx">                         files = (
</span><ins>+                                2E54F40D1D7BC84200921ADF /* large-video-mutes-onplaying.html in Copy Resources */,
</ins><span class="cx">                                 2E691AF31D79E75E00129407 /* large-video-playing-scroll-away.html in Copy Resources */,
</span><span class="cx">                                 2E691AF11D79E51A00129407 /* large-videos-autoplaying-scroll-to-video.html in Copy Resources */,
</span><span class="cx">                                 2E691AEF1D79DE8400129407 /* large-videos-autoplaying-click-to-pause.html in Copy Resources */,
</span><span class="lines">@@ -755,6 +757,7 @@
</span><span class="cx">                 2E1DFDEC1D42A41C00714A00 /* large-videos-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;large-videos-with-audio.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2E1DFDEE1D42A6EB00714A00 /* large-videos-with-audio-autoplay.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;large-videos-with-audio-autoplay.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2E1DFDF01D42E14400714A00 /* large-video-seek-to-beginning-and-play-after-ending.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;large-video-seek-to-beginning-and-play-after-ending.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                2E54F40C1D7BC83900921ADF /* large-video-mutes-onplaying.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;large-video-mutes-onplaying.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 2E691AE81D78B52B00129407 /* large-videos-paused-video-hides-controls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;large-videos-paused-video-hides-controls.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2E691AE91D78B52B00129407 /* large-videos-playing-video-keeps-controls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;large-videos-playing-video-keeps-controls.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2E691AEC1D78B90200129407 /* large-videos-playing-muted-video-hides-controls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;large-videos-playing-muted-video-hides-controls.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -1418,6 +1421,7 @@
</span><span class="cx">                 A16F66B81C40E9E100BD4D24 /* Resources */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                2E54F40C1D7BC83900921ADF /* large-video-mutes-onplaying.html */,
</ins><span class="cx">                                 2E691AF21D79E75400129407 /* large-video-playing-scroll-away.html */,
</span><span class="cx">                                 2E691AF01D79E51400129407 /* large-videos-autoplaying-scroll-to-video.html */,
</span><span class="cx">                                 2E691AEE1D79DE6F00129407 /* large-videos-autoplaying-click-to-pause.html */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2CocoaVideoControlsManagermm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm (205416 => 205417)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm        2016-09-04 05:09:28 UTC (rev 205416)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm        2016-09-04 05:45:10 UTC (rev 205417)
</span><span class="lines">@@ -43,17 +43,14 @@
</span><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span><del>-@interface MessageHandler : NSObject &lt;WKScriptMessageHandler&gt; {
</del><ins>+@interface MessageHandler : NSObject &lt;WKScriptMessageHandler&gt;
+@end
+
+@implementation MessageHandler {
</ins><span class="cx">     dispatch_block_t _handler;
</span><span class="cx">     NSString *_message;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (instancetype)initWithMessage:(NSString *)message handler:(dispatch_block_t)handler;
-
-@end
-
-@implementation MessageHandler
-
</del><span class="cx"> - (instancetype)initWithMessage:(NSString *)message handler:(dispatch_block_t)handler
</span><span class="cx"> {
</span><span class="cx">     if (!(self = [super init]))
</span><span class="lines">@@ -74,15 +71,6 @@
</span><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> @interface VideoControlsManagerTestWebView : WKWebView
</span><del>-
-- (void)mouseDownAtPoint:(NSPoint)point;
-- (void)performAfterLoading:(dispatch_block_t)actions;
-- (void)loadTestPageNamed:(NSString *)pageName;
-- (void)loadTestPageNamed:(NSString *)pageName andExpectControlsManager:(BOOL)expectControlsManager afterReceivingMessage:(NSString *)message;
-- (void)performAfterReceivingMessage:(NSString *)message action:(dispatch_block_t)action;
-
-@property (nonatomic, readonly) NSString *controlledElementID;
-
</del><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> @implementation VideoControlsManagerTestWebView {
</span><span class="lines">@@ -104,6 +92,12 @@
</span><span class="cx">     [contentController addScriptMessageHandler:handler name:@&quot;onloadHandler&quot;];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)callJavascriptFunction:(NSString *)functionName
+{
+    NSString *command = [NSString stringWithFormat:@&quot;%@()&quot;, functionName];
+    [self evaluateJavaScript:command completionHandler:nil];
+}
+
</ins><span class="cx"> - (void)loadTestPageNamed:(NSString *)pageName
</span><span class="cx"> {
</span><span class="cx">     NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:pageName withExtension:@&quot;html&quot; subdirectory:@&quot;TestWebKitAPI.resources&quot;]];
</span><span class="lines">@@ -110,7 +104,7 @@
</span><span class="cx">     [self loadRequest:request];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)loadTestPageNamed:(NSString *)pageName andExpectControlsManager:(BOOL)expectControlsManager afterReceivingMessage:(NSString *)message
</del><ins>+- (void)expectControlsManager:(BOOL)expectControlsManager afterReceivingMessage:(NSString *)message
</ins><span class="cx"> {
</span><span class="cx">     __block bool doneWaiting = false;
</span><span class="cx">     [self performAfterReceivingMessage:message action:^ {
</span><span class="lines">@@ -122,7 +116,6 @@
</span><span class="cx">         doneWaiting = true;
</span><span class="cx">     }];
</span><span class="cx"> 
</span><del>-    [self loadTestPageNamed:pageName];
</del><span class="cx">     TestWebKitAPI::Util::run(&amp;doneWaiting);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -129,9 +122,35 @@
</span><span class="cx"> - (void)performAfterReceivingMessage:(NSString *)message action:(dispatch_block_t)action
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;MessageHandler&gt; handler = adoptNS([[MessageHandler alloc] initWithMessage:message handler:action]);
</span><del>-    [[[self configuration] userContentController] addScriptMessageHandler:handler.get() name:@&quot;playingHandler&quot;];
</del><ins>+    WKUserContentController* contentController = [[self configuration] userContentController];
+    [contentController removeScriptMessageHandlerForName:@&quot;playingHandler&quot;];
+    [contentController addScriptMessageHandler:handler.get() name:@&quot;playingHandler&quot;];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)waitForPageToLoadWithAutoplayingVideos:(int)numberOfAutoplayingVideos
+{
+    __block int remainingAutoplayedCount = numberOfAutoplayingVideos;
+    __block bool autoplayingIsFinished = !numberOfAutoplayingVideos;
+    __block bool pageHasLoaded = false;
+
+    [self performAfterLoading:^()
+    {
+        pageHasLoaded = true;
+    }];
+
+    if (numberOfAutoplayingVideos) {
+        [self performAfterReceivingMessage:@&quot;autoplayed&quot; action:^()
+        {
+            remainingAutoplayedCount--;
+            if (remainingAutoplayedCount &lt;= 0)
+                autoplayingIsFinished = true;
+        }];
+    }
+
+    TestWebKitAPI::Util::run(&amp;pageHasLoaded);
+    TestWebKitAPI::Util::run(&amp;autoplayingIsFinished);
+}
+
</ins><span class="cx"> - (NSString *)controlledElementID
</span><span class="cx"> {
</span><span class="cx">     _isDoneQueryingControlledElementID = false;
</span><span class="lines">@@ -167,7 +186,8 @@
</span><span class="cx"> 
</span><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>-    [webView loadTestPageNamed:@&quot;large-video-with-audio&quot; andExpectControlsManager:YES afterReceivingMessage:@&quot;playing&quot;];
</del><ins>+    [webView loadTestPageNamed:@&quot;large-video-with-audio&quot;];
+    [webView expectControlsManager:YES afterReceivingMessage:@&quot;playing&quot;];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerSingleSmallVideo)
</span><span class="lines">@@ -176,7 +196,8 @@
</span><span class="cx"> 
</span><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>-    [webView loadTestPageNamed:@&quot;video-with-audio&quot; andExpectControlsManager:NO afterReceivingMessage:@&quot;playing&quot;];
</del><ins>+    [webView loadTestPageNamed:@&quot;video-with-audio&quot;];
+    [webView expectControlsManager:NO afterReceivingMessage:@&quot;playing&quot;];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerMultipleVideosWithAudio)
</span><span class="lines">@@ -183,18 +204,10 @@
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;VideoControlsManagerTestWebView*&gt; webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
</span><span class="cx"> 
</span><del>-    __block BOOL didShowMediaControls;
-    __block bool isDoneLoading = false;
-
-    [webView performAfterLoading:^ {
-        didShowMediaControls = [webView _hasActiveVideoForControlsManager];
-        isDoneLoading = true;
-    }];
-
</del><span class="cx">     [webView loadTestPageNamed:@&quot;large-videos-with-audio&quot;];
</span><ins>+    [webView waitForPageToLoadWithAutoplayingVideos:0];
</ins><span class="cx"> 
</span><del>-    TestWebKitAPI::Util::run(&amp;isDoneLoading);
-    EXPECT_FALSE(didShowMediaControls);
</del><ins>+    EXPECT_FALSE([webView _hasActiveVideoForControlsManager]);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerMultipleVideosWithAudioAndAutoplay)
</span><span class="lines">@@ -201,18 +214,11 @@
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;VideoControlsManagerTestWebView*&gt; webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
</span><span class="cx"> 
</span><del>-    __block BOOL didShowMediaControls;
-    __block bool isDoneLoading = false;
-
-    [webView performAfterLoading:^ {
-        didShowMediaControls = [webView _hasActiveVideoForControlsManager];
-        isDoneLoading = true;
-    }];
-
</del><span class="cx">     [webView loadTestPageNamed:@&quot;large-videos-with-audio-autoplay&quot;];
</span><ins>+    [webView waitForPageToLoadWithAutoplayingVideos:1];
</ins><span class="cx"> 
</span><del>-    TestWebKitAPI::Util::run(&amp;isDoneLoading);
-    EXPECT_TRUE(didShowMediaControls);
</del><ins>+    EXPECT_TRUE([webView _hasActiveVideoForControlsManager]);
+    EXPECT_TRUE([[webView controlledElementID] isEqualToString:@&quot;bar&quot;]);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerMultipleVideosScrollPausedVideoOutOfView)
</span><span class="lines">@@ -219,7 +225,11 @@
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;VideoControlsManagerTestWebView*&gt; webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500));
</span><span class="cx"> 
</span><del>-    [webView loadTestPageNamed:@&quot;large-videos-paused-video-hides-controls&quot; andExpectControlsManager:NO afterReceivingMessage:@&quot;paused&quot;];
</del><ins>+    [webView loadTestPageNamed:@&quot;large-videos-paused-video-hides-controls&quot;];
+    [webView waitForPageToLoadWithAutoplayingVideos:1];
+
+    [webView callJavascriptFunction:@&quot;pauseFirstVideoAndScrollToSecondVideo&quot;];
+    [webView expectControlsManager:NO afterReceivingMessage:@&quot;paused&quot;];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerMultipleVideosScrollPlayingVideoWithSoundOutOfView)
</span><span class="lines">@@ -226,7 +236,11 @@
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;VideoControlsManagerTestWebView*&gt; webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500));
</span><span class="cx"> 
</span><del>-    [webView loadTestPageNamed:@&quot;large-videos-playing-video-keeps-controls&quot; andExpectControlsManager:YES afterReceivingMessage:@&quot;playing&quot;];
</del><ins>+    [webView loadTestPageNamed:@&quot;large-videos-playing-video-keeps-controls&quot;];
+    [webView waitForPageToLoadWithAutoplayingVideos:1];
+
+    [webView callJavascriptFunction:@&quot;scrollToSecondVideo&quot;];
+    [webView expectControlsManager:YES afterReceivingMessage:@&quot;scrolled&quot;];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerMultipleVideosScrollPlayingMutedVideoOutOfView)
</span><span class="lines">@@ -233,7 +247,11 @@
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;VideoControlsManagerTestWebView*&gt; webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500));
</span><span class="cx"> 
</span><del>-    [webView loadTestPageNamed:@&quot;large-videos-playing-muted-video-hides-controls&quot; andExpectControlsManager:NO afterReceivingMessage:@&quot;playing&quot;];
</del><ins>+    [webView loadTestPageNamed:@&quot;large-videos-playing-muted-video-hides-controls&quot;];
+    [webView waitForPageToLoadWithAutoplayingVideos:1];
+
+    [webView callJavascriptFunction:@&quot;muteFirstVideoAndScrollToSecondVideo&quot;];
+    [webView expectControlsManager:NO afterReceivingMessage:@&quot;playing&quot;];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerMultipleVideosShowControlsForLastInteractedVideo)
</span><span class="lines">@@ -241,25 +259,25 @@
</span><span class="cx">     RetainPtr&lt;VideoControlsManagerTestWebView*&gt; webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 800, 600));
</span><span class="cx">     NSPoint clickPoint = NSMakePoint(400, 300);
</span><span class="cx"> 
</span><del>-    [webView performAfterLoading:^ {
-        [webView mouseDownAtPoint:clickPoint];
-    }];
</del><ins>+    [webView loadTestPageNamed:@&quot;large-videos-autoplaying-click-to-pause&quot;];
+    [webView waitForPageToLoadWithAutoplayingVideos:2];
</ins><span class="cx"> 
</span><ins>+    [webView mouseDownAtPoint:clickPoint];
+
</ins><span class="cx">     __block bool firstVideoPaused = false;
</span><span class="cx">     __block bool secondVideoPaused = false;
</span><span class="cx">     [webView performAfterReceivingMessage:@&quot;paused&quot; action:^ {
</span><span class="cx">         NSString *controlledElementID = [webView controlledElementID];
</span><span class="cx">         if (firstVideoPaused) {
</span><ins>+            EXPECT_TRUE([controlledElementID isEqualToString:@&quot;second&quot;]);
</ins><span class="cx">             secondVideoPaused = true;
</span><del>-            EXPECT_TRUE([controlledElementID isEqualToString:@&quot;second&quot;]);
</del><span class="cx">         } else {
</span><ins>+            EXPECT_TRUE([controlledElementID isEqualToString:@&quot;first&quot;]);
</ins><span class="cx">             [webView mouseDownAtPoint:clickPoint];
</span><del>-            EXPECT_TRUE([controlledElementID isEqualToString:@&quot;first&quot;]);
</del><span class="cx">         }
</span><span class="cx">         firstVideoPaused = true;
</span><span class="cx">     }];
</span><span class="cx"> 
</span><del>-    [webView loadTestPageNamed:@&quot;large-videos-autoplaying-click-to-pause&quot;];
</del><span class="cx">     TestWebKitAPI::Util::run(&amp;secondVideoPaused);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -267,13 +285,12 @@
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;VideoControlsManagerTestWebView*&gt; webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 800, 600));
</span><span class="cx"> 
</span><del>-    __block bool scrolledSecondVideoIntoView = false;
</del><span class="cx">     [webView loadTestPageNamed:@&quot;large-videos-autoplaying-scroll-to-video&quot;];
</span><del>-    [webView performAfterReceivingMessage:@&quot;scrolled&quot; action:^ {
-        scrolledSecondVideoIntoView = true;
-    }];
</del><ins>+    [webView waitForPageToLoadWithAutoplayingVideos:2];
</ins><span class="cx"> 
</span><del>-    TestWebKitAPI::Util::run(&amp;scrolledSecondVideoIntoView);
</del><ins>+    [webView callJavascriptFunction:@&quot;scrollToSecondView&quot;];
+    [webView expectControlsManager:YES afterReceivingMessage:@&quot;scrolled&quot;];
+
</ins><span class="cx">     EXPECT_TRUE([[webView controlledElementID] isEqualToString:@&quot;second&quot;]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -281,7 +298,10 @@
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;VideoControlsManagerTestWebView*&gt; webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500));
</span><span class="cx"> 
</span><del>-    [webView loadTestPageNamed:@&quot;large-video-playing-scroll-away&quot; andExpectControlsManager:YES afterReceivingMessage:@&quot;scrolled&quot;];
</del><ins>+    [webView loadTestPageNamed:@&quot;large-video-playing-scroll-away&quot;];
+    [webView waitForPageToLoadWithAutoplayingVideos:1];
+    [webView callJavascriptFunction:@&quot;scrollVideoOutOfView&quot;];
+    [webView expectControlsManager:YES afterReceivingMessage:@&quot;scrolled&quot;];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerSingleSmallAutoplayingVideo)
</span><span class="lines">@@ -288,11 +308,11 @@
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;VideoControlsManagerTestWebView*&gt; webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
</span><span class="cx"> 
</span><del>-    [webView performAfterLoading:^ {
-        [webView mouseDownAtPoint:NSMakePoint(50, 50)];
-    }];
</del><ins>+    [webView loadTestPageNamed:@&quot;autoplaying-video-with-audio&quot;];
+    [webView waitForPageToLoadWithAutoplayingVideos:1];
</ins><span class="cx"> 
</span><del>-    [webView loadTestPageNamed:@&quot;autoplaying-video-with-audio&quot; andExpectControlsManager:YES afterReceivingMessage:@&quot;paused&quot;];
</del><ins>+    [webView mouseDownAtPoint:NSMakePoint(50, 50)];
+    [webView expectControlsManager:YES afterReceivingMessage:@&quot;paused&quot;];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoSeeksAfterEnding)
</span><span class="lines">@@ -300,7 +320,8 @@
</span><span class="cx">     RetainPtr&lt;VideoControlsManagerTestWebView*&gt; webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
</span><span class="cx"> 
</span><span class="cx">     // Since the video has ended, the expectation is NO even if the page programmatically seeks to the beginning.
</span><del>-    [webView loadTestPageNamed:@&quot;large-video-seek-after-ending&quot; andExpectControlsManager:NO afterReceivingMessage:@&quot;ended&quot;];
</del><ins>+    [webView loadTestPageNamed:@&quot;large-video-seek-after-ending&quot;];
+    [webView expectControlsManager:NO afterReceivingMessage:@&quot;ended&quot;];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoSeeksAndPlaysAfterEnding)
</span><span class="lines">@@ -308,7 +329,8 @@
</span><span class="cx">     RetainPtr&lt;VideoControlsManagerTestWebView*&gt; webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
</span><span class="cx"> 
</span><span class="cx">     // Since the video is still playing, the expectation is YES even if the video has ended once.
</span><del>-    [webView loadTestPageNamed:@&quot;large-video-seek-to-beginning-and-play-after-ending&quot; andExpectControlsManager:YES afterReceivingMessage:@&quot;replaying&quot;];
</del><ins>+    [webView loadTestPageNamed:@&quot;large-video-seek-to-beginning-and-play-after-ending&quot;];
+    [webView expectControlsManager:YES afterReceivingMessage:@&quot;replaying&quot;];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoAfterSeekingToEnd)
</span><span class="lines">@@ -315,13 +337,13 @@
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;VideoControlsManagerTestWebView*&gt; webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
</span><span class="cx"> 
</span><del>-    [webView performAfterLoading:^ {
-        [webView mouseDownAtPoint:NSMakePoint(50, 50)];
-    }];
</del><ins>+    [webView loadTestPageNamed:@&quot;large-video-hides-controls-after-seek-to-end&quot;];
+    [webView waitForPageToLoadWithAutoplayingVideos:1];
+    [webView mouseDownAtPoint:NSMakePoint(50, 50)];
</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>-    [webView loadTestPageNamed:@&quot;large-video-hides-controls-after-seek-to-end&quot; andExpectControlsManager:YES afterReceivingMessage:@&quot;ended&quot;];
</del><ins>+    [webView expectControlsManager:YES afterReceivingMessage:@&quot;ended&quot;];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerSingleLargeVideoWithoutAudio)
</span><span class="lines">@@ -330,7 +352,8 @@
</span><span class="cx"> 
</span><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>-    [webView loadTestPageNamed:@&quot;large-video-without-audio&quot; andExpectControlsManager:NO afterReceivingMessage:@&quot;playing&quot;];
</del><ins>+    [webView loadTestPageNamed:@&quot;large-video-without-audio&quot;];
+    [webView expectControlsManager:NO afterReceivingMessage:@&quot;playing&quot;];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerAudioElementStartedWithScript)
</span><span class="lines">@@ -338,7 +361,8 @@
</span><span class="cx">     RetainPtr&lt;VideoControlsManagerTestWebView*&gt; webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
</span><span class="cx"> 
</span><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>-    [webView loadTestPageNamed:@&quot;audio-only&quot; andExpectControlsManager:NO afterReceivingMessage:@&quot;playing&quot;];
</del><ins>+    [webView loadTestPageNamed:@&quot;audio-only&quot;];
+    [webView expectControlsManager:NO afterReceivingMessage:@&quot;playing&quot;];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerTearsDownMediaControlsOnDealloc)
</span><span class="lines">@@ -383,7 +407,8 @@
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;VideoControlsManagerTestWebView*&gt; webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 1600, 800));
</span><span class="cx"> 
</span><del>-    [webView loadTestPageNamed:@&quot;skinny-autoplaying-video-with-audio&quot; andExpectControlsManager:NO afterReceivingMessage:@&quot;playing&quot;];
</del><ins>+    [webView loadTestPageNamed:@&quot;skinny-autoplaying-video-with-audio&quot;];
+    [webView expectControlsManager:NO afterReceivingMessage:@&quot;playing&quot;];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(VideoControlsManager, VideoControlsManagerFullSizeVideoInWideMainFrame)
</span><span class="lines">@@ -390,9 +415,18 @@
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;VideoControlsManagerTestWebView*&gt; webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 1600, 800));
</span><span class="cx"> 
</span><del>-    [webView loadTestPageNamed:@&quot;full-size-autoplaying-video-with-audio&quot; andExpectControlsManager:YES afterReceivingMessage:@&quot;playing&quot;];
</del><ins>+    [webView loadTestPageNamed:@&quot;full-size-autoplaying-video-with-audio&quot;];
+    [webView expectControlsManager:YES afterReceivingMessage:@&quot;playing&quot;];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+TEST(VideoControlsManager, VideoControlsManagerVideoMutesOnPlaying)
+{
+    RetainPtr&lt;VideoControlsManagerTestWebView*&gt; webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500));
+
+    [webView loadTestPageNamed:@&quot;large-video-mutes-onplaying&quot;];
+    [webView expectControlsManager:NO afterReceivingMessage:@&quot;playing&quot;];
+}
+
</ins><span class="cx"> } // namespace TestWebKitAPI
</span><span class="cx"> 
</span><span class="cx"> #endif // WK_API_ENABLED &amp;&amp; PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2Cocoaautoplayingvideowithaudiohtml"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/autoplaying-video-with-audio.html (205416 => 205417)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/autoplaying-video-with-audio.html        2016-09-04 05:09:28 UTC (rev 205416)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/autoplaying-video-with-audio.html        2016-09-04 05:45:10 UTC (rev 205417)
</span><span class="lines">@@ -4,17 +4,8 @@
</span><span class="cx">     &lt;script&gt;
</span><span class="cx">     var timeout;
</span><span class="cx"> 
</span><del>-    function beginTest() {
-        timeout = window.setTimeout(stillPlaying, 5000);
-        window.addEventListener(&quot;mousedown&quot;, pauseVideo);
-        try {
-            window.webkit.messageHandlers.onloadHandler.postMessage('loaded');
-        } catch(e) { }
-    }
-
</del><span class="cx">     function pauseVideo() {
</span><del>-        document.getElementsByTagName('video')[0].pause();
-        window.clearTimeout(timeout);
</del><ins>+        document.getElementsByTagName(&quot;video&quot;)[0].pause();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     function handlePaused() {
</span><span class="lines">@@ -21,20 +12,23 @@
</span><span class="cx">         // Wait until the next runloop to allow media controls to update.
</span><span class="cx">         setTimeout(function() {
</span><span class="cx">             try {
</span><del>-                window.webkit.messageHandlers.playingHandler.postMessage('paused');
</del><ins>+                window.webkit.messageHandlers.playingHandler.postMessage(&quot;paused&quot;);
</ins><span class="cx">             } catch(e) { }
</span><span class="cx">         }, 0);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    function stillPlaying() {
-        try {
-            window.webkit.messageHandlers.playingHandler.postMessage('playing');
-        } catch(e) { }
</del><ins>+    function beganAutoplaying() {
+        setTimeout(function() {
+            try {
+                window.webkit.messageHandlers.playingHandler.postMessage(&quot;autoplayed&quot;);
+            } catch(e) {
+            }
+        }, 0)
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">    &lt;/script&gt;
</span><span class="cx"> &lt;/head&gt;
</span><del>-&lt;body onload=&quot;beginTest()&quot;&gt;
-    &lt;video controls autoplay src=&quot;video-with-audio.mp4&quot; webkit-playsinline onpause=&quot;handlePaused()&quot;&gt;&lt;/video&gt;
</del><ins>+&lt;body onmousedown=pauseVideo()&gt;
+    &lt;video autoplay controls onplaying=beganAutoplaying() src=&quot;video-with-audio.mp4&quot; webkit-playsinline onpause=handlePaused()&gt;&lt;/video&gt;
</ins><span class="cx"> &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2Cocoalargevideohidescontrolsafterseektoendhtml"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-hides-controls-after-seek-to-end.html (205416 => 205417)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-hides-controls-after-seek-to-end.html        2016-09-04 05:09:28 UTC (rev 205416)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-hides-controls-after-seek-to-end.html        2016-09-04 05:45:10 UTC (rev 205417)
</span><span class="lines">@@ -23,9 +23,18 @@
</span><span class="cx">         } catch(e) { }
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    function beganAutoplaying() {
+        setTimeout(function() {
+            try {
+                window.webkit.messageHandlers.playingHandler.postMessage(&quot;autoplayed&quot;);
+            } catch(e) {
+            }
+        }, 0)
+    }
+
</ins><span class="cx">    &lt;/script&gt;
</span><span class="cx"> &lt;/head&gt;
</span><span class="cx"> &lt;body onmousedown=seekToEnd() onload=beginTest()&gt;
</span><del>-    &lt;video autoplay onended=handleEnded() src=&quot;large-video-with-audio.mp4&quot; webkit-playsinline style=&quot;width: 800px; height: 600px;&quot;&gt;&lt;/video&gt;
</del><ins>+    &lt;video autoplay onplaying=beganAutoplaying() onended=handleEnded() src=&quot;large-video-with-audio.mp4&quot; webkit-playsinline style=&quot;width: 800px; height: 600px;&quot;&gt;&lt;/video&gt;
</ins><span class="cx"> &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2Cocoalargevideomutesonplayinghtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-mutes-onplaying.html (0 => 205417)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-mutes-onplaying.html                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-mutes-onplaying.html        2016-09-04 05:45:10 UTC (rev 205417)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+    function handlePlaying() {
+        try {
+            window.webkit.messageHandlers.playingHandler.postMessage(&quot;playing&quot;);
+        } catch(e) {
+        }
+        document.querySelector(&quot;video&quot;).muted = true;
+    }
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;video autoplay src=&quot;large-video-with-audio.mp4&quot; width=640 height=480 onplaying=handlePlaying()&gt;&lt;/video&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2Cocoalargevideoplayingscrollawayhtml"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-playing-scroll-away.html (205416 => 205417)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-playing-scroll-away.html        2016-09-04 05:09:28 UTC (rev 205416)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-playing-scroll-away.html        2016-09-04 05:45:10 UTC (rev 205417)
</span><span class="lines">@@ -11,16 +11,25 @@
</span><span class="cx">             }
</span><span class="cx">         &lt;/style&gt;
</span><span class="cx">         &lt;script&gt;
</span><del>-            function handleLoaded() {
</del><ins>+            function scrollVideoOutOfView() {
</ins><span class="cx">                 document.querySelector(&quot;div&quot;).scrollIntoView();
</span><span class="cx">                 setTimeout(function() {
</span><span class="cx">                     window.webkit.messageHandlers.playingHandler.postMessage(&quot;scrolled&quot;);
</span><span class="cx">                 }, 0);
</span><span class="cx">             }
</span><ins>+
+            function beganAutoplaying() {
+                setTimeout(function() {
+                    try {
+                        window.webkit.messageHandlers.playingHandler.postMessage(&quot;autoplayed&quot;);
+                    } catch(e) {
+                    }
+                }, 0)
+            }
</ins><span class="cx">         &lt;/script&gt;
</span><span class="cx">     &lt;/head&gt;
</span><del>-    &lt;body onload=handleLoaded()&gt;
-        &lt;video autoplay loop id=&quot;first&quot; src=&quot;large-video-with-audio.mp4&quot;&gt;&lt;/video&gt;
</del><ins>+    &lt;body&gt;
+        &lt;video autoplay onplaying=beganAutoplaying() loop id=&quot;first&quot; src=&quot;large-video-with-audio.mp4&quot;&gt;&lt;/video&gt;
</ins><span class="cx">         &lt;br&gt;
</span><span class="cx">         &lt;div&gt;hello world!&lt;/div&gt;
</span><span class="cx">     &lt;/body&gt;
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2Cocoalargevideosautoplayingclicktopausehtml"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-click-to-pause.html (205416 => 205417)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-click-to-pause.html        2016-09-04 05:09:28 UTC (rev 205416)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-click-to-pause.html        2016-09-04 05:45:10 UTC (rev 205417)
</span><span class="lines">@@ -29,10 +29,19 @@
</span><span class="cx">                     } catch(e) { }
</span><span class="cx">                 }, 0);
</span><span class="cx">             }
</span><ins>+
+            function beganAutoplaying() {
+                setTimeout(function() {
+                    try {
+                        window.webkit.messageHandlers.playingHandler.postMessage(&quot;autoplayed&quot;);
+                    } catch(e) {
+                    }
+                }, 0)
+            }
</ins><span class="cx">         &lt;/script&gt;
</span><span class="cx">     &lt;/head&gt;
</span><span class="cx">     &lt;body onmousedown=handleMouseDown()&gt;
</span><del>-        &lt;video autoplay loop id=&quot;first&quot; src=&quot;large-video-with-audio.mp4&quot; onpause=handleFirstPause()&gt;&lt;/video&gt;
-        &lt;video autoplay loop id=&quot;second&quot; src=&quot;large-video-with-audio.mp4&quot; onpause=handleSecondPause()&gt;&lt;/video&gt;
</del><ins>+        &lt;video autoplay onplaying=beganAutoplaying() loop id=&quot;first&quot; src=&quot;large-video-with-audio.mp4&quot; onpause=handleFirstPause()&gt;&lt;/video&gt;
+        &lt;video autoplay onplaying=beganAutoplaying() loop id=&quot;second&quot; src=&quot;large-video-with-audio.mp4&quot; onpause=handleSecondPause()&gt;&lt;/video&gt;
</ins><span class="cx">     &lt;/body&gt;
</span><span class="cx"> &lt;html&gt;
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2Cocoalargevideosautoplayingscrolltovideohtml"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-scroll-to-video.html (205416 => 205417)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-scroll-to-video.html        2016-09-04 05:09:28 UTC (rev 205416)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-scroll-to-video.html        2016-09-04 05:45:10 UTC (rev 205417)
</span><span class="lines">@@ -11,17 +11,25 @@
</span><span class="cx">             }
</span><span class="cx">         &lt;/style&gt;
</span><span class="cx">         &lt;script&gt;
</span><del>-            function handleLoaded() {
</del><ins>+            function scrollToSecondView() {
</ins><span class="cx">                 document.querySelector(&quot;#second&quot;).scrollIntoView();
</span><span class="cx">                 setTimeout(function() {
</span><span class="cx">                     window.webkit.messageHandlers.playingHandler.postMessage(&quot;scrolled&quot;);
</span><span class="cx">                 }, 0);
</span><span class="cx">             }
</span><ins>+            function beganAutoplaying() {
+                setTimeout(function() {
+                    try {
+                        window.webkit.messageHandlers.playingHandler.postMessage(&quot;autoplayed&quot;);
+                    } catch(e) {
+                    }
+                }, 0)
+            }
</ins><span class="cx">         &lt;/script&gt;
</span><span class="cx">     &lt;/head&gt;
</span><del>-    &lt;body onload=handleLoaded()&gt;
-        &lt;video autoplay loop id=&quot;first&quot; src=&quot;large-video-with-audio.mp4&quot;&gt;&lt;/video&gt;
</del><ins>+    &lt;body&gt;
+        &lt;video autoplay onplaying=beganAutoplaying() loop id=&quot;first&quot; src=&quot;large-video-with-audio.mp4&quot;&gt;&lt;/video&gt;
</ins><span class="cx">         &lt;br&gt;
</span><del>-        &lt;video autoplay loop id=&quot;second&quot; src=&quot;large-video-with-audio.mp4&quot;&gt;&lt;/video&gt;
</del><ins>+        &lt;video autoplay onplaying=beganAutoplaying() loop id=&quot;second&quot; src=&quot;large-video-with-audio.mp4&quot;&gt;&lt;/video&gt;
</ins><span class="cx">     &lt;/body&gt;
</span><span class="cx"> &lt;html&gt;
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2Cocoalargevideospausedvideohidescontrolshtml"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-paused-video-hides-controls.html (205416 => 205417)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-paused-video-hides-controls.html        2016-09-04 05:09:28 UTC (rev 205416)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-paused-video-hides-controls.html        2016-09-04 05:45:10 UTC (rev 205417)
</span><span class="lines">@@ -10,7 +10,7 @@
</span><span class="cx">     }
</span><span class="cx"> &lt;/style&gt;
</span><span class="cx"> &lt;script&gt;
</span><del>-    function handleLoaded() {
</del><ins>+    function pauseFirstVideoAndScrollToSecondVideo() {
</ins><span class="cx">         document.querySelector(&quot;#bar&quot;).scrollIntoView();
</span><span class="cx">         document.querySelector(&quot;#foo&quot;).pause();
</span><span class="cx">     }
</span><span class="lines">@@ -21,9 +21,17 @@
</span><span class="cx">             } catch(e) { }
</span><span class="cx">         }, 0);
</span><span class="cx">     }
</span><ins>+    function beganAutoplaying() {
+        setTimeout(function() {
+            try {
+                window.webkit.messageHandlers.playingHandler.postMessage(&quot;autoplayed&quot;);
+            } catch(e) {
+            }
+        }, 0)
+    }
</ins><span class="cx"> &lt;/script&gt;
</span><del>-&lt;body onload=handleLoaded()&gt;
-    &lt;video autoplay loop id=&quot;foo&quot; onpause=handlePaused()&gt;&lt;source src=&quot;large-video-with-audio.mp4&quot;&gt;&lt;/video&gt;
</del><ins>+&lt;body&gt;
+    &lt;video autoplay onplaying=beganAutoplaying() loop id=&quot;foo&quot; onpause=handlePaused()&gt;&lt;source src=&quot;large-video-with-audio.mp4&quot;&gt;&lt;/video&gt;
</ins><span class="cx">     &lt;br&gt;
</span><span class="cx">     &lt;video id=&quot;bar&quot;&gt;&lt;source src=&quot;large-video-with-audio.mp4&quot;&gt;&lt;/video&gt;
</span><span class="cx"> &lt;/body&gt;
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2Cocoalargevideosplayingmutedvideohidescontrolshtml"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-muted-video-hides-controls.html (205416 => 205417)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-muted-video-hides-controls.html        2016-09-04 05:09:28 UTC (rev 205416)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-muted-video-hides-controls.html        2016-09-04 05:45:10 UTC (rev 205417)
</span><span class="lines">@@ -10,7 +10,7 @@
</span><span class="cx">     }
</span><span class="cx"> &lt;/style&gt;
</span><span class="cx"> &lt;script&gt;
</span><del>-    function handleLoaded() {
</del><ins>+    function muteFirstVideoAndScrollToSecondVideo() {
</ins><span class="cx">         document.querySelector(&quot;#foo&quot;).muted = true;
</span><span class="cx">         document.querySelector(&quot;#bar&quot;).scrollIntoView();
</span><span class="cx">         setTimeout(function() {
</span><span class="lines">@@ -19,9 +19,17 @@
</span><span class="cx">             } catch(e) { }
</span><span class="cx">         }, 0);
</span><span class="cx">     }
</span><ins>+    function beganAutoplaying() {
+        setTimeout(function() {
+            try {
+                window.webkit.messageHandlers.playingHandler.postMessage(&quot;autoplayed&quot;);
+            } catch(e) {
+            }
+        }, 0)
+    }
</ins><span class="cx"> &lt;/script&gt;
</span><del>-&lt;body onload=handleLoaded()&gt;
-    &lt;video autoplay loop id=&quot;foo&quot;&gt;&lt;source src=&quot;large-video-with-audio.mp4&quot;&gt;&lt;/video&gt;
</del><ins>+&lt;body&gt;
+    &lt;video autoplay onplaying=beganAutoplaying() loop id=&quot;foo&quot;&gt;&lt;source src=&quot;large-video-with-audio.mp4&quot;&gt;&lt;/video&gt;
</ins><span class="cx">     &lt;br&gt;
</span><span class="cx">     &lt;video id=&quot;bar&quot;&gt;&lt;source src=&quot;large-video-with-audio.mp4&quot;&gt;&lt;/video&gt;
</span><span class="cx"> &lt;/body&gt;
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2Cocoalargevideosplayingvideokeepscontrolshtml"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-video-keeps-controls.html (205416 => 205417)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-video-keeps-controls.html        2016-09-04 05:09:28 UTC (rev 205416)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-video-keeps-controls.html        2016-09-04 05:45:10 UTC (rev 205417)
</span><span class="lines">@@ -10,17 +10,25 @@
</span><span class="cx">     }
</span><span class="cx"> &lt;/style&gt;
</span><span class="cx"> &lt;script&gt;
</span><del>-    function handleLoaded() {
</del><ins>+    function scrollToSecondVideo() {
</ins><span class="cx">         document.querySelector(&quot;#bar&quot;).scrollIntoView();
</span><span class="cx">         setTimeout(function() {
</span><span class="cx">             try {
</span><del>-                window.webkit.messageHandlers.playingHandler.postMessage(&quot;playing&quot;);
</del><ins>+                window.webkit.messageHandlers.playingHandler.postMessage(&quot;scrolled&quot;);
</ins><span class="cx">             } catch(e) { }
</span><span class="cx">         }, 0);
</span><span class="cx">     }
</span><ins>+    function beganAutoplaying() {
+        setTimeout(function() {
+            try {
+                window.webkit.messageHandlers.playingHandler.postMessage(&quot;autoplayed&quot;);
+            } catch(e) {
+            }
+        }, 0)
+    }
</ins><span class="cx"> &lt;/script&gt;
</span><del>-&lt;body onload=handleLoaded()&gt;
-    &lt;video autoplay loop id=&quot;foo&quot;&gt;&lt;source src=&quot;large-video-with-audio.mp4&quot;&gt;&lt;/video&gt;
</del><ins>+&lt;body&gt;
+    &lt;video autoplay onplaying=beganAutoplaying() loop id=&quot;foo&quot;&gt;&lt;source src=&quot;large-video-with-audio.mp4&quot;&gt;&lt;/video&gt;
</ins><span class="cx">     &lt;br&gt;
</span><span class="cx">     &lt;video id=&quot;bar&quot;&gt;&lt;source src=&quot;large-video-with-audio.mp4&quot;&gt;&lt;/video&gt;
</span><span class="cx"> &lt;/body&gt;
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2Cocoalargevideoswithaudioautoplayhtml"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-with-audio-autoplay.html (205416 => 205417)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-with-audio-autoplay.html        2016-09-04 05:09:28 UTC (rev 205416)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-with-audio-autoplay.html        2016-09-04 05:45:10 UTC (rev 205417)
</span><span class="lines">@@ -1,18 +1,18 @@
</span><span class="cx"> &lt;!DOCTYPE html&gt;
</span><span class="cx"> &lt;html&gt;
</span><span class="cx"> &lt;script&gt;
</span><del>-    function handleLoaded() {
-        // The media controls should be updated on the next runloop.
</del><ins>+    function beganAutoplaying() {
</ins><span class="cx">         setTimeout(function() {
</span><span class="cx">             try {
</span><del>-                window.webkit.messageHandlers.onloadHandler.postMessage(&quot;loaded&quot;);
-            } catch(e) { }
-        }, 0);
</del><ins>+                window.webkit.messageHandlers.playingHandler.postMessage(&quot;autoplayed&quot;);
+            } catch(e) {
+            }
+        }, 0)
</ins><span class="cx">     }
</span><span class="cx"> &lt;/script&gt;
</span><del>-&lt;body onload=handleLoaded()&gt;
</del><ins>+&lt;body&gt;
</ins><span class="cx">     &lt;video id=&quot;foo&quot; style=&quot;width: 480px; height: 320px;&quot;&gt;&lt;source src=&quot;large-video-with-audio.mp4&quot;&gt;&lt;/video&gt;
</span><del>-    &lt;video autoplay id=&quot;bar&quot; style=&quot;width: 480px; height: 320px;&quot;&gt;&lt;source src=&quot;large-video-with-audio.mp4&quot;&gt;&lt;/video&gt;
</del><ins>+    &lt;video autoplay onplaying=beganAutoplaying() id=&quot;bar&quot; style=&quot;width: 480px; height: 320px;&quot;&gt;&lt;source src=&quot;large-video-with-audio.mp4&quot;&gt;&lt;/video&gt;
</ins><span class="cx">     &lt;video id=&quot;baz&quot; style=&quot;width: 480px; height: 320px;&quot;&gt;&lt;source src=&quot;large-video-with-audio.mp4&quot;&gt;&lt;/video&gt;
</span><span class="cx"> &lt;/body&gt;
</span><span class="cx"> &lt;html&gt;
</span></span></pre>
</div>
</div>

</body>
</html>