Add/remove appropriate media element behavior restrictions when updateWebsitePolicies...
authormrajca@apple.com <mrajca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Jul 2017 23:19:31 +0000 (23:19 +0000)
committermrajca@apple.com <mrajca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Jul 2017 23:19:31 +0000 (23:19 +0000)
commit7433c6da51d04e621a450db4743aad3d8ef7cb0d
tree80ab0926af6031a3041a0d179c6623de576c8977
parent862f4f0c57d80cc134fa77ce0cdd85d44ff26c9d
Add/remove appropriate media element behavior restrictions when updateWebsitePolicies is called
https://bugs.webkit.org/show_bug.cgi?id=174103

Reviewed by Alex Christensen.

Source/WebCore:

Test: Added API test.

Added support for updating rate change behavior restrictions on media elements that have already
been created.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::updateRateChangeRestrictions):
* html/HTMLMediaElement.h:
* page/Page.cpp:
(WebCore::Page::updateMediaElementRateChangeRestrictions):
* page/Page.h:

Source/WebKit2:

Currently, when -[WKWebView evaluateJavaScript:completionHandler:] is invoked, we end up simulating
a user gesture unconditionally. This is not desireable for some tests, so I added a private variant
of this method that takes a boolean that is ultimately passed to `executeScript` for the
`forceUserGesture` parameter (instead of unconditionally passing `true`).

* UIProcess/API/C/WKPage.cpp:
(WKPageRunJavaScriptInMainFrame):
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView evaluateJavaScript:completionHandler:]):
(-[WKWebView _evaluateJavaScript:forceUserGesture:completionHandler:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::runJavaScriptInMainFrame):
* UIProcess/WebPageProxy.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::runJavaScriptInMainFrame):
(WebKit::WebPage::updateWebsitePolicies): Update behavior restrictions on any existing media elements.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Tools:

Added an API test.

* TestWebKitAPI/Tests/WebKit2/autoplay-check.html: Expose a pause method.
* TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm:
(TEST): Added test.
* TestWebKitAPI/cocoa/TestWKWebView.h:
* TestWebKitAPI/cocoa/TestWKWebView.mm:
(-[TestWKWebView stringByEvaluatingJavaScript:]): Don't simulate a user gesture when invoking the script.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219106 268f45cc-cd09-0410-ab3c-d52691b4dbfc
19 files changed:
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit2/UIProcess/API/glib/WebKitWebView.cpp
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit2/autoplay-check.html
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm
Tools/TestWebKitAPI/cocoa/TestWKWebView.mm