<!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>[211226] 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/211226">211226</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2017-01-26 12:41:13 -0800 (Thu, 26 Jan 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Notify clients when the user plays media otherwise prevented from autoplaying
https://bugs.webkit.org/show_bug.cgi?id=167390

Patch by Matt Rajca &lt;mrajca@apple.com&gt; on 2017-01-26
Reviewed by Alex Christensen.

Source/WebCore:

The API is tested.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::playInternal):
* page/ChromeClient.h:

Source/WebKit2:

* UIProcess/API/APIUIClient.h:
(API::UIClient::didPlayMediaPreventedFromPlayingWithoutUserGesture):
* UIProcess/API/C/WKPage.cpp:
(WKPageSetPageUIClient):
* UIProcess/API/C/WKPageUIClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didPlayMediaPreventedFromPlayingWithoutUserGesture):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::didPlayMediaPreventedFromPlayingWithoutUserGesture):
* WebProcess/WebCoreSupport/WebChromeClient.h:

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/autoplay-with-controls.html: Added.
* TestWebKitAPI/Tests/WebKit2/js-play-with-controls.html: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm:
(didPlayMediaPreventedFromPlayingWithoutUserGesture):
(TEST):
* TestWebKitAPI/cocoa/TestWKWebView.h:
* TestWebKitAPI/cocoa/TestWKWebView.mm:
(-[TestWKWebViewHostWindow _mouseUpAtPoint:]):
(-[TestWKWebView waitForLoad]):
(-[TestWKWebView mouseUpAtPoint:]):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::createOtherPage):
(WTR::TestController::createWebViewWithOptions):</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="#trunkSourceWebCorepageChromeClienth">trunk/Source/WebCore/page/ChromeClient.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIAPIUIClienth">trunk/Source/WebKit2/UIProcess/API/APIUIClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKPagecpp">trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKPageUIClienth">trunk/Source/WebKit2/UIProcess/API/C/WKPageUIClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxymessagesin">trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebChromeClientcpp">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebChromeClienth">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h</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>
<li><a href="#trunkToolsTestWebKitAPIcocoaTestWKWebViewh">trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h</a></li>
<li><a href="#trunkToolsTestWebKitAPIcocoaTestWKWebViewmm">trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2autoplaywithcontrolshtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2/autoplay-with-controls.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2jsplaywithcontrolshtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2/js-play-with-controls.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2noautoplaywithcontrolshtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2/no-autoplay-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 (211225 => 211226)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-26 20:39:57 UTC (rev 211225)
+++ trunk/Source/WebCore/ChangeLog        2017-01-26 20:41:13 UTC (rev 211226)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2017-01-26  Matt Rajca  &lt;mrajca@apple.com&gt;
+
+        Notify clients when the user plays media otherwise prevented from autoplaying
+        https://bugs.webkit.org/show_bug.cgi?id=167390
+
+        Reviewed by Alex Christensen.
+
+        The API is tested.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::playInternal):
+        * page/ChromeClient.h:
+
</ins><span class="cx"> 2017-01-26  Enrique Ocaña González  &lt;eocanha@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GStreamer] ASSERTION FAILED: !g_object_is_floating(ptr) in adoptGRef(GstContext* ptr)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (211225 => 211226)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp        2017-01-26 20:39:57 UTC (rev 211225)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp        2017-01-26 20:41:13 UTC (rev 211226)
</span><span class="lines">@@ -3167,7 +3167,8 @@
</span><span class="cx">         scheduleResolvePendingPlayPromises();
</span><span class="cx"> 
</span><span class="cx">     if (ScriptController::processingUserGestureForMedia() &amp;&amp; m_preventedFromPlayingWithoutUserGesture) {
</span><del>-        // FIXME: notify clients a user gesture was made and started playback of an element that was otherwise prevented from playing.
</del><ins>+        if (Page* page = document().page())
+            page-&gt;chrome().client().didPlayMediaPreventedFromPlayingWithoutUserGesture();
</ins><span class="cx">         m_preventedFromPlayingWithoutUserGesture = false;
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepageChromeClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ChromeClient.h (211225 => 211226)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ChromeClient.h        2017-01-26 20:39:57 UTC (rev 211225)
+++ trunk/Source/WebCore/page/ChromeClient.h        2017-01-26 20:41:13 UTC (rev 211226)
</span><span class="lines">@@ -420,6 +420,7 @@
</span><span class="cx">     virtual bool shouldUseTiledBackingForFrameView(const FrameView&amp;) const { return false; }
</span><span class="cx"> 
</span><span class="cx">     virtual void isPlayingMediaDidChange(MediaProducer::MediaStateFlags, uint64_t) { }
</span><ins>+    virtual void didPlayMediaPreventedFromPlayingWithoutUserGesture() { }
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(MEDIA_SESSION)
</span><span class="cx">     virtual void hasMediaSessionWithActiveMediaElementsDidChange(bool) { }
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (211225 => 211226)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-01-26 20:39:57 UTC (rev 211225)
+++ trunk/Source/WebKit2/ChangeLog        2017-01-26 20:41:13 UTC (rev 211226)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2017-01-26  Matt Rajca  &lt;mrajca@apple.com&gt;
+
+        Notify clients when the user plays media otherwise prevented from autoplaying
+        https://bugs.webkit.org/show_bug.cgi?id=167390
+
+        Reviewed by Alex Christensen.
+
+        * UIProcess/API/APIUIClient.h:
+        (API::UIClient::didPlayMediaPreventedFromPlayingWithoutUserGesture):
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageSetPageUIClient):
+        * UIProcess/API/C/WKPageUIClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::didPlayMediaPreventedFromPlayingWithoutUserGesture):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::didPlayMediaPreventedFromPlayingWithoutUserGesture):
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+
</ins><span class="cx"> 2017-01-26  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Don't use _CFBundleCreateUnique on Yosemite, it's not available there
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIAPIUIClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/APIUIClient.h (211225 => 211226)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/APIUIClient.h        2017-01-26 20:39:57 UTC (rev 211225)
+++ trunk/Source/WebKit2/UIProcess/API/APIUIClient.h        2017-01-26 20:41:13 UTC (rev 211226)
</span><span class="lines">@@ -152,6 +152,7 @@
</span><span class="cx">     virtual void isPlayingAudioDidChange(WebKit::WebPageProxy&amp;) { }
</span><span class="cx">     virtual void didBeginCaptureSession() { }
</span><span class="cx">     virtual void didEndCaptureSession() { }
</span><ins>+    virtual void didPlayMediaPreventedFromPlayingWithoutUserGesture(WebKit::WebPageProxy&amp;) { }
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(MEDIA_SESSION)
</span><span class="cx">     virtual void mediaSessionMetadataDidChange(WebKit::WebPageProxy&amp;, WebKit::WebMediaSessionMetadata*) { }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICWKPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (211225 => 211226)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp        2017-01-26 20:39:57 UTC (rev 211225)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp        2017-01-26 20:41:13 UTC (rev 211226)
</span><span class="lines">@@ -110,7 +110,7 @@
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> template&lt;&gt; struct ClientTraits&lt;WKPageUIClientBase&gt; {
</span><del>-    typedef std::tuple&lt;WKPageUIClientV0, WKPageUIClientV1, WKPageUIClientV2, WKPageUIClientV3, WKPageUIClientV4, WKPageUIClientV5, WKPageUIClientV6, WKPageUIClientV7, WKPageUIClientV8&gt; Versions;
</del><ins>+    typedef std::tuple&lt;WKPageUIClientV0, WKPageUIClientV1, WKPageUIClientV2, WKPageUIClientV3, WKPageUIClientV4, WKPageUIClientV5, WKPageUIClientV6, WKPageUIClientV7, WKPageUIClientV8, WKPageUIClientV9&gt; Versions;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(CONTEXT_MENUS)
</span><span class="lines">@@ -2241,6 +2241,14 @@
</span><span class="cx">             m_client.didLosePointerLock(toAPI(page), m_client.base.clientInfo);
</span><span class="cx">         }
</span><span class="cx"> #endif
</span><ins>+
+        void didPlayMediaPreventedFromPlayingWithoutUserGesture(WebPageProxy&amp; page) override
+        {
+            if (!m_client.didPlayMediaPreventedFromPlayingWithoutUserGesture)
+                return;
+
+            m_client.didPlayMediaPreventedFromPlayingWithoutUserGesture(toAPI(&amp;page), m_client.base.clientInfo);
+        }
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     toImpl(pageRef)-&gt;setUIClient(std::make_unique&lt;UIClient&gt;(wkClient));
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICWKPageUIClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPageUIClient.h (211225 => 211226)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/C/WKPageUIClient.h        2017-01-26 20:39:57 UTC (rev 211225)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPageUIClient.h        2017-01-26 20:41:13 UTC (rev 211226)
</span><span class="lines">@@ -102,6 +102,7 @@
</span><span class="cx"> typedef void (*WKCheckUserMediaPermissionCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef userMediaDocumentOrigin, WKSecurityOriginRef topLevelDocumentOrigin, WKUserMediaPermissionCheckRef devicesRequest, const void *clientInfo);
</span><span class="cx"> typedef void (*WKPageDidClickAutoFillButtonCallback)(WKPageRef page, WKTypeRef userData, const void *clientInfo);
</span><span class="cx"> typedef void (*WKPageMediaSessionMetadataDidChangeCallback)(WKPageRef page, WKMediaSessionMetadataRef metadata, const void* clientInfo);
</span><ins>+typedef void (*WKDidPlayMediaPreventedFromPlayingWithoutUserGesture)(WKPageRef page, const void* clientInfo);
</ins><span class="cx"> typedef void (*WKFullscreenMayReturnToInlineCallback)(WKPageRef page, const void* clientInfo);
</span><span class="cx"> 
</span><span class="cx"> typedef void (*WKRequestPointerLockCallback)(WKPageRef page, const void* clientInfo);
</span><span class="lines">@@ -726,6 +727,97 @@
</span><span class="cx">     WKRequestPointerLockCallback                                        requestPointerLock;
</span><span class="cx">     WKDidLosePointerLockCallback                                        didLosePointerLock;
</span><span class="cx"> } WKPageUIClientV8;
</span><ins>+
+typedef struct WKPageUIClientV9 {
+    WKPageUIClientBase                                                  base;
+
+    // Version 0.
+    WKPageCreateNewPageCallback_deprecatedForUseWithV0                  createNewPage_deprecatedForUseWithV0;
+    WKPageUIClientCallback                                              showPage;
+    WKPageUIClientCallback                                              close;
+    WKPageTakeFocusCallback                                             takeFocus;
+    WKPageFocusCallback                                                 focus;
+    WKPageUnfocusCallback                                               unfocus;
+    WKPageRunJavaScriptAlertCallback_deprecatedForUseWithV0             runJavaScriptAlert_deprecatedForUseWithV0;
+    WKPageRunJavaScriptConfirmCallback_deprecatedForUseWithV0           runJavaScriptConfirm_deprecatedForUseWithV0;
+    WKPageRunJavaScriptPromptCallback_deprecatedForUseWithV0            runJavaScriptPrompt_deprecatedForUseWithV0;
+    WKPageSetStatusTextCallback                                         setStatusText;
+    WKPageMouseDidMoveOverElementCallback_deprecatedForUseWithV0        mouseDidMoveOverElement_deprecatedForUseWithV0;
+    WKPageMissingPluginButtonClickedCallback_deprecatedForUseWithV0     missingPluginButtonClicked_deprecatedForUseWithV0;
+    WKPageDidNotHandleKeyEventCallback                                  didNotHandleKeyEvent;
+    WKPageDidNotHandleWheelEventCallback                                didNotHandleWheelEvent;
+    WKPageGetToolbarsAreVisibleCallback                                 toolbarsAreVisible;
+    WKPageSetToolbarsAreVisibleCallback                                 setToolbarsAreVisible;
+    WKPageGetMenuBarIsVisibleCallback                                   menuBarIsVisible;
+    WKPageSetMenuBarIsVisibleCallback                                   setMenuBarIsVisible;
+    WKPageGetStatusBarIsVisibleCallback                                 statusBarIsVisible;
+    WKPageSetStatusBarIsVisibleCallback                                 setStatusBarIsVisible;
+    WKPageGetIsResizableCallback                                        isResizable;
+    WKPageSetIsResizableCallback                                        setIsResizable;
+    WKPageGetWindowFrameCallback                                        getWindowFrame;
+    WKPageSetWindowFrameCallback                                        setWindowFrame;
+    WKPageRunBeforeUnloadConfirmPanelCallback_deprecatedForUseWithV6    runBeforeUnloadConfirmPanel_deprecatedForUseWithV6;
+    WKPageUIClientCallback                                              didDraw;
+    WKPageUIClientCallback                                              pageDidScroll;
+    WKPageExceededDatabaseQuotaCallback                                 exceededDatabaseQuota;
+    WKPageRunOpenPanelCallback                                          runOpenPanel;
+    WKPageDecidePolicyForGeolocationPermissionRequestCallback           decidePolicyForGeolocationPermissionRequest;
+    WKPageHeaderHeightCallback                                          headerHeight;
+    WKPageFooterHeightCallback                                          footerHeight;
+    WKPageDrawHeaderCallback                                            drawHeader;
+    WKPageDrawFooterCallback                                            drawFooter;
+    WKPagePrintFrameCallback                                            printFrame;
+    WKPageUIClientCallback                                              runModal;
+    void*                                                               unused1; // Used to be didCompleteRubberBandForMainFrame
+    WKPageSaveDataToFileInDownloadsFolderCallback                       saveDataToFileInDownloadsFolder;
+    void*                                                               shouldInterruptJavaScript_unavailable;
+
+    // Version 1.
+    WKPageCreateNewPageCallback_deprecatedForUseWithV1                  createNewPage_deprecatedForUseWithV1;
+    WKPageMouseDidMoveOverElementCallback                               mouseDidMoveOverElement;
+    WKPageDecidePolicyForNotificationPermissionRequestCallback          decidePolicyForNotificationPermissionRequest;
+    WKPageUnavailablePluginButtonClickedCallback_deprecatedForUseWithV1 unavailablePluginButtonClicked_deprecatedForUseWithV1;
+
+    // Version 2.
+    WKPageShowColorPickerCallback                                       showColorPicker;
+    WKPageHideColorPickerCallback                                       hideColorPicker;
+    WKPageUnavailablePluginButtonClickedCallback                        unavailablePluginButtonClicked;
+
+    // Version 3.
+    WKPagePinnedStateDidChangeCallback                                  pinnedStateDidChange;
+
+    // Version 4.
+    void*                                                               unused2; // Used to be didBeginTrackingPotentialLongMousePress.
+    void*                                                               unused3; // Used to be didRecognizeLongMousePress.
+    void*                                                               unused4; // Used to be didCancelTrackingPotentialLongMousePress.
+    WKPageIsPlayingAudioDidChangeCallback                               isPlayingAudioDidChange;
+
+    // Version 5.
+    WKPageDecidePolicyForUserMediaPermissionRequestCallback             decidePolicyForUserMediaPermissionRequest;
+    WKPageDidClickAutoFillButtonCallback                                didClickAutoFillButton;
+    WKPageRunJavaScriptAlertCallback_deprecatedForUseWithV5             runJavaScriptAlert_deprecatedForUseWithV5;
+    WKPageRunJavaScriptConfirmCallback_deprecatedForUseWithV5           runJavaScriptConfirm_deprecatedForUseWithV5;
+    WKPageRunJavaScriptPromptCallback_deprecatedForUseWithV5            runJavaScriptPrompt_deprecatedForUseWithV5;
+    WKPageMediaSessionMetadataDidChangeCallback                         mediaSessionMetadataDidChange;
+
+    // Version 6.
+    WKPageCreateNewPageCallback                                         createNewPage;
+    WKPageRunJavaScriptAlertCallback                                    runJavaScriptAlert;
+    WKPageRunJavaScriptConfirmCallback                                  runJavaScriptConfirm;
+    WKPageRunJavaScriptPromptCallback                                   runJavaScriptPrompt;
+    WKCheckUserMediaPermissionCallback                                  checkUserMediaPermissionForOrigin;
+
+    // Version 7.
+    WKPageRunBeforeUnloadConfirmPanelCallback                           runBeforeUnloadConfirmPanel;
+    WKFullscreenMayReturnToInlineCallback                               fullscreenMayReturnToInline;
+
+    // Version 8.
+    WKRequestPointerLockCallback                                        requestPointerLock;
+    WKDidLosePointerLockCallback                                        didLosePointerLock;
+
+    // Version 9.
+    WKDidPlayMediaPreventedFromPlayingWithoutUserGesture                didPlayMediaPreventedFromPlayingWithoutUserGesture;
+} WKPageUIClientV9;
</ins><span class="cx">     
</span><span class="cx"> #ifdef __cplusplus
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (211225 => 211226)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2017-01-26 20:39:57 UTC (rev 211225)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2017-01-26 20:41:13 UTC (rev 211226)
</span><span class="lines">@@ -6532,6 +6532,11 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+void WebPageProxy::didPlayMediaPreventedFromPlayingWithoutUserGesture()
+{
+    m_uiClient-&gt;didPlayMediaPreventedFromPlayingWithoutUserGesture(*this);
+}
+
</ins><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> void WebPageProxy::removeNavigationGestureSnapshot()
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (211225 => 211226)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2017-01-26 20:39:57 UTC (rev 211225)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2017-01-26 20:41:13 UTC (rev 211226)
</span><span class="lines">@@ -1064,6 +1064,7 @@
</span><span class="cx">     bool hasActiveAudioStream() const { return m_mediaState &amp; WebCore::MediaProducer::HasActiveAudioCaptureDevice; }
</span><span class="cx">     bool hasActiveVideoStream() const { return m_mediaState &amp; WebCore::MediaProducer::HasActiveVideoCaptureDevice; }
</span><span class="cx">     WebCore::MediaProducer::MediaStateFlags mediaStateFlags() const { return m_mediaState; }
</span><ins>+    void didPlayMediaPreventedFromPlayingWithoutUserGesture();
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx">     void videoControlsManagerDidChange();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (211225 => 211226)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2017-01-26 20:39:57 UTC (rev 211225)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2017-01-26 20:41:13 UTC (rev 211226)
</span><span class="lines">@@ -443,6 +443,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     IsPlayingMediaDidChange(unsigned state, uint64_t sourceElementID)
</span><ins>+    DidPlayMediaPreventedFromPlayingWithoutUserGesture()
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(MEDIA_SESSION)
</span><span class="cx">     HasMediaSessionWithActiveMediaElementsDidChange(bool state)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebChromeClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp (211225 => 211226)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp        2017-01-26 20:39:57 UTC (rev 211225)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp        2017-01-26 20:41:13 UTC (rev 211226)
</span><span class="lines">@@ -1084,6 +1084,11 @@
</span><span class="cx">     m_page.send(Messages::WebPageProxy::IsPlayingMediaDidChange(state, sourceElementID));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebChromeClient::didPlayMediaPreventedFromPlayingWithoutUserGesture()
+{
+    m_page.send(Messages::WebPageProxy::DidPlayMediaPreventedFromPlayingWithoutUserGesture());
+}
+
</ins><span class="cx"> #if ENABLE(MEDIA_SESSION)
</span><span class="cx"> 
</span><span class="cx"> void WebChromeClient::hasMediaSessionWithActiveMediaElementsDidChange(bool state)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebChromeClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h (211225 => 211226)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h        2017-01-26 20:39:57 UTC (rev 211225)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h        2017-01-26 20:41:13 UTC (rev 211226)
</span><span class="lines">@@ -297,6 +297,7 @@
</span><span class="cx">     bool shouldUseTiledBackingForFrameView(const WebCore::FrameView&amp;) const final;
</span><span class="cx"> 
</span><span class="cx">     void isPlayingMediaDidChange(WebCore::MediaProducer::MediaStateFlags, uint64_t) final;
</span><ins>+    void didPlayMediaPreventedFromPlayingWithoutUserGesture() final;
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(MEDIA_SESSION)
</span><span class="cx">     void hasMediaSessionWithActiveMediaElementsDidChange(bool) final;
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (211225 => 211226)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2017-01-26 20:39:57 UTC (rev 211225)
+++ trunk/Tools/ChangeLog        2017-01-26 20:41:13 UTC (rev 211226)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2017-01-26  Matt Rajca  &lt;mrajca@apple.com&gt;
+
+        Notify clients when the user plays media otherwise prevented from autoplaying
+        https://bugs.webkit.org/show_bug.cgi?id=167390
+
+        Reviewed by Alex Christensen.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2/autoplay-with-controls.html: Added.
+        * TestWebKitAPI/Tests/WebKit2/js-play-with-controls.html: Added.
+        * TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm:
+        (didPlayMediaPreventedFromPlayingWithoutUserGesture):
+        (TEST):
+        * TestWebKitAPI/cocoa/TestWKWebView.h:
+        * TestWebKitAPI/cocoa/TestWKWebView.mm:
+        (-[TestWKWebViewHostWindow _mouseUpAtPoint:]):
+        (-[TestWKWebView waitForLoad]):
+        (-[TestWKWebView mouseUpAtPoint:]):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::createOtherPage):
+        (WTR::TestController::createWebViewWithOptions):
+
</ins><span class="cx"> 2017-01-26  Per Arne Vollan  &lt;pvollan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Crash when setting custom scale factor.
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (211225 => 211226)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-01-26 20:39:57 UTC (rev 211225)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-01-26 20:41:13 UTC (rev 211226)
</span><span class="lines">@@ -509,6 +509,9 @@
</span><span class="cx">                 C95984F41E36BC6B002C0D45 /* autoplay-check.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C95984F21E36BC55002C0D45 /* autoplay-check.html */; };
</span><span class="cx">                 C95984F51E36BC6B002C0D45 /* autoplay-no-audio-check.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C95984F31E36BC55002C0D45 /* autoplay-no-audio-check.html */; };
</span><span class="cx">                 C95984F71E36BCEF002C0D45 /* test-without-audio-track.mp4 in Copy Resources */ = {isa = PBXBuildFile; fileRef = C95984F61E36BCD7002C0D45 /* test-without-audio-track.mp4 */; };
</span><ins>+                C99B675C1E39721A00FC6C80 /* autoplay-with-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C99B675A1E3971FC00FC6C80 /* autoplay-with-controls.html */; };
+                C99B675D1E39722000FC6C80 /* js-play-with-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C99B675B1E3971FC00FC6C80 /* js-play-with-controls.html */; };
+                C99B675F1E39736F00FC6C80 /* no-autoplay-with-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C99B675E1E39735C00FC6C80 /* no-autoplay-with-controls.html */; };
</ins><span class="cx">                 CD59F53419E9110D00CF1835 /* file-with-mse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD59F53219E910AA00CF1835 /* file-with-mse.html */; };
</span><span class="cx">                 CD59F53519E9110D00CF1835 /* test-mse.mp4 in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD59F53319E910BC00CF1835 /* test-mse.mp4 */; };
</span><span class="cx">                 CD78E11D1DB7EA660014A2DE /* FullscreenDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD78E11A1DB7EA360014A2DE /* FullscreenDelegate.mm */; };
</span><span class="lines">@@ -607,6 +610,9 @@
</span><span class="cx">                         dstPath = TestWebKitAPI.resources;
</span><span class="cx">                         dstSubfolderSpec = 7;
</span><span class="cx">                         files = (
</span><ins>+                                C99B675F1E39736F00FC6C80 /* no-autoplay-with-controls.html in Copy Resources */,
+                                C99B675D1E39722000FC6C80 /* js-play-with-controls.html in Copy Resources */,
+                                C99B675C1E39721A00FC6C80 /* autoplay-with-controls.html in Copy Resources */,
</ins><span class="cx">                                 C95984F71E36BCEF002C0D45 /* test-without-audio-track.mp4 in Copy Resources */,
</span><span class="cx">                                 C95984F41E36BC6B002C0D45 /* autoplay-check.html in Copy Resources */,
</span><span class="cx">                                 C95984F51E36BC6B002C0D45 /* autoplay-no-audio-check.html in Copy Resources */,
</span><span class="lines">@@ -1274,6 +1280,9 @@
</span><span class="cx">                 C95984F21E36BC55002C0D45 /* autoplay-check.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;autoplay-check.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 C95984F31E36BC55002C0D45 /* autoplay-no-audio-check.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;autoplay-no-audio-check.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 C95984F61E36BCD7002C0D45 /* test-without-audio-track.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = &quot;test-without-audio-track.mp4&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                C99B675A1E3971FC00FC6C80 /* autoplay-with-controls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;autoplay-with-controls.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
+                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;; };
+                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;; };
</ins><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="cx">                 CD5393C71757BA9700C07123 /* MD5.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MD5.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CD5393C91757BAC400C07123 /* SHA1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SHA1.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -1961,6 +1970,7 @@
</span><span class="cx">                                 76E182DE15475A8300F1FADD /* auto-submitting-form.html */,
</span><span class="cx">                                 C95984F21E36BC55002C0D45 /* autoplay-check.html */,
</span><span class="cx">                                 C95984F31E36BC55002C0D45 /* autoplay-no-audio-check.html */,
</span><ins>+                                C99B675A1E3971FC00FC6C80 /* autoplay-with-controls.html */,
</ins><span class="cx">                                 7C486BA01AA1254B003F6F9B /* bundle-file.html */,
</span><span class="cx">                                 9BD4239B1E04BFD000200395 /* chinese-character-with-image.html */,
</span><span class="cx">                                 1A50AA1F1A2A4EA500F4C345 /* close-from-within-create-page.html */,
</span><span class="lines">@@ -1981,6 +1991,7 @@
</span><span class="cx">                                 4A410F4D19AF7BEF002EBAB5 /* getUserMedia.html */,
</span><span class="cx">                                 BCBD372E125ABBE600D2C29F /* icon.png */,
</span><span class="cx">                                 CE3524F51B142BBB0028A7C5 /* input-focus-blur.html */,
</span><ins>+                                C99B675B1E3971FC00FC6C80 /* js-play-with-controls.html */,
</ins><span class="cx">                                 8349D3C31DB9724F004A9F65 /* link-with-download-attribute.html */,
</span><span class="cx">                                 378E647816326FDF00B6C676 /* link-with-title.html */,
</span><span class="cx">                                 9361002814DC957B0061379D /* lots-of-iframes.html */,
</span><span class="lines">@@ -1991,6 +2002,7 @@
</span><span class="cx">                                 51CD1C711B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html */,
</span><span class="cx">                                 7A1458FB1AD5C03500E06772 /* mouse-button-listener.html */,
</span><span class="cx">                                 33E79E05137B5FCE00E32D99 /* mouse-move-listener.html */,
</span><ins>+                                C99B675E1E39735C00FC6C80 /* no-autoplay-with-controls.html */,
</ins><span class="cx">                                 CEA6CF2719CCF69D0064F5A7 /* open-and-close-window.html */,
</span><span class="cx">                                 F6FDDDD514241C48004F1729 /* push-state.html */,
</span><span class="cx">                                 CEBABD481B71687C0051210A /* should-open-external-schemes.html */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2autoplaywithcontrolshtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/autoplay-with-controls.html (0 => 211226)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/autoplay-with-controls.html                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/autoplay-with-controls.html        2017-01-26 20:41:13 UTC (rev 211226)
</span><span class="lines">@@ -0,0 +1,19 @@
</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 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; autoplay src=&quot;test.mp4&quot; /&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2jsplaywithcontrolshtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/js-play-with-controls.html (0 => 211226)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/js-play-with-controls.html                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/js-play-with-controls.html        2017-01-26 20:41:13 UTC (rev 211226)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+&lt;html&gt;
+    &lt;head&gt;
+        &lt;script&gt;
+            function pageLoaded() {
+                document.getElementById(&quot;video&quot;).play();
+                try {
+                    window.webkit.messageHandlers.testHandler.postMessage(&quot;loaded&quot;);
+                } catch(e) { }
+            }
+
+            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; src=&quot;test.mp4&quot; /&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2noautoplaywithcontrolshtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/no-autoplay-with-controls.html (0 => 211226)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/no-autoplay-with-controls.html                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/no-autoplay-with-controls.html        2017-01-26 20:41:13 UTC (rev 211226)
</span><span class="lines">@@ -0,0 +1,25 @@
</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() {
+                try {
+                    window.webkit.messageHandlers.testHandler.postMessage(&quot;played&quot;);
+                } catch(e) { }
+            }
+
+            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=beganPlaying() 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 (211225 => 211226)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm        2017-01-26 20:39:57 UTC (rev 211225)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm        2017-01-26 20:41:13 UTC (rev 211226)
</span><span class="lines">@@ -39,6 +39,10 @@
</span><span class="cx"> 
</span><span class="cx"> #if WK_API_ENABLED
</span><span class="cx"> 
</span><ins>+@interface WKWebView ()
+- (WKPageRef)_pageForTesting;
+@end
+
</ins><span class="cx"> static bool doneCompiling;
</span><span class="cx"> static bool receivedAlert;
</span><span class="cx"> static size_t alertCount;
</span><span class="lines">@@ -213,4 +217,59 @@
</span><span class="cx">     [webView waitForMessage:@&quot;autoplayed&quot;];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if PLATFORM(MAC)
+static void didPlayMediaPreventedFromPlayingWithoutUserGesture(WKPageRef page, const void* clientInfo)
+{
+    receivedAlert = true;
+}
+
+TEST(WebKit2, WebsitePoliciesPlayAfterPreventedAutoplay)
+{
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 336, 276) configuration:configuration.get()]);
+
+    auto delegate = adoptNS([[AutoplayPoliciesDelegate alloc] init]);
+    [delegate setAutoplayPolicy:_WKWebsiteAutoplayPolicyDeny];
+    [webView setNavigationDelegate:delegate.get()];
+
+    WKPageUIClientV9 uiClient;
+    memset(&amp;uiClient, 0, sizeof(uiClient));
+
+    uiClient.base.version = 8;
+    uiClient.didPlayMediaPreventedFromPlayingWithoutUserGesture = didPlayMediaPreventedFromPlayingWithoutUserGesture;
+
+    WKPageSetPageUIClient([webView _pageForTesting], &amp;uiClient.base);
+    NSPoint playButtonClickPoint = NSMakePoint(20, 256);
+
+    receivedAlert = false;
+    NSURLRequest *jsPlayRequest = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@&quot;js-play-with-controls&quot; withExtension:@&quot;html&quot; subdirectory:@&quot;TestWebKitAPI.resources&quot;]];
+    [webView loadRequest:jsPlayRequest];
+    [webView waitForMessage:@&quot;loaded&quot;];
+    [webView mouseDownAtPoint:playButtonClickPoint simulatePressure:NO];
+    [webView mouseUpAtPoint:playButtonClickPoint];
+    TestWebKitAPI::Util::run(&amp;receivedAlert);
+
+    receivedAlert = false;
+    [webView loadHTMLString:@&quot;&quot; baseURL:nil];
+
+    NSURLRequest *autoplayRequest = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@&quot;autoplay-with-controls&quot; withExtension:@&quot;html&quot; subdirectory:@&quot;TestWebKitAPI.resources&quot;]];
+    [webView loadRequest:autoplayRequest];
+    [webView waitForMessage:@&quot;loaded&quot;];
+    [webView mouseDownAtPoint:playButtonClickPoint simulatePressure:NO];
+    [webView mouseUpAtPoint:playButtonClickPoint];
+    TestWebKitAPI::Util::run(&amp;receivedAlert);
+
+    receivedAlert = false;
+    [webView loadHTMLString:@&quot;&quot; baseURL:nil];
+
+    NSURLRequest *noAutoplayRequest = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@&quot;no-autoplay-with-controls&quot; withExtension:@&quot;html&quot; subdirectory:@&quot;TestWebKitAPI.resources&quot;]];
+    [webView loadRequest:noAutoplayRequest];
+    [webView waitForMessage:@&quot;loaded&quot;];
+    [webView mouseDownAtPoint:playButtonClickPoint simulatePressure:NO];
+    [webView mouseUpAtPoint:playButtonClickPoint];
+    [webView waitForMessage:@&quot;played&quot;];
+    ASSERT_FALSE(receivedAlert);
+}
</ins><span class="cx"> #endif
</span><ins>+
+#endif
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPIcocoaTestWKWebViewh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h (211225 => 211226)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h        2017-01-26 20:39:57 UTC (rev 211225)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h        2017-01-26 20:41:13 UTC (rev 211226)
</span><span class="lines">@@ -44,6 +44,7 @@
</span><span class="cx"> @interface TestWKWebView (MacOnly)
</span><span class="cx"> // Simulates clicking with a pressure-sensitive device, if possible.
</span><span class="cx"> - (void)mouseDownAtPoint:(NSPoint)point simulatePressure:(BOOL)simulatePressure;
</span><ins>+- (void)mouseUpAtPoint:(NSPoint)point;
</ins><span class="cx"> - (void)typeCharacter:(char)character;
</span><span class="cx"> @end
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPIcocoaTestWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm (211225 => 211226)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm        2017-01-26 20:39:57 UTC (rev 211225)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm        2017-01-26 20:41:13 UTC (rev 211226)
</span><span class="lines">@@ -120,6 +120,11 @@
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><ins>+
+- (void)_mouseUpAtPoint:(NSPoint)point
+{
+    [self sendEvent:[NSEvent mouseEventWithType:NSEventTypeLeftMouseUp location:point modifierFlags:0 timestamp:GetCurrentEventTime() windowNumber:self.windowNumber context:[NSGraphicsContext currentContext] eventNumber:++gEventNumber clickCount:1 pressure:0]];
+}
</ins><span class="cx"> #endif // PLATFORM(MAC)
</span><span class="cx"> 
</span><span class="cx"> - (BOOL)isKeyWindow
</span><span class="lines">@@ -250,6 +255,11 @@
</span><span class="cx">     [_hostWindow _mouseDownAtPoint:point simulatePressure:simulatePressure];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)mouseUpAtPoint:(NSPoint)point
+{
+    [_hostWindow _mouseUpAtPoint:point];
+}
+
</ins><span class="cx"> - (void)typeCharacter:(char)character {
</span><span class="cx">     NSString *characterAsString = [NSString stringWithFormat:@&quot;%c&quot; , character];
</span><span class="cx">     NSEventType keyDownEventType = NSEventTypeKeyDown;
</span></span></pre>
</div>
</div>

</body>
</html>