Diff
Modified: trunk/Source/WebCore/ChangeLog (211225 => 211226)
--- 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)
@@ -1,3 +1,16 @@
+2017-01-26 Matt Rajca <mra...@apple.com>
+
+ 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-26 Enrique Ocaña González <eoca...@igalia.com>
[GStreamer] ASSERTION FAILED: !g_object_is_floating(ptr) in adoptGRef(GstContext* ptr)
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (211225 => 211226)
--- 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)
@@ -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 (211225 => 211226)
--- 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)
@@ -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 (211225 => 211226)
--- 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)
@@ -1,3 +1,23 @@
+2017-01-26 Matt Rajca <mra...@apple.com>
+
+ 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-26 Anders Carlsson <ander...@apple.com>
Don't use _CFBundleCreateUnique on Yosemite, it's not available there
Modified: trunk/Source/WebKit2/UIProcess/API/APIUIClient.h (211225 => 211226)
--- 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)
@@ -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 (211225 => 211226)
--- 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)
@@ -110,7 +110,7 @@
};
template<> struct ClientTraits<WKPageUIClientBase> {
- typedef std::tuple<WKPageUIClientV0, WKPageUIClientV1, WKPageUIClientV2, WKPageUIClientV3, WKPageUIClientV4, WKPageUIClientV5, WKPageUIClientV6, WKPageUIClientV7, WKPageUIClientV8> Versions;
+ typedef std::tuple<WKPageUIClientV0, WKPageUIClientV1, WKPageUIClientV2, WKPageUIClientV3, WKPageUIClientV4, WKPageUIClientV5, WKPageUIClientV6, WKPageUIClientV7, WKPageUIClientV8, WKPageUIClientV9> Versions;
};
#if ENABLE(CONTEXT_MENUS)
@@ -2241,6 +2241,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 (211225 => 211226)
--- 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)
@@ -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);
@@ -726,6 +727,97 @@
WKRequestPointerLockCallback requestPointerLock;
WKDidLosePointerLockCallback didLosePointerLock;
} WKPageUIClientV8;
+
+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;
#ifdef __cplusplus
}
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (211225 => 211226)
--- 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)
@@ -6532,6 +6532,11 @@
}
#endif
+void WebPageProxy::didPlayMediaPreventedFromPlayingWithoutUserGesture()
+{
+ m_uiClient->didPlayMediaPreventedFromPlayingWithoutUserGesture(*this);
+}
+
#if PLATFORM(MAC)
void WebPageProxy::removeNavigationGestureSnapshot()
{
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (211225 => 211226)
--- 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)
@@ -1064,6 +1064,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 (211225 => 211226)
--- 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)
@@ -443,6 +443,7 @@
#endif
IsPlayingMediaDidChange(unsigned state, uint64_t sourceElementID)
+ DidPlayMediaPreventedFromPlayingWithoutUserGesture()
#if ENABLE(MEDIA_SESSION)
HasMediaSessionWithActiveMediaElementsDidChange(bool state)
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp (211225 => 211226)
--- 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)
@@ -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 (211225 => 211226)
--- 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)
@@ -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 (211225 => 211226)
--- trunk/Tools/ChangeLog 2017-01-26 20:39:57 UTC (rev 211225)
+++ trunk/Tools/ChangeLog 2017-01-26 20:41:13 UTC (rev 211226)
@@ -1,3 +1,25 @@
+2017-01-26 Matt Rajca <mra...@apple.com>
+
+ 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-26 Per Arne Vollan <pvol...@apple.com>
Crash when setting custom scale factor.
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (211225 => 211226)
--- 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)
@@ -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 => 211226)
--- 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)
@@ -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 => 211226)
--- 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)
@@ -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 => 211226)
--- 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)
@@ -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 (211225 => 211226)
--- 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)
@@ -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()];
+
+ WKPageUIClientV9 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 (211225 => 211226)
--- 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)
@@ -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 (211225 => 211226)
--- 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)
@@ -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;