Diff
Modified: trunk/Source/WebCore/ChangeLog (211192 => 211193)
--- trunk/Source/WebCore/ChangeLog 2017-01-26 02:01:29 UTC (rev 211192)
+++ trunk/Source/WebCore/ChangeLog 2017-01-26 02:18:00 UTC (rev 211193)
@@ -1,3 +1,16 @@
+2017-01-25 Matt Rajca <[email protected]>
+
+ 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:
+
2017-01-25 Wenson Hsieh <[email protected]>
Refactor drag and drop implementation on Mac
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (211192 => 211193)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2017-01-26 02:01:29 UTC (rev 211192)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2017-01-26 02:18:00 UTC (rev 211193)
@@ -3167,7 +3167,8 @@
scheduleResolvePendingPlayPromises();
if (ScriptController::processingUserGestureForMedia() && m_preventedFromPlayingWithoutUserGesture) {
- // FIXME: notify clients a user gesture was made and started playback of an element that was otherwise prevented from playing.
+ if (Page* page = document().page())
+ page->chrome().client().didPlayMediaPreventedFromPlayingWithoutUserGesture();
m_preventedFromPlayingWithoutUserGesture = false;
}
Modified: trunk/Source/WebCore/page/ChromeClient.h (211192 => 211193)
--- trunk/Source/WebCore/page/ChromeClient.h 2017-01-26 02:01:29 UTC (rev 211192)
+++ trunk/Source/WebCore/page/ChromeClient.h 2017-01-26 02:18:00 UTC (rev 211193)
@@ -420,6 +420,7 @@
virtual bool shouldUseTiledBackingForFrameView(const FrameView&) const { return false; }
virtual void isPlayingMediaDidChange(MediaProducer::MediaStateFlags, uint64_t) { }
+ virtual void didPlayMediaPreventedFromPlayingWithoutUserGesture() { }
#if ENABLE(MEDIA_SESSION)
virtual void hasMediaSessionWithActiveMediaElementsDidChange(bool) { }
Modified: trunk/Source/WebKit2/ChangeLog (211192 => 211193)
--- trunk/Source/WebKit2/ChangeLog 2017-01-26 02:01:29 UTC (rev 211192)
+++ trunk/Source/WebKit2/ChangeLog 2017-01-26 02:18:00 UTC (rev 211193)
@@ -1,3 +1,23 @@
+2017-01-25 Matt Rajca <[email protected]>
+
+ 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:
+
2017-01-25 Wenson Hsieh <[email protected]>
Refactor drag and drop implementation on Mac
Modified: trunk/Source/WebKit2/UIProcess/API/APIUIClient.h (211192 => 211193)
--- trunk/Source/WebKit2/UIProcess/API/APIUIClient.h 2017-01-26 02:01:29 UTC (rev 211192)
+++ trunk/Source/WebKit2/UIProcess/API/APIUIClient.h 2017-01-26 02:18:00 UTC (rev 211193)
@@ -152,6 +152,7 @@
virtual void isPlayingAudioDidChange(WebKit::WebPageProxy&) { }
virtual void didBeginCaptureSession() { }
virtual void didEndCaptureSession() { }
+ virtual void didPlayMediaPreventedFromPlayingWithoutUserGesture(WebKit::WebPageProxy&) { }
#if ENABLE(MEDIA_SESSION)
virtual void mediaSessionMetadataDidChange(WebKit::WebPageProxy&, WebKit::WebMediaSessionMetadata*) { }
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (211192 => 211193)
--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp 2017-01-26 02:01:29 UTC (rev 211192)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp 2017-01-26 02:18:00 UTC (rev 211193)
@@ -2235,6 +2235,14 @@
m_client.didLosePointerLock(toAPI(page), m_client.base.clientInfo);
}
#endif
+
+ void didPlayMediaPreventedFromPlayingWithoutUserGesture(WebPageProxy& page) override
+ {
+ if (!m_client.didPlayMediaPreventedFromPlayingWithoutUserGesture)
+ return;
+
+ m_client.didPlayMediaPreventedFromPlayingWithoutUserGesture(toAPI(&page), m_client.base.clientInfo);
+ }
};
toImpl(pageRef)->setUIClient(std::make_unique<UIClient>(wkClient));
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPageUIClient.h (211192 => 211193)
--- trunk/Source/WebKit2/UIProcess/API/C/WKPageUIClient.h 2017-01-26 02:01:29 UTC (rev 211192)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPageUIClient.h 2017-01-26 02:18:00 UTC (rev 211193)
@@ -102,6 +102,7 @@
typedef void (*WKCheckUserMediaPermissionCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef userMediaDocumentOrigin, WKSecurityOriginRef topLevelDocumentOrigin, WKUserMediaPermissionCheckRef devicesRequest, const void *clientInfo);
typedef void (*WKPageDidClickAutoFillButtonCallback)(WKPageRef page, WKTypeRef userData, const void *clientInfo);
typedef void (*WKPageMediaSessionMetadataDidChangeCallback)(WKPageRef page, WKMediaSessionMetadataRef metadata, const void* clientInfo);
+typedef void (*WKDidPlayMediaPreventedFromPlayingWithoutUserGesture)(WKPageRef page, const void* clientInfo);
typedef void (*WKFullscreenMayReturnToInlineCallback)(WKPageRef page, const void* clientInfo);
typedef void (*WKRequestPointerLockCallback)(WKPageRef page, const void* clientInfo);
@@ -725,6 +726,7 @@
// Version 8.
WKRequestPointerLockCallback requestPointerLock;
WKDidLosePointerLockCallback didLosePointerLock;
+ WKDidPlayMediaPreventedFromPlayingWithoutUserGesture didPlayMediaPreventedFromPlayingWithoutUserGesture;
} WKPageUIClientV8;
#ifdef __cplusplus
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (211192 => 211193)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2017-01-26 02:01:29 UTC (rev 211192)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2017-01-26 02:18:00 UTC (rev 211193)
@@ -6527,6 +6527,11 @@
}
#endif
+void WebPageProxy::didPlayMediaPreventedFromPlayingWithoutUserGesture()
+{
+ m_uiClient->didPlayMediaPreventedFromPlayingWithoutUserGesture(*this);
+}
+
#if PLATFORM(MAC)
void WebPageProxy::removeNavigationGestureSnapshot()
{
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (211192 => 211193)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2017-01-26 02:01:29 UTC (rev 211192)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2017-01-26 02:18:00 UTC (rev 211193)
@@ -1058,6 +1058,7 @@
bool hasActiveAudioStream() const { return m_mediaState & WebCore::MediaProducer::HasActiveAudioCaptureDevice; }
bool hasActiveVideoStream() const { return m_mediaState & WebCore::MediaProducer::HasActiveVideoCaptureDevice; }
WebCore::MediaProducer::MediaStateFlags mediaStateFlags() const { return m_mediaState; }
+ void didPlayMediaPreventedFromPlayingWithoutUserGesture();
#if PLATFORM(MAC)
void videoControlsManagerDidChange();
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (211192 => 211193)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in 2017-01-26 02:01:29 UTC (rev 211192)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in 2017-01-26 02:18:00 UTC (rev 211193)
@@ -439,6 +439,7 @@
#endif
IsPlayingMediaDidChange(unsigned state, uint64_t sourceElementID)
+ DidPlayMediaPreventedFromPlayingWithoutUserGesture()
#if ENABLE(MEDIA_SESSION)
HasMediaSessionWithActiveMediaElementsDidChange(bool state)
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp (211192 => 211193)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp 2017-01-26 02:01:29 UTC (rev 211192)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp 2017-01-26 02:18:00 UTC (rev 211193)
@@ -1084,6 +1084,11 @@
m_page.send(Messages::WebPageProxy::IsPlayingMediaDidChange(state, sourceElementID));
}
+void WebChromeClient::didPlayMediaPreventedFromPlayingWithoutUserGesture()
+{
+ m_page.send(Messages::WebPageProxy::DidPlayMediaPreventedFromPlayingWithoutUserGesture());
+}
+
#if ENABLE(MEDIA_SESSION)
void WebChromeClient::hasMediaSessionWithActiveMediaElementsDidChange(bool state)
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h (211192 => 211193)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h 2017-01-26 02:01:29 UTC (rev 211192)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h 2017-01-26 02:18:00 UTC (rev 211193)
@@ -297,6 +297,7 @@
bool shouldUseTiledBackingForFrameView(const WebCore::FrameView&) const final;
void isPlayingMediaDidChange(WebCore::MediaProducer::MediaStateFlags, uint64_t) final;
+ void didPlayMediaPreventedFromPlayingWithoutUserGesture() final;
#if ENABLE(MEDIA_SESSION)
void hasMediaSessionWithActiveMediaElementsDidChange(bool) final;
Modified: trunk/Tools/ChangeLog (211192 => 211193)
--- trunk/Tools/ChangeLog 2017-01-26 02:01:29 UTC (rev 211192)
+++ trunk/Tools/ChangeLog 2017-01-26 02:18:00 UTC (rev 211193)
@@ -1,5 +1,27 @@
2017-01-25 Matt Rajca <[email protected]>
+ 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):
+
+2017-01-25 Matt Rajca <[email protected]>
+
[ios-simulator] API test WebKit2.WebsitePoliciesAutoplayEnabled timing out
https://bugs.webkit.org/show_bug.cgi?id=167385
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (211192 => 211193)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2017-01-26 02:01:29 UTC (rev 211192)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2017-01-26 02:18:00 UTC (rev 211193)
@@ -509,6 +509,9 @@
C95984F41E36BC6B002C0D45 /* autoplay-check.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C95984F21E36BC55002C0D45 /* autoplay-check.html */; };
C95984F51E36BC6B002C0D45 /* autoplay-no-audio-check.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C95984F31E36BC55002C0D45 /* autoplay-no-audio-check.html */; };
C95984F71E36BCEF002C0D45 /* test-without-audio-track.mp4 in Copy Resources */ = {isa = PBXBuildFile; fileRef = C95984F61E36BCD7002C0D45 /* test-without-audio-track.mp4 */; };
+ 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 */; };
CD59F53419E9110D00CF1835 /* file-with-mse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD59F53219E910AA00CF1835 /* file-with-mse.html */; };
CD59F53519E9110D00CF1835 /* test-mse.mp4 in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD59F53319E910BC00CF1835 /* test-mse.mp4 */; };
CD78E11D1DB7EA660014A2DE /* FullscreenDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD78E11A1DB7EA360014A2DE /* FullscreenDelegate.mm */; };
@@ -607,6 +610,9 @@
dstPath = TestWebKitAPI.resources;
dstSubfolderSpec = 7;
files = (
+ 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 */,
C95984F71E36BCEF002C0D45 /* test-without-audio-track.mp4 in Copy Resources */,
C95984F41E36BC6B002C0D45 /* autoplay-check.html in Copy Resources */,
C95984F51E36BC6B002C0D45 /* autoplay-no-audio-check.html in Copy Resources */,
@@ -1274,6 +1280,9 @@
C95984F21E36BC55002C0D45 /* autoplay-check.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autoplay-check.html"; sourceTree = "<group>"; };
C95984F31E36BC55002C0D45 /* autoplay-no-audio-check.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autoplay-no-audio-check.html"; sourceTree = "<group>"; };
C95984F61E36BCD7002C0D45 /* test-without-audio-track.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = "test-without-audio-track.mp4"; sourceTree = "<group>"; };
+ C99B675A1E3971FC00FC6C80 /* autoplay-with-controls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autoplay-with-controls.html"; sourceTree = "<group>"; };
+ C99B675B1E3971FC00FC6C80 /* js-play-with-controls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "js-play-with-controls.html"; sourceTree = "<group>"; };
+ C99B675E1E39735C00FC6C80 /* no-autoplay-with-controls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "no-autoplay-with-controls.html"; sourceTree = "<group>"; };
CD225C071C45A69200140761 /* ParsedContentRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParsedContentRange.cpp; sourceTree = "<group>"; };
CD5393C71757BA9700C07123 /* MD5.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MD5.cpp; sourceTree = "<group>"; };
CD5393C91757BAC400C07123 /* SHA1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SHA1.cpp; sourceTree = "<group>"; };
@@ -1961,6 +1970,7 @@
76E182DE15475A8300F1FADD /* auto-submitting-form.html */,
C95984F21E36BC55002C0D45 /* autoplay-check.html */,
C95984F31E36BC55002C0D45 /* autoplay-no-audio-check.html */,
+ C99B675A1E3971FC00FC6C80 /* autoplay-with-controls.html */,
7C486BA01AA1254B003F6F9B /* bundle-file.html */,
9BD4239B1E04BFD000200395 /* chinese-character-with-image.html */,
1A50AA1F1A2A4EA500F4C345 /* close-from-within-create-page.html */,
@@ -1981,6 +1991,7 @@
4A410F4D19AF7BEF002EBAB5 /* getUserMedia.html */,
BCBD372E125ABBE600D2C29F /* icon.png */,
CE3524F51B142BBB0028A7C5 /* input-focus-blur.html */,
+ C99B675B1E3971FC00FC6C80 /* js-play-with-controls.html */,
8349D3C31DB9724F004A9F65 /* link-with-download-attribute.html */,
378E647816326FDF00B6C676 /* link-with-title.html */,
9361002814DC957B0061379D /* lots-of-iframes.html */,
@@ -1991,6 +2002,7 @@
51CD1C711B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html */,
7A1458FB1AD5C03500E06772 /* mouse-button-listener.html */,
33E79E05137B5FCE00E32D99 /* mouse-move-listener.html */,
+ C99B675E1E39735C00FC6C80 /* no-autoplay-with-controls.html */,
CEA6CF2719CCF69D0064F5A7 /* open-and-close-window.html */,
F6FDDDD514241C48004F1729 /* push-state.html */,
CEBABD481B71687C0051210A /* should-open-external-schemes.html */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/autoplay-with-controls.html (0 => 211193)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/autoplay-with-controls.html (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/autoplay-with-controls.html 2017-01-26 02:18:00 UTC (rev 211193)
@@ -0,0 +1,19 @@
+<html>
+ <head>
+ <script>
+ function pageLoaded() {
+ try {
+ window.webkit.messageHandlers.testHandler.postMessage("loaded");
+ } catch(e) { }
+ }
+
+ function play() {
+ document.getElementById("video").play();
+ }
+ </script>
+ </head>
+ <body _onload_="pageLoaded()">
+ <button _onclick_="play()">Play</button>
+ <video id="video" autoplay src="" />
+ </body>
+</html>
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/js-play-with-controls.html (0 => 211193)
--- 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 02:18:00 UTC (rev 211193)
@@ -0,0 +1,20 @@
+<html>
+ <head>
+ <script>
+ function pageLoaded() {
+ document.getElementById("video").play();
+ try {
+ window.webkit.messageHandlers.testHandler.postMessage("loaded");
+ } catch(e) { }
+ }
+
+ function play() {
+ document.getElementById("video").play();
+ }
+ </script>
+ </head>
+ <body _onload_="pageLoaded()">
+ <button _onclick_="play()">Play</button>
+ <video id="video" src="" />
+ </body>
+</html>
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/no-autoplay-with-controls.html (0 => 211193)
--- 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 02:18:00 UTC (rev 211193)
@@ -0,0 +1,25 @@
+<html>
+ <head>
+ <script>
+ function pageLoaded() {
+ try {
+ window.webkit.messageHandlers.testHandler.postMessage("loaded");
+ } catch(e) { }
+ }
+
+ function beganPlaying() {
+ try {
+ window.webkit.messageHandlers.testHandler.postMessage("played");
+ } catch(e) { }
+ }
+
+ function play() {
+ document.getElementById("video").play();
+ }
+ </script>
+ </head>
+ <body _onload_="pageLoaded()">
+ <button _onclick_="play()">Play</button>
+ <video id="video" _onplaying_=beganPlaying() src="" />
+ </body>
+</html>
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm (211192 => 211193)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm 2017-01-26 02:01:29 UTC (rev 211192)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm 2017-01-26 02:18:00 UTC (rev 211193)
@@ -39,6 +39,10 @@
#if WK_API_ENABLED
+@interface WKWebView ()
+- (WKPageRef)_pageForTesting;
+@end
+
static bool doneCompiling;
static bool receivedAlert;
static size_t alertCount;
@@ -213,4 +217,59 @@
[webView waitForMessage:@"autoplayed"];
}
+#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()];
+
+ WKPageUIClientV8 uiClient;
+ memset(&uiClient, 0, sizeof(uiClient));
+
+ uiClient.base.version = 8;
+ uiClient.didPlayMediaPreventedFromPlayingWithoutUserGesture = didPlayMediaPreventedFromPlayingWithoutUserGesture;
+
+ WKPageSetPageUIClient([webView _pageForTesting], &uiClient.base);
+ NSPoint playButtonClickPoint = NSMakePoint(20, 256);
+
+ receivedAlert = false;
+ NSURLRequest *jsPlayRequest = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"js-play-with-controls" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+ [webView loadRequest:jsPlayRequest];
+ [webView waitForMessage:@"loaded"];
+ [webView mouseDownAtPoint:playButtonClickPoint simulatePressure:NO];
+ [webView mouseUpAtPoint:playButtonClickPoint];
+ TestWebKitAPI::Util::run(&receivedAlert);
+
+ receivedAlert = false;
+ [webView loadHTMLString:@"" baseURL:nil];
+
+ NSURLRequest *autoplayRequest = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"autoplay-with-controls" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+ [webView loadRequest:autoplayRequest];
+ [webView waitForMessage:@"loaded"];
+ [webView mouseDownAtPoint:playButtonClickPoint simulatePressure:NO];
+ [webView mouseUpAtPoint:playButtonClickPoint];
+ TestWebKitAPI::Util::run(&receivedAlert);
+
+ receivedAlert = false;
+ [webView loadHTMLString:@"" baseURL:nil];
+
+ NSURLRequest *noAutoplayRequest = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"no-autoplay-with-controls" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+ [webView loadRequest:noAutoplayRequest];
+ [webView waitForMessage:@"loaded"];
+ [webView mouseDownAtPoint:playButtonClickPoint simulatePressure:NO];
+ [webView mouseUpAtPoint:playButtonClickPoint];
+ [webView waitForMessage:@"played"];
+ ASSERT_FALSE(receivedAlert);
+}
#endif
+
+#endif
Modified: trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h (211192 => 211193)
--- trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h 2017-01-26 02:01:29 UTC (rev 211192)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h 2017-01-26 02:18:00 UTC (rev 211193)
@@ -44,6 +44,7 @@
@interface TestWKWebView (MacOnly)
// Simulates clicking with a pressure-sensitive device, if possible.
- (void)mouseDownAtPoint:(NSPoint)point simulatePressure:(BOOL)simulatePressure;
+- (void)mouseUpAtPoint:(NSPoint)point;
- (void)typeCharacter:(char)character;
@end
#endif
Modified: trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm (211192 => 211193)
--- trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm 2017-01-26 02:01:29 UTC (rev 211192)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm 2017-01-26 02:18:00 UTC (rev 211193)
@@ -120,6 +120,11 @@
}
#endif
}
+
+- (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]];
+}
#endif // PLATFORM(MAC)
- (BOOL)isKeyWindow
@@ -250,6 +255,11 @@
[_hostWindow _mouseDownAtPoint:point simulatePressure:simulatePressure];
}
+- (void)mouseUpAtPoint:(NSPoint)point
+{
+ [_hostWindow _mouseUpAtPoint:point];
+}
+
- (void)typeCharacter:(char)character {
NSString *characterAsString = [NSString stringWithFormat:@"%c" , character];
NSEventType keyDownEventType = NSEventTypeKeyDown;
Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (211192 => 211193)
--- trunk/Tools/WebKitTestRunner/TestController.cpp 2017-01-26 02:01:29 UTC (rev 211192)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp 2017-01-26 02:18:00 UTC (rev 211193)
@@ -279,6 +279,7 @@
0, // fullscreenMayReturnToInline
requestPointerLock,
0,
+ 0, // didPlayMediaPreventedFromPlayingWithoutUserGesture
};
WKPageSetPageUIClient(newPage, &otherPageUIClient.base);
@@ -551,6 +552,7 @@
0, // fullscreenMayReturnToInline
requestPointerLock,
0,
+ 0, // didPlayMediaPreventedFromPlayingWithoutUserGesture
};
WKPageSetPageUIClient(m_mainWebView->page(), &pageUIClient.base);