Diff
Modified: trunk/Source/WebKit/ChangeLog (254552 => 254553)
--- trunk/Source/WebKit/ChangeLog 2020-01-15 02:03:37 UTC (rev 254552)
+++ trunk/Source/WebKit/ChangeLog 2020-01-15 02:21:56 UTC (rev 254553)
@@ -1,3 +1,22 @@
+2020-01-14 Luming Yin <luming_...@apple.com>
+
+ Update API availability for autoplay event
+ https://bugs.webkit.org/show_bug.cgi?id=202214
+ <rdar://problem/55710395>
+
+ Reviewed by Tim Horton.
+
+ * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
+ Make enums and WKUIDelegate method related to autoplay event available on iOS.
+
+ * UIProcess/Cocoa/UIDelegate.h:
+ * UIProcess/Cocoa/UIDelegate.mm:
+ (WebKit::UIDelegate::setDelegate):
+ (WebKit::toWKAutoplayEventFlags):
+ (WebKit::toWKAutoplayEvent):
+ (WebKit::UIDelegate::UIClient::handleAutoplayEvent):
+ Make delegate methods related to autoplay events available on iOS.
+
2020-01-14 Tim Horton <timothy_hor...@apple.com>
REGRESSION (r253394): After swiping back during a navigation, WKWebView gets stuck with the forward content, stops repainting
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (254552 => 254553)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h 2020-01-15 02:03:37 UTC (rev 254552)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h 2020-01-15 02:21:56 UTC (rev 254553)
@@ -50,13 +50,6 @@
@protocol UIDragSession;
@protocol UIDropSession;
#else
-typedef NS_ENUM(NSInteger, _WKAutoplayEvent) {
- _WKAutoplayEventDidPreventFromAutoplaying,
- _WKAutoplayEventDidPlayMediaWithUserGesture,
- _WKAutoplayEventDidAutoplayMediaPastThresholdWithoutUserInterference,
- _WKAutoplayEventUserDidInterfereWithPlayback,
-} WK_API_AVAILABLE(macos(10.13.4));
-
typedef NS_ENUM(NSInteger, _WKResourceLimit) {
_WKResourceLimitMemory,
_WKResourceLimitCPU,
@@ -67,14 +60,21 @@
_WKPlugInUnavailabilityReasonPluginCrashed,
_WKPlugInUnavailabilityReasonInsecurePluginVersion
} WK_API_AVAILABLE(macos(10.13.4));
+#endif
+typedef NS_ENUM(NSInteger, _WKAutoplayEvent) {
+ _WKAutoplayEventDidPreventFromAutoplaying,
+ _WKAutoplayEventDidPlayMediaWithUserGesture,
+ _WKAutoplayEventDidAutoplayMediaPastThresholdWithoutUserInterference,
+ _WKAutoplayEventUserDidInterfereWithPlayback,
+} WK_API_AVAILABLE(macos(10.13.4), ios(WK_IOS_TBA));
+
typedef NS_OPTIONS(NSUInteger, _WKAutoplayEventFlags) {
_WKAutoplayEventFlagsNone = 0,
_WKAutoplayEventFlagsHasAudio = 1 << 0,
_WKAutoplayEventFlagsPlaybackWasPrevented = 1 << 1,
_WKAutoplayEventFlagsMediaIsMainContent = 1 << 2,
-} WK_API_AVAILABLE(macos(10.13.4));
-#endif
+} WK_API_AVAILABLE(macos(10.13.4), ios(WK_IOS_TBA));
typedef NS_ENUM(NSInteger, _WKFocusDirection) {
_WKFocusDirectionBackward,
@@ -140,6 +140,8 @@
- (void)_webView:(WKWebView *)webView runWebAuthenticationPanel:(_WKWebAuthenticationPanel *)panel initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(_WKWebAuthenticationPanelResult))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_webView:(WKWebView *)webView handleAutoplayEvent:(_WKAutoplayEvent)event withFlags:(_WKAutoplayEventFlags)flags WK_API_AVAILABLE(macos(10.13.4), ios(WK_IOS_TBA));
+
#if TARGET_OS_IPHONE
- (BOOL)_webView:(WKWebView *)webView shouldIncludeAppLinkActionsForElement:(_WKActivatedElementInfo *)element WK_API_AVAILABLE(ios(9.0));
- (NSArray *)_webView:(WKWebView *)webView actionsForElement:(_WKActivatedElementInfo *)element defaultActions:(NSArray<_WKElementAction *> *)defaultActions;
@@ -217,7 +219,6 @@
- (void)_webViewDidScroll:(WKWebView *)webView WK_API_AVAILABLE(macos(10.13.4));
- (void)_webViewRunModal:(WKWebView *)webView WK_API_AVAILABLE(macos(10.13.4));
- (void)_webView:(WKWebView *)webView didNotHandleWheelEvent:(NSEvent *)event WK_API_AVAILABLE(macos(10.13.4));
-- (void)_webView:(WKWebView *)webView handleAutoplayEvent:(_WKAutoplayEvent)event withFlags:(_WKAutoplayEventFlags)flags WK_API_AVAILABLE(macos(10.13.4));
- (void)_webView:(WKWebView *)webView didClickAutoFillButtonWithUserInfo:(id <NSSecureCoding>)userInfo WK_API_AVAILABLE(macos(10.13.4));
- (void)_webView:(WKWebView *)webView getToolbarsAreVisibleWithCompletionHandler:(void(^)(BOOL))completionHandler WK_API_AVAILABLE(macos(10.13.4));
- (void)_webView:(WKWebView *)webView saveDataToFile:(NSData *)data suggestedFilename:(NSString *)suggestedFilename mimeType:(NSString *)mimeType originatingURL:(NSURL *)url WK_API_AVAILABLE(macos(10.13.4));
Modified: trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h (254552 => 254553)
--- trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h 2020-01-15 02:03:37 UTC (rev 254552)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h 2020-01-15 02:21:56 UTC (rev 254553)
@@ -100,6 +100,7 @@
void reachedApplicationCacheOriginQuota(WebPageProxy*, const WebCore::SecurityOrigin&, uint64_t currentQuota, uint64_t totalBytesNeeded, Function<void(unsigned long long)>&& completionHandler) final;
void didResignInputElementStrongPasswordAppearance(WebPageProxy&, API::Object*) final;
bool takeFocus(WebPageProxy*, WKFocusDirection) final;
+ void handleAutoplayEvent(WebPageProxy&, WebCore::AutoplayEvent, OptionSet<WebCore::AutoplayEventFlags>) final;
#if PLATFORM(MAC)
void showPage(WebPageProxy*) final;
void focus(WebPageProxy*) final;
@@ -116,7 +117,6 @@
void drawHeader(WebPageProxy&, WebFrameProxy&, WebCore::FloatRect&&) final;
void drawFooter(WebPageProxy&, WebFrameProxy&, WebCore::FloatRect&&) final;
void decidePolicyForNotificationPermissionRequest(WebPageProxy&, API::SecurityOrigin&, Function<void(bool)>&&) final;
- void handleAutoplayEvent(WebPageProxy&, WebCore::AutoplayEvent, OptionSet<WebCore::AutoplayEventFlags>) final;
void unavailablePluginButtonClicked(WebPageProxy&, WKPluginUnavailabilityReason, API::Dictionary&) final;
void mouseDidMoveOverElement(WebPageProxy&, const WebHitTestResultData&, OptionSet<WebEvent::Modifier>, API::Object*);
void didClickAutoFillButton(WebPageProxy&, API::Object*) final;
@@ -176,6 +176,7 @@
bool webViewRequestGeolocationPermissionForFrameDecisionHandler : 1;
bool webViewDidResignInputElementStrongPasswordAppearanceWithUserInfo : 1;
bool webViewTakeFocus : 1;
+ bool webViewHandleAutoplayEventWithFlags : 1;
#if PLATFORM(MAC)
bool showWebView : 1;
bool focusWebView : 1;
@@ -187,7 +188,6 @@
bool webViewSetResizable : 1;
bool webViewSetWindowFrame : 1;
bool webViewDidNotHandleWheelEvent : 1;
- bool webViewHandleAutoplayEventWithFlags : 1;
bool webViewUnavailablePlugInButtonClicked : 1;
bool webViewDidClickAutoFillButtonWithUserInfo : 1;
bool webViewDrawHeaderInRectForPageWithTitleURL : 1;
Modified: trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm (254552 => 254553)
--- trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm 2020-01-15 02:03:37 UTC (rev 254552)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm 2020-01-15 02:21:56 UTC (rev 254553)
@@ -109,6 +109,7 @@
m_delegateMethods.webViewRequestGeolocationPermissionForFrameDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestGeolocationPermissionForFrame:decisionHandler:)];
m_delegateMethods.webViewDidResignInputElementStrongPasswordAppearanceWithUserInfo = [delegate respondsToSelector:@selector(_webView:didResignInputElementStrongPasswordAppearanceWithUserInfo:)];
m_delegateMethods.webViewTakeFocus = [delegate respondsToSelector:@selector(_webView:takeFocus:)];
+ m_delegateMethods.webViewHandleAutoplayEventWithFlags = [delegate respondsToSelector:@selector(_webView:handleAutoplayEvent:withFlags:)];
#if PLATFORM(MAC)
m_delegateMethods.showWebView = [delegate respondsToSelector:@selector(_showWebView:)];
@@ -122,7 +123,6 @@
m_delegateMethods.webViewGetWindowFrameWithCompletionHandler = [delegate respondsToSelector:@selector(_webView:getWindowFrameWithCompletionHandler:)];
m_delegateMethods.webViewSetWindowFrame = [delegate respondsToSelector:@selector(_webView:setWindowFrame:)];
m_delegateMethods.webViewUnavailablePlugInButtonClicked = [delegate respondsToSelector:@selector(_webView:unavailablePlugInButtonClickedWithReason:plugInInfo:)];
- m_delegateMethods.webViewHandleAutoplayEventWithFlags = [delegate respondsToSelector:@selector(_webView:handleAutoplayEvent:withFlags:)];
m_delegateMethods.webViewDidClickAutoFillButtonWithUserInfo = [delegate respondsToSelector:@selector(_webView:didClickAutoFillButtonWithUserInfo:)];
m_delegateMethods.webViewDrawHeaderInRectForPageWithTitleURL = [delegate respondsToSelector:@selector(_webView:drawHeaderInRect:forPageWithTitle:URL:)];
m_delegateMethods.webViewDrawFooterInRectForPageWithTitleURL = [delegate respondsToSelector:@selector(_webView:drawFooterInRect:forPageWithTitle:URL:)];
@@ -486,6 +486,47 @@
return true;
}
+static _WKAutoplayEventFlags toWKAutoplayEventFlags(OptionSet<WebCore::AutoplayEventFlags> flags)
+{
+ _WKAutoplayEventFlags wkFlags = _WKAutoplayEventFlagsNone;
+ if (flags.contains(WebCore::AutoplayEventFlags::HasAudio))
+ wkFlags |= _WKAutoplayEventFlagsHasAudio;
+ if (flags.contains(WebCore::AutoplayEventFlags::PlaybackWasPrevented))
+ wkFlags |= _WKAutoplayEventFlagsPlaybackWasPrevented;
+ if (flags.contains(WebCore::AutoplayEventFlags::MediaIsMainContent))
+ wkFlags |= _WKAutoplayEventFlagsMediaIsMainContent;
+
+ return wkFlags;
+}
+
+static _WKAutoplayEvent toWKAutoplayEvent(WebCore::AutoplayEvent event)
+{
+ switch (event) {
+ case WebCore::AutoplayEvent::DidPreventMediaFromPlaying:
+ return _WKAutoplayEventDidPreventFromAutoplaying;
+ case WebCore::AutoplayEvent::DidPlayMediaWithUserGesture:
+ return _WKAutoplayEventDidPlayMediaWithUserGesture;
+ case WebCore::AutoplayEvent::DidAutoplayMediaPastThresholdWithoutUserInterference:
+ return _WKAutoplayEventDidAutoplayMediaPastThresholdWithoutUserInterference;
+ case WebCore::AutoplayEvent::UserDidInterfereWithPlayback:
+ return _WKAutoplayEventUserDidInterfereWithPlayback;
+ }
+ ASSERT_NOT_REACHED();
+ return _WKAutoplayEventDidPlayMediaWithUserGesture;
+}
+
+void UIDelegate::UIClient::handleAutoplayEvent(WebPageProxy&, WebCore::AutoplayEvent event, OptionSet<WebCore::AutoplayEventFlags> flags)
+{
+ if (!m_uiDelegate.m_delegateMethods.webViewHandleAutoplayEventWithFlags)
+ return;
+
+ auto delegate = m_uiDelegate.m_delegate.get();
+ if (!delegate)
+ return;
+
+ [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView handleAutoplayEvent:toWKAutoplayEvent(event) withFlags:toWKAutoplayEventFlags(flags)];
+}
+
#if PLATFORM(MAC)
bool UIDelegate::UIClient::canRunModal() const
{
@@ -704,35 +745,6 @@
[(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView mouseDidMoveOverElement:wrapper(apiHitTestResult.get()) withFlags:WebEventFactory::toNSEventModifierFlags(modifiers) userInfo:userInfo ? static_cast<id <NSSecureCoding>>(userInfo->wrapper()) : nil];
}
-static _WKAutoplayEventFlags toWKAutoplayEventFlags(OptionSet<WebCore::AutoplayEventFlags> flags)
-{
- _WKAutoplayEventFlags wkFlags = _WKAutoplayEventFlagsNone;
- if (flags.contains(WebCore::AutoplayEventFlags::HasAudio))
- wkFlags |= _WKAutoplayEventFlagsHasAudio;
- if (flags.contains(WebCore::AutoplayEventFlags::PlaybackWasPrevented))
- wkFlags |= _WKAutoplayEventFlagsPlaybackWasPrevented;
- if (flags.contains(WebCore::AutoplayEventFlags::MediaIsMainContent))
- wkFlags |= _WKAutoplayEventFlagsMediaIsMainContent;
-
- return wkFlags;
-}
-
-static _WKAutoplayEvent toWKAutoplayEvent(WebCore::AutoplayEvent event)
-{
- switch (event) {
- case WebCore::AutoplayEvent::DidPreventMediaFromPlaying:
- return _WKAutoplayEventDidPreventFromAutoplaying;
- case WebCore::AutoplayEvent::DidPlayMediaWithUserGesture:
- return _WKAutoplayEventDidPlayMediaWithUserGesture;
- case WebCore::AutoplayEvent::DidAutoplayMediaPastThresholdWithoutUserInterference:
- return _WKAutoplayEventDidAutoplayMediaPastThresholdWithoutUserInterference;
- case WebCore::AutoplayEvent::UserDidInterfereWithPlayback:
- return _WKAutoplayEventUserDidInterfereWithPlayback;
- }
- ASSERT_NOT_REACHED();
- return _WKAutoplayEventDidPlayMediaWithUserGesture;
-}
-
void UIDelegate::UIClient::toolbarsAreVisible(WebPageProxy&, Function<void(bool)>&& completionHandler)
{
if (!m_uiDelegate.m_delegateMethods.webViewGetToolbarsAreVisibleWithCompletionHandler)
@@ -762,18 +774,6 @@
[(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView didClickAutoFillButtonWithUserInfo:userInfo ? static_cast<id <NSSecureCoding>>(userInfo->wrapper()) : nil];
}
-void UIDelegate::UIClient::handleAutoplayEvent(WebPageProxy&, WebCore::AutoplayEvent event, OptionSet<WebCore::AutoplayEventFlags> flags)
-{
- if (!m_uiDelegate.m_delegateMethods.webViewHandleAutoplayEventWithFlags)
- return;
-
- auto delegate = m_uiDelegate.m_delegate.get();
- if (!delegate)
- return;
-
- [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView handleAutoplayEvent:toWKAutoplayEvent(event) withFlags:toWKAutoplayEventFlags(flags)];
-}
-
void UIDelegate::UIClient::showPage(WebPageProxy*)
{
if (!m_uiDelegate.m_delegateMethods.showWebView)
Modified: trunk/Tools/ChangeLog (254552 => 254553)
--- trunk/Tools/ChangeLog 2020-01-15 02:03:37 UTC (rev 254552)
+++ trunk/Tools/ChangeLog 2020-01-15 02:21:56 UTC (rev 254553)
@@ -1,3 +1,27 @@
+2020-01-14 Luming Yin <luming_...@apple.com>
+
+ Update API availability for autoplay event
+ https://bugs.webkit.org/show_bug.cgi?id=202214
+ <rdar://problem/55710395>
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/Tests/WebKit/js-play-with-controls.html:
+ * TestWebKitAPI/Tests/WebKitCocoa/audio-with-play-button.html:
+ * TestWebKitAPI/Tests/WebKitCocoa/video-with-play-button.html:
+ Provide an id for each play button on various testing pages so that they can be triggered on iOS.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm:
+ (-[AutoplayPoliciesDelegate _webView:handleAutoplayEvent:withFlags:]):
+ (-[AsyncAutoplayPoliciesDelegate _webView:handleAutoplayEvent:withFlags:]):
+ (TEST):
+ Enable tests related to autoplay policy on iOS.
+
+ * TestWebKitAPI/cocoa/TestWKWebView.h:
+ * TestWebKitAPI/cocoa/TestWKWebView.mm:
+ (-[TestWKWebView clickOnElementID:]):
+ Helper method that performs a click on a given element ID.
+
2020-01-14 Jonathan Bedard <jbed...@apple.com>
EWS: Run webkitpy tests with Python 2 and 3
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit/js-play-with-controls.html (254552 => 254553)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit/js-play-with-controls.html 2020-01-15 02:03:37 UTC (rev 254552)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/js-play-with-controls.html 2020-01-15 02:21:56 UTC (rev 254553)
@@ -34,8 +34,8 @@
</script>
</head>
<body _onload_="pageLoaded()">
- <button _onclick_="play()">Play</button>
- <button _onclick_="mute()">Mute</button>
+ <button id="playButton" _onclick_="play()">Play</button>
+ <button id="muteButton" _onclick_="mute()">Mute</button>
<video id="video" _onplaying_=beganPlaying() _onended_=endedPlaying() src="" />
</body>
</html>
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm (254552 => 254553)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm 2020-01-15 02:03:37 UTC (rev 254552)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm 2020-01-15 02:21:56 UTC (rev 254553)
@@ -63,10 +63,8 @@
static bool receivedAlert;
static bool finishedNavigation;
-#if PLATFORM(MAC)
static Optional<_WKAutoplayEvent> receivedAutoplayEvent;
static Optional<_WKAutoplayEventFlags> receivedAutoplayEventFlags;
-#endif
static size_t alertCount;
@@ -198,13 +196,11 @@
decisionHandler(WKNavigationActionPolicyAllow, websitePolicies);
}
-#if PLATFORM(MAC)
- (void)_webView:(WKWebView *)webView handleAutoplayEvent:(_WKAutoplayEvent)event withFlags:(_WKAutoplayEventFlags)flags
{
receivedAutoplayEventFlags = flags;
receivedAutoplayEvent = event;
}
-#endif
@end
@@ -234,13 +230,11 @@
});
}
-#if PLATFORM(MAC)
- (void)_webView:(WKWebView *)webView handleAutoplayEvent:(_WKAutoplayEvent)event withFlags:(_WKAutoplayEventFlags)flags
{
receivedAutoplayEventFlags = flags;
receivedAutoplayEvent = event;
}
-#endif
@end
@@ -265,7 +259,8 @@
auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
#if PLATFORM(IOS_FAMILY)
- [configuration setAllowsInlineMediaPlayback:YES];
+ configuration.get().allowsInlineMediaPlayback = YES;
+ configuration.get()._inlineMediaPlaybackRequiresPlaysInlineAttribute = NO;
#endif
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
@@ -354,7 +349,6 @@
[webView waitForMessage:@"did-not-play"];
}
-#if PLATFORM(MAC)
static void runUntilReceivesAutoplayEvent(WKAutoplayEvent event)
{
while (!receivedAutoplayEvent || *receivedAutoplayEvent != event)
@@ -361,6 +355,7 @@
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.1, true);
}
+#if PLATFORM(MAC)
TEST(WebpagePreferences, WebsitePoliciesPlayAfterPreventedAutoplay)
{
auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
@@ -431,10 +426,16 @@
ASSERT_TRUE(*receivedAutoplayEventFlags & kWKAutoplayEventFlagsHasAudio);
ASSERT_TRUE(*receivedAutoplayEventFlags & kWKAutoplayEventFlagsPlaybackWasPrevented);
}
+#endif
TEST(WebpagePreferences, WebsitePoliciesPlayingWithUserGesture)
{
auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+#if PLATFORM(IOS_FAMILY)
+ configuration.get().allowsInlineMediaPlayback = YES;
+ configuration.get()._inlineMediaPlaybackRequiresPlaysInlineAttribute = NO;
+#endif
+
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
auto delegate = adoptNS([[AutoplayPoliciesDelegate alloc] init]);
@@ -446,13 +447,20 @@
receivedAutoplayEvent = WTF::nullopt;
+#if PLATFORM(MAC)
NSPoint playButtonClickPoint = NSMakePoint(20, 580);
+#endif
NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"audio-with-play-button" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
[webView loadRequest:request];
[webView waitForMessage:@"loaded"];
+
+#if PLATFORM(MAC)
[webView mouseDownAtPoint:playButtonClickPoint simulatePressure:NO];
[webView mouseUpAtPoint:playButtonClickPoint];
+#else
+ [webView clickOnElementID:@"playButton"];
+#endif
runUntilReceivesAutoplayEvent(kWKAutoplayEventDidPlayMediaWithUserGesture);
ASSERT_TRUE(*receivedAutoplayEventFlags & kWKAutoplayEventFlagsHasAudio);
@@ -463,8 +471,13 @@
request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"video-with-play-button" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
[webView loadRequest:request];
[webView waitForMessage:@"loaded"];
+
+#if PLATFORM(MAC)
[webView mouseDownAtPoint:playButtonClickPoint simulatePressure:NO];
[webView mouseUpAtPoint:playButtonClickPoint];
+#else
+ [webView clickOnElementID:@"playButton"];
+#endif
runUntilReceivesAutoplayEvent(kWKAutoplayEventDidPlayMediaWithUserGesture);
ASSERT_TRUE(*receivedAutoplayEventFlags & kWKAutoplayEventFlagsHasAudio);
@@ -474,6 +487,11 @@
TEST(WebpagePreferences, WebsitePoliciesPlayingWithoutInterference)
{
auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+#if PLATFORM(IOS_FAMILY)
+ configuration.get().allowsInlineMediaPlayback = YES;
+ configuration.get()._inlineMediaPlaybackRequiresPlaysInlineAttribute = NO;
+#endif
+
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 336, 276) configuration:configuration.get()]);
auto delegate = adoptNS([[AutoplayPoliciesDelegate alloc] init]);
@@ -493,6 +511,11 @@
TEST(WebpagePreferences, WebsitePoliciesUserInterferenceWithPlaying)
{
auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+#if PLATFORM(IOS_FAMILY)
+ configuration.get().allowsInlineMediaPlayback = YES;
+ configuration.get()._inlineMediaPlaybackRequiresPlaysInlineAttribute = NO;
+#endif
+
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 336, 276) configuration:configuration.get()]);
auto delegate = adoptNS([[AutoplayPoliciesDelegate alloc] init]);
@@ -517,9 +540,14 @@
[webView waitForMessage:@"playing"];
ASSERT_TRUE(receivedAutoplayEvent == WTF::nullopt);
+#if PLATFORM(MAC)
const NSPoint muteButtonClickPoint = NSMakePoint(80, 256);
[webView mouseDownAtPoint:muteButtonClickPoint simulatePressure:NO];
[webView mouseUpAtPoint:muteButtonClickPoint];
+#else
+ [webView clickOnElementID:@"muteButton"];
+#endif
+
runUntilReceivesAutoplayEvent(kWKAutoplayEventUserDidInterfereWithPlayback);
ASSERT_TRUE(*receivedAutoplayEventFlags & kWKAutoplayEventFlagsHasAudio);
@@ -528,13 +556,19 @@
[webView waitForMessage:@"playing"];
ASSERT_TRUE(receivedAutoplayEvent == WTF::nullopt);
+#if PLATFORM(MAC)
const NSPoint playButtonClickPoint = NSMakePoint(20, 256);
[webView mouseDownAtPoint:playButtonClickPoint simulatePressure:NO];
[webView mouseUpAtPoint:playButtonClickPoint];
+#else
+ [webView clickOnElementID:@"playButton"];
+#endif
+
runUntilReceivesAutoplayEvent(kWKAutoplayEventUserDidInterfereWithPlayback);
ASSERT_TRUE(*receivedAutoplayEventFlags & kWKAutoplayEventFlagsHasAudio);
}
+#if PLATFORM(MAC)
TEST(WebpagePreferences, WebsitePoliciesPerDocumentAutoplayBehaviorMediaLoading)
{
auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
@@ -713,10 +747,16 @@
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"test:///should-redirect"]]];
[webView waitForMessage:@"autoplayed"];
}
+#endif // PLATFORM(MAC)
TEST(WebpagePreferences, WebsitePoliciesUpdates)
{
auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+#if PLATFORM(IOS_FAMILY)
+ configuration.get().allowsInlineMediaPlayback = YES;
+ configuration.get()._inlineMediaPlaybackRequiresPlaysInlineAttribute = NO;
+#endif
+
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
auto delegate = adoptNS([[AutoplayPoliciesDelegate alloc] init]);
[webView setNavigationDelegate:delegate.get()];
@@ -750,6 +790,7 @@
runUntilReceivesAutoplayEvent(kWKAutoplayEventDidPreventFromAutoplaying);
}
+#if PLATFORM(MAC)
TEST(WebpagePreferences, WebsitePoliciesArbitraryUserGestureQuirk)
{
auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
@@ -903,19 +944,21 @@
[webView _evaluateJavaScriptWithoutUserGesture:@"playVideo('video2')" completionHandler:nil];
[webView waitForMessage:@"did-not-play-video2"];
}
+#endif
TEST(WebpagePreferences, WebsitePoliciesAutoplayQuirksAsyncPolicyDelegate)
{
auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+#if PLATFORM(IOS_FAMILY)
+ configuration.get().allowsInlineMediaPlayback = YES;
+ configuration.get()._inlineMediaPlaybackRequiresPlaysInlineAttribute = NO;
+#endif
+ [configuration preferences]._needsSiteSpecificQuirks = YES;
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
auto delegate = adoptNS([[AsyncAutoplayPoliciesDelegate alloc] init]);
[webView setNavigationDelegate:delegate.get()];
- WKRetainPtr<WKPreferencesRef> preferences = adoptWK(WKPreferencesCreate());
- WKPreferencesSetNeedsSiteSpecificQuirks(preferences.get(), true);
- WKPageGroupSetPreferences(WKPageGetPageGroup([webView _pageForTesting]), preferences.get());
-
NSURLRequest *requestWithAudio = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"autoplay-check" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
[delegate setAllowedAutoplayQuirksForURL:^_WKWebsiteAutoplayQuirk(NSURL *url) {
@@ -946,7 +989,6 @@
[webView waitForMessage:@"did-not-play"];
[webView waitForMessage:@"on-pause"];
}
-#endif // PLATFORM(MAC)
TEST(WebpagePreferences, InvalidCustomHeaders)
{
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/audio-with-play-button.html (254552 => 254553)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/audio-with-play-button.html 2020-01-15 02:03:37 UTC (rev 254552)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/audio-with-play-button.html 2020-01-15 02:21:56 UTC (rev 254553)
@@ -21,7 +21,7 @@
</script>
</head>
<body _onload_="pageLoaded()">
- <button _onclick_="play()">Play</button>
+ <button id="playButton" _onclick_="play()">Play</button>
<br />
<audio controls id="audio" _onplaying_="beganPlaying()" src="" />
</body>
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/video-with-play-button.html (254552 => 254553)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/video-with-play-button.html 2020-01-15 02:03:37 UTC (rev 254552)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/video-with-play-button.html 2020-01-15 02:21:56 UTC (rev 254553)
@@ -21,7 +21,7 @@
</script>
</head>
<body _onload_="pageLoaded()">
- <button _onclick_="play()">Play</button>
+ <button id="playButton" _onclick_="play()">Play</button>
<br />
<video controls id="video" _onplaying_="beganPlaying()" src=""
</body>
Modified: trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h (254552 => 254553)
--- trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h 2020-01-15 02:03:37 UTC (rev 254552)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h 2020-01-15 02:21:56 UTC (rev 254553)
@@ -86,6 +86,7 @@
- (void)collapseToEnd;
- (void)addToTestWindow;
- (BOOL)selectionRangeHasStartOffset:(int)start endOffset:(int)end;
+- (void)clickOnElementID:(NSString *)elementID;
@end
#if PLATFORM(IOS_FAMILY)
Modified: trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm (254552 => 254553)
--- trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm 2020-01-15 02:03:37 UTC (rev 254552)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm 2020-01-15 02:21:56 UTC (rev 254553)
@@ -515,6 +515,11 @@
return matches;
}
+- (void)clickOnElementID:(NSString *)elementID
+{
+ [self evaluateJavaScript:[NSString stringWithFormat:@"document.getElementById('%@').click();", elementID] completionHandler:nil];
+}
+
#if PLATFORM(IOS_FAMILY)
- (void)didStartFormControlInteraction