<!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>[215243] 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/215243">215243</a></dd>
<dt>Author</dt> <dd>mrajca@apple.com</dd>
<dt>Date</dt> <dd>2017-04-11 11:29:03 -0700 (Tue, 11 Apr 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Change autoplay state to &quot;prevented&quot; when media is paused due to restrictions.
https://bugs.webkit.org/show_bug.cgi?id=170686

Reviewed by Alex Christensen.

Source/WebCore:

Added API tests.

Currently, the autoplay state is set to &quot;prevented&quot; when playback is about to begin without
user interaction and there are restrictions in place. We should also be setting this flag when
autoplay is allowed but due to a change in audio tracks, for example, it gets paused.

This patch also moves some common logic into setPlaybackWithoutUserGesture without changing behavior.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::setReadyState):
(WebCore::HTMLMediaElement::play):
(WebCore::HTMLMediaElement::mediaPlayerDidAddAudioTrack):
(WebCore::HTMLMediaElement::mediaPlayerCharacteristicChanged):
(WebCore::HTMLMediaElement::setPlaybackWithoutUserGesture):
(WebCore::HTMLMediaElement::updateShouldPlay):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/autoplay-muted-with-controls.html: Added test.
* TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm:
(TEST):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementcpp">trunk/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2CocoaWebsitePoliciesmm">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2autoplaymutedwithcontrolshtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2/autoplay-muted-with-controls.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (215242 => 215243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-04-11 18:27:01 UTC (rev 215242)
+++ trunk/Source/WebCore/ChangeLog        2017-04-11 18:29:03 UTC (rev 215243)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2017-04-10  Matt Rajca  &lt;mrajca@apple.com&gt;
+
+        Change autoplay state to &quot;prevented&quot; when media is paused due to restrictions.
+        https://bugs.webkit.org/show_bug.cgi?id=170686
+
+        Reviewed by Alex Christensen.
+
+        Added API tests.
+
+        Currently, the autoplay state is set to &quot;prevented&quot; when playback is about to begin without
+        user interaction and there are restrictions in place. We should also be setting this flag when
+        autoplay is allowed but due to a change in audio tracks, for example, it gets paused.
+
+        This patch also moves some common logic into setPlaybackWithoutUserGesture without changing behavior.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::setReadyState):
+        (WebCore::HTMLMediaElement::play):
+        (WebCore::HTMLMediaElement::mediaPlayerDidAddAudioTrack):
+        (WebCore::HTMLMediaElement::mediaPlayerCharacteristicChanged):
+        (WebCore::HTMLMediaElement::setPlaybackWithoutUserGesture):
+        (WebCore::HTMLMediaElement::updateShouldPlay):
+
</ins><span class="cx"> 2017-04-11  Eric Carlson  &lt;eric.carlson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [MediaStream] Set correct audio session category when capturing audio
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (215242 => 215243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp        2017-04-11 18:27:01 UTC (rev 215242)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp        2017-04-11 18:29:03 UTC (rev 215243)
</span><span class="lines">@@ -2446,21 +2446,18 @@
</span><span class="cx">             m_playbackStartedTime = currentMediaTime().toDouble();
</span><span class="cx">             scheduleEvent(eventNames().playEvent);
</span><span class="cx">             scheduleNotifyAboutPlaying();
</span><del>-        } else if (success.value() == MediaPlaybackDenialReason::UserGestureRequired) {
</del><ins>+        } else if (success.value() == MediaPlaybackDenialReason::UserGestureRequired)
</ins><span class="cx">             setPlaybackWithoutUserGesture(PlaybackWithoutUserGesture::Prevented);
</span><del>-            dispatchPlayPauseEventsIfNeedsQuirks();
</del><span class="cx"> 
</span><del>-            if (Page* page = document().page())
-                page-&gt;chrome().client().handleAutoplayEvent(AutoplayEvent::DidPreventMediaFromPlaying);
-        }
-
</del><span class="cx">         shouldUpdateDisplayState = true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // If we transition to the Future Data state and we're about to begin playing, ensure playback is actually permitted first,
</span><span class="cx">     // honoring any playback denial reasons such as the requirement of a user gesture.
</span><del>-    if (m_readyState == HAVE_FUTURE_DATA &amp;&amp; oldState &lt; HAVE_FUTURE_DATA &amp;&amp; potentiallyPlaying() &amp;&amp; !m_mediaSession-&gt;playbackPermitted(*this))
</del><ins>+    if (m_readyState == HAVE_FUTURE_DATA &amp;&amp; oldState &lt; HAVE_FUTURE_DATA &amp;&amp; potentiallyPlaying() &amp;&amp; !m_mediaSession-&gt;playbackPermitted(*this)) {
</ins><span class="cx">         pauseInternal();
</span><ins>+        setPlaybackWithoutUserGesture(PlaybackWithoutUserGesture::Prevented);
+    }
</ins><span class="cx"> 
</span><span class="cx">     if (shouldUpdateDisplayState) {
</span><span class="cx">         updateDisplayState();
</span><span class="lines">@@ -3136,13 +3133,8 @@
</span><span class="cx"> 
</span><span class="cx">     auto success = m_mediaSession-&gt;playbackPermitted(*this);
</span><span class="cx">     if (!success) {
</span><del>-        if (success.value() == MediaPlaybackDenialReason::UserGestureRequired) {
</del><ins>+        if (success.value() == MediaPlaybackDenialReason::UserGestureRequired)
</ins><span class="cx">             setPlaybackWithoutUserGesture(PlaybackWithoutUserGesture::Prevented);
</span><del>-            dispatchPlayPauseEventsIfNeedsQuirks();
-
-            if (Page* page = document().page())
-                page-&gt;chrome().client().handleAutoplayEvent(AutoplayEvent::DidPreventMediaFromPlaying);
-        }
</del><span class="cx">         promise.reject(NotAllowedError);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -3169,13 +3161,8 @@
</span><span class="cx"> 
</span><span class="cx">     auto success = m_mediaSession-&gt;playbackPermitted(*this);
</span><span class="cx">     if (!success) {
</span><del>-        if (success.value() == MediaPlaybackDenialReason::UserGestureRequired) {
</del><ins>+        if (success.value() == MediaPlaybackDenialReason::UserGestureRequired)
</ins><span class="cx">             setPlaybackWithoutUserGesture(PlaybackWithoutUserGesture::Prevented);
</span><del>-            dispatchPlayPauseEventsIfNeedsQuirks();
-
-            if (Page* page = document().page())
-                page-&gt;chrome().client().handleAutoplayEvent(AutoplayEvent::DidPreventMediaFromPlaying);
-        }
</del><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (ScriptController::processingUserGestureForMedia())
</span><span class="lines">@@ -3610,8 +3597,10 @@
</span><span class="cx"> 
</span><span class="cx"> void HTMLMediaElement::mediaPlayerDidAddAudioTrack(AudioTrackPrivate&amp; track)
</span><span class="cx"> {
</span><del>-    if (isPlaying() &amp;&amp; !m_mediaSession-&gt;playbackPermitted(*this))
</del><ins>+    if (isPlaying() &amp;&amp; !m_mediaSession-&gt;playbackPermitted(*this)) {
</ins><span class="cx">         pauseInternal();
</span><ins>+        setPlaybackWithoutUserGesture(PlaybackWithoutUserGesture::Prevented);
+    }
</ins><span class="cx"> 
</span><span class="cx">     addAudioTrack(AudioTrack::create(*this, track));
</span><span class="cx"> }
</span><span class="lines">@@ -4757,8 +4746,10 @@
</span><span class="cx">         mediaControls()-&gt;reset();
</span><span class="cx">     updateRenderer();
</span><span class="cx"> 
</span><del>-    if (!paused() &amp;&amp; !m_mediaSession-&gt;playbackPermitted(*this))
</del><ins>+    if (!paused() &amp;&amp; !m_mediaSession-&gt;playbackPermitted(*this)) {
</ins><span class="cx">         pauseInternal();
</span><ins>+        setPlaybackWithoutUserGesture(PlaybackWithoutUserGesture::Prevented);
+    }
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(MEDIA_SESSION)
</span><span class="cx">     document().updateIsPlayingMedia(m_elementID);
</span><span class="lines">@@ -7181,8 +7172,16 @@
</span><span class="cx">         m_playbackWithoutUserGestureStartedTime = currentMediaTime();
</span><span class="cx">         break;
</span><span class="cx">     case PlaybackWithoutUserGesture::None:
</span><ins>+        m_playbackWithoutUserGestureStartedTime = std::nullopt;
+        break;
</ins><span class="cx">     case PlaybackWithoutUserGesture::Prevented:
</span><span class="cx">         m_playbackWithoutUserGestureStartedTime = std::nullopt;
</span><ins>+
+        dispatchPlayPauseEventsIfNeedsQuirks();
+
+        if (Page* page = document().page())
+            page-&gt;chrome().client().handleAutoplayEvent(AutoplayEvent::DidPreventMediaFromPlaying);
+
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -7358,9 +7357,10 @@
</span><span class="cx"> 
</span><span class="cx"> void HTMLMediaElement::updateShouldPlay()
</span><span class="cx"> {
</span><del>-    if (!paused() &amp;&amp; !m_mediaSession-&gt;playbackPermitted(*this))
</del><ins>+    if (!paused() &amp;&amp; !m_mediaSession-&gt;playbackPermitted(*this)) {
</ins><span class="cx">         pauseInternal();
</span><del>-    else if (canTransitionFromAutoplayToPlay())
</del><ins>+        setPlaybackWithoutUserGesture(PlaybackWithoutUserGesture::Prevented);
+    } else if (canTransitionFromAutoplayToPlay())
</ins><span class="cx">         play();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (215242 => 215243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2017-04-11 18:27:01 UTC (rev 215242)
+++ trunk/Tools/ChangeLog        2017-04-11 18:29:03 UTC (rev 215243)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2017-04-10  Matt Rajca  &lt;mrajca@apple.com&gt;
+
+        Change autoplay state to &quot;prevented&quot; when media is paused due to restrictions.
+        https://bugs.webkit.org/show_bug.cgi?id=170686
+
+        Reviewed by Alex Christensen.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2/autoplay-muted-with-controls.html: Added test.
+        * TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm:
+        (TEST):
+
</ins><span class="cx"> 2017-04-11  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [WebCore][JSC] ResourceUsageData.{timeOfNextEdenCollection,timeOfNextFullCollection} should be MonotonicTime
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (215242 => 215243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-04-11 18:27:01 UTC (rev 215242)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-04-11 18:29:03 UTC (rev 215243)
</span><span class="lines">@@ -544,6 +544,7 @@
</span><span class="cx">                 C99B675D1E39722000FC6C80 /* js-play-with-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C99B675B1E3971FC00FC6C80 /* js-play-with-controls.html */; };
</span><span class="cx">                 C99B675F1E39736F00FC6C80 /* no-autoplay-with-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C99B675E1E39735C00FC6C80 /* no-autoplay-with-controls.html */; };
</span><span class="cx">                 C99BDF891E80980400C7170E /* autoplay-zero-volume-check.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C99BDF881E8097E300C7170E /* autoplay-zero-volume-check.html */; };
</span><ins>+                C9BF06EF1E9C132500595E3E /* autoplay-muted-with-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C9BF06EE1E9C130400595E3E /* autoplay-muted-with-controls.html */; };
</ins><span class="cx">                 C9C60E651E53A9DC006DA181 /* autoplay-check-frame.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C9C60E631E53A9BA006DA181 /* autoplay-check-frame.html */; };
</span><span class="cx">                 C9C60E661E53A9DC006DA181 /* autoplay-check-in-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C9C60E641E53A9BA006DA181 /* autoplay-check-in-iframe.html */; };
</span><span class="cx">                 CD321B041E3A85FA00EB21C8 /* video-with-muted-audio-and-webaudio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD321B031E3A84B700EB21C8 /* video-with-muted-audio-and-webaudio.html */; };
</span><span class="lines">@@ -662,6 +663,7 @@
</span><span class="cx">                         dstPath = TestWebKitAPI.resources;
</span><span class="cx">                         dstSubfolderSpec = 7;
</span><span class="cx">                         files = (
</span><ins>+                                C9BF06EF1E9C132500595E3E /* autoplay-muted-with-controls.html in Copy Resources */,
</ins><span class="cx">                                 F4DEF6ED1E9B4DB60048EF61 /* image-in-link-and-input.html in Copy Resources */,
</span><span class="cx">                                 1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */,
</span><span class="cx">                                 379028B914FAC24C007E6B43 /* acceptsFirstMouse.html in Copy Resources */,
</span><span class="lines">@@ -1388,6 +1390,7 @@
</span><span class="cx">                 C99B675B1E3971FC00FC6C80 /* js-play-with-controls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;js-play-with-controls.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 C99B675E1E39735C00FC6C80 /* no-autoplay-with-controls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;no-autoplay-with-controls.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 C99BDF881E8097E300C7170E /* autoplay-zero-volume-check.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;autoplay-zero-volume-check.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                C9BF06EE1E9C130400595E3E /* autoplay-muted-with-controls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;autoplay-muted-with-controls.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 C9C60E631E53A9BA006DA181 /* autoplay-check-frame.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;autoplay-check-frame.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 C9C60E641E53A9BA006DA181 /* autoplay-check-in-iframe.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;autoplay-check-in-iframe.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CD225C071C45A69200140761 /* ParsedContentRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParsedContentRange.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -2150,6 +2153,7 @@
</span><span class="cx">                                 C9C60E631E53A9BA006DA181 /* autoplay-check-frame.html */,
</span><span class="cx">                                 C9C60E641E53A9BA006DA181 /* autoplay-check-in-iframe.html */,
</span><span class="cx">                                 C95984F21E36BC55002C0D45 /* autoplay-check.html */,
</span><ins>+                                C9BF06EE1E9C130400595E3E /* autoplay-muted-with-controls.html */,
</ins><span class="cx">                                 C95984F31E36BC55002C0D45 /* autoplay-no-audio-check.html */,
</span><span class="cx">                                 C99B675A1E3971FC00FC6C80 /* autoplay-with-controls.html */,
</span><span class="cx">                                 C99BDF881E8097E300C7170E /* autoplay-zero-volume-check.html */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2autoplaymutedwithcontrolshtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/autoplay-muted-with-controls.html (0 => 215243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/autoplay-muted-with-controls.html                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/autoplay-muted-with-controls.html        2017-04-11 18:29:03 UTC (rev 215243)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+&lt;html&gt;
+    &lt;head&gt;
+        &lt;script&gt;
+            function pageLoaded() {
+                try {
+                    window.webkit.messageHandlers.testHandler.postMessage(&quot;loaded&quot;);
+                } catch(e) { }
+            }
+
+            function beganPlaying() {
+                document.getElementById(&quot;video&quot;).muted = false;
+            }
+
+            function play() {
+                document.getElementById(&quot;video&quot;).play();
+            }
+        &lt;/script&gt;
+    &lt;/head&gt;
+    &lt;body onload=&quot;pageLoaded()&quot;&gt;
+        &lt;button onclick=&quot;play()&quot;&gt;Play&lt;/button&gt;
+        &lt;video id=&quot;video&quot; onplaying=&quot;beganPlaying()&quot; muted autoplay src=&quot;test.mp4&quot; /&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2CocoaWebsitePoliciesmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm (215242 => 215243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm        2017-04-11 18:27:01 UTC (rev 215242)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm        2017-04-11 18:29:03 UTC (rev 215243)
</span><span class="lines">@@ -342,6 +342,22 @@
</span><span class="cx">     [webView mouseUpAtPoint:playButtonClickPoint];
</span><span class="cx">     [webView waitForMessage:@&quot;played&quot;];
</span><span class="cx">     ASSERT_TRUE(receivedAutoplayEvent == std::nullopt);
</span><ins>+
+    receivedAutoplayEvent = std::nullopt;
+    [webView loadHTMLString:@&quot;&quot; baseURL:nil];
+
+    [delegate setAutoplayPolicyForURL:^(NSURL *) {
+        return _WKWebsiteAutoplayPolicyAllowWithoutSound;
+    }];
+
+    NSURLRequest *autoplayMutedRequest = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@&quot;autoplay-muted-with-controls&quot; withExtension:@&quot;html&quot; subdirectory:@&quot;TestWebKitAPI.resources&quot;]];
+    [webView loadRequest:autoplayMutedRequest];
+    [webView waitForMessage:@&quot;loaded&quot;];
+    runUntilReceivesAutoplayEvent(kWKAutoplayEventDidPreventFromAutoplaying);
+
+    [webView mouseDownAtPoint:playButtonClickPoint simulatePressure:NO];
+    [webView mouseUpAtPoint:playButtonClickPoint];
+    runUntilReceivesAutoplayEvent(kWKAutoplayEventDidPlayMediaPreventedFromAutoplaying);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(WebKit2, WebsitePoliciesPlayingWithoutInterference)
</span></span></pre>
</div>
</div>

</body>
</html>