Title: [223684] branches/safari-604-branch

Diff

Modified: branches/safari-604-branch/Source/WebCore/ChangeLog (223683 => 223684)


--- branches/safari-604-branch/Source/WebCore/ChangeLog	2017-10-19 08:27:10 UTC (rev 223683)
+++ branches/safari-604-branch/Source/WebCore/ChangeLog	2017-10-19 08:37:41 UTC (rev 223684)
@@ -1,5 +1,25 @@
 2017-10-19  Jason Marcell  <jmarc...@apple.com>
 
+        Cherry-pick r223451. rdar://problem/34985194
+
+    2017-10-12  Matt Rajca  <mra...@apple.com>
+
+            Add API support for quirk that lets an arbitrary click allow auto-play.
+            https://bugs.webkit.org/show_bug.cgi?id=178227
+
+            Reviewed by Alex Christensen.
+
+            Added API test.
+
+            Instead of hardcoding sites in WebCore, let API clients control which websites opt into the quirk that lets
+            an arbitrary click allow auto-play via website policies.
+
+            * html/MediaElementSession.cpp:
+            (WebCore::needsArbitraryUserGestureAutoplayQuirk):
+            * loader/DocumentLoader.h:
+
+2017-10-19  Jason Marcell  <jmarc...@apple.com>
+
         Cherry-pick r223436. rdar://problem/35061711
 
     2017-10-16  Chris Dumez  <cdu...@apple.com>

Modified: branches/safari-604-branch/Source/WebCore/html/MediaElementSession.cpp (223683 => 223684)


--- branches/safari-604-branch/Source/WebCore/html/MediaElementSession.cpp	2017-10-19 08:27:10 UTC (rev 223683)
+++ branches/safari-604-branch/Source/WebCore/html/MediaElementSession.cpp	2017-10-19 08:37:41 UTC (rev 223684)
@@ -30,6 +30,7 @@
 #include "MediaElementSession.h"
 
 #include "Document.h"
+#include "DocumentLoader.h"
 #include "Frame.h"
 #include "FrameView.h"
 #include "HTMLAudioElement.h"
@@ -154,8 +155,8 @@
     if (!document.settings().needsSiteSpecificQuirks())
         return false;
 
-    auto host = document.url().host();
-    return equalLettersIgnoringASCIICase(host, "washingtonpost.com") || host.endsWithIgnoringASCIICase(".washingtonpost.com");
+    auto* loader = document.loader();
+    return loader && loader->allowedAutoplayQuirks().contains(AutoplayQuirk::ArbitraryUserGestures);
 }
 #endif // PLATFORM(MAC)
 

Modified: branches/safari-604-branch/Source/WebCore/loader/DocumentLoader.h (223683 => 223684)


--- branches/safari-604-branch/Source/WebCore/loader/DocumentLoader.h	2017-10-19 08:27:10 UTC (rev 223683)
+++ branches/safari-604-branch/Source/WebCore/loader/DocumentLoader.h	2017-10-19 08:37:41 UTC (rev 223684)
@@ -90,6 +90,7 @@
 enum class AutoplayQuirk {
     SynthesizedPauseEvents = 1 << 0,
     InheritedUserGestures = 1 << 1,
+    ArbitraryUserGestures = 1 << 2,
 };
 
 class DocumentLoader : public RefCounted<DocumentLoader>, public FrameDestructionObserver, private CachedRawResourceClient {

Modified: branches/safari-604-branch/Source/WebKit/ChangeLog (223683 => 223684)


--- branches/safari-604-branch/Source/WebKit/ChangeLog	2017-10-19 08:27:10 UTC (rev 223683)
+++ branches/safari-604-branch/Source/WebKit/ChangeLog	2017-10-19 08:37:41 UTC (rev 223684)
@@ -1,5 +1,33 @@
 2017-10-19  Jason Marcell  <jmarc...@apple.com>
 
+        Cherry-pick r223451. rdar://problem/34985194
+
+    2017-10-12  Matt Rajca  <mra...@apple.com>
+
+            Add API support for quirk that lets an arbitrary click allow auto-play.
+            https://bugs.webkit.org/show_bug.cgi?id=178227
+
+            Reviewed by Alex Christensen.
+
+            Instead of hardcoding sites in WebCore, let API clients control which websites opt into the quirk that lets
+            an arbitrary click allow auto-play via website policies.
+
+            * Shared/WebsitePolicies.h:
+            * UIProcess/API/C/WKWebsitePolicies.cpp:
+            (WKWebsitePoliciesSetAllowedAutoplayQuirks):
+            (WKWebsitePoliciesGetAllowedAutoplayQuirks):
+            * UIProcess/API/C/WKWebsitePolicies.h:
+            * UIProcess/API/Cocoa/_WKWebsitePolicies.h:
+            * UIProcess/API/Cocoa/_WKWebsitePolicies.mm:
+            (-[_WKWebsitePolicies setAllowedAutoplayQuirks:]):
+            (-[_WKWebsitePolicies allowedAutoplayQuirks]):
+            * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+            (WebKit::WebFrameLoaderClient::applyToDocumentLoader):
+            * WebProcess/WebPage/WebPage.cpp:
+            (WebKit::WebPage::updateWebsitePolicies):
+
+2017-10-19  Jason Marcell  <jmarc...@apple.com>
+
         Cherry-pick r223436. rdar://problem/35061711
 
     2017-10-16  Chris Dumez  <cdu...@apple.com>

Modified: branches/safari-604-branch/Source/WebKit/Shared/WebsitePolicies.h (223683 => 223684)


--- branches/safari-604-branch/Source/WebKit/Shared/WebsitePolicies.h	2017-10-19 08:27:10 UTC (rev 223683)
+++ branches/safari-604-branch/Source/WebKit/Shared/WebsitePolicies.h	2017-10-19 08:37:41 UTC (rev 223684)
@@ -39,6 +39,7 @@
 enum class WebsiteAutoplayQuirk {
     SynthesizedPauseEvents = 1 << 0,
     InheritedUserGestures = 1 << 1,
+    ArbitraryUserGestures = 1 << 2,
 };
 
 struct WebsitePolicies {

Modified: branches/safari-604-branch/Source/WebKit/UIProcess/API/C/WKWebsitePolicies.cpp (223683 => 223684)


--- branches/safari-604-branch/Source/WebKit/UIProcess/API/C/WKWebsitePolicies.cpp	2017-10-19 08:27:10 UTC (rev 223683)
+++ branches/safari-604-branch/Source/WebKit/UIProcess/API/C/WKWebsitePolicies.cpp	2017-10-19 08:37:41 UTC (rev 223684)
@@ -61,6 +61,9 @@
     if (allowedQuirks & kWKWebsiteAutoplayQuirkSynthesizedPauseEvents)
         quirks |= WebsiteAutoplayQuirk::SynthesizedPauseEvents;
 
+    if (allowedQuirks & kWKWebsiteAutoplayQuirkArbitraryUserGestures)
+        quirks |= WebsiteAutoplayQuirk::ArbitraryUserGestures;
+
     toImpl(websitePolicies)->setAllowedAutoplayQuirks(quirks);
 }
 
@@ -75,6 +78,9 @@
     if (allowedQuirks.contains(WebsiteAutoplayQuirk::InheritedUserGestures))
         quirks |= kWKWebsiteAutoplayQuirkInheritedUserGestures;
 
+    if (allowedQuirks.contains(WebsiteAutoplayQuirk::ArbitraryUserGestures))
+        quirks |= kWKWebsiteAutoplayQuirkArbitraryUserGestures;
+
     return quirks;
 }
 

Modified: branches/safari-604-branch/Source/WebKit/UIProcess/API/C/WKWebsitePolicies.h (223683 => 223684)


--- branches/safari-604-branch/Source/WebKit/UIProcess/API/C/WKWebsitePolicies.h	2017-10-19 08:27:10 UTC (rev 223683)
+++ branches/safari-604-branch/Source/WebKit/UIProcess/API/C/WKWebsitePolicies.h	2017-10-19 08:37:41 UTC (rev 223684)
@@ -44,6 +44,7 @@
 enum {
     kWKWebsiteAutoplayQuirkSynthesizedPauseEvents = 1 << 0,
     kWKWebsiteAutoplayQuirkInheritedUserGestures = 1 << 1,
+    kWKWebsiteAutoplayQuirkArbitraryUserGestures = 1 << 2,
 };
 
 WK_EXPORT WKWebsitePoliciesRef WKWebsitePoliciesCreate();

Modified: branches/safari-604-branch/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h (223683 => 223684)


--- branches/safari-604-branch/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h	2017-10-19 08:27:10 UTC (rev 223683)
+++ branches/safari-604-branch/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h	2017-10-19 08:37:41 UTC (rev 223684)
@@ -37,6 +37,7 @@
 typedef NS_OPTIONS(NSUInteger, _WKWebsiteAutoplayQuirk) {
     _WKWebsiteAutoplayQuirkSynthesizedPauseEvents = 1 << 0,
     _WKWebsiteAutoplayQuirkInheritedUserGestures = 1 << 1,
+    _WKWebsiteAutoplayQuirkArbitraryUserGestures = 1 << 2,
 } WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 WK_CLASS_AVAILABLE(macosx(10.12.3), ios(10.3))

Modified: branches/safari-604-branch/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm (223683 => 223684)


--- branches/safari-604-branch/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm	2017-10-19 08:27:10 UTC (rev 223683)
+++ branches/safari-604-branch/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm	2017-10-19 08:37:41 UTC (rev 223684)
@@ -67,6 +67,9 @@
     if (allowedQuirks & _WKWebsiteAutoplayQuirkSynthesizedPauseEvents)
         quirks |= WebKit::WebsiteAutoplayQuirk::SynthesizedPauseEvents;
 
+    if (allowedQuirks & _WKWebsiteAutoplayQuirkArbitraryUserGestures)
+        quirks |= WebKit::WebsiteAutoplayQuirk::ArbitraryUserGestures;
+
     _websitePolicies->setAllowedAutoplayQuirks(quirks);
 }
 
@@ -81,6 +84,9 @@
     if (allowedQuirks.contains(WebKit::WebsiteAutoplayQuirk::SynthesizedPauseEvents))
         quirks |= _WKWebsiteAutoplayQuirkSynthesizedPauseEvents;
 
+    if (allowedQuirks.contains(WebKit::WebsiteAutoplayQuirk::ArbitraryUserGestures))
+        quirks |= _WKWebsiteAutoplayQuirkArbitraryUserGestures;
+
     return quirks;
 }
 

Modified: branches/safari-604-branch/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (223683 => 223684)


--- branches/safari-604-branch/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2017-10-19 08:27:10 UTC (rev 223683)
+++ branches/safari-604-branch/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2017-10-19 08:37:41 UTC (rev 223684)
@@ -802,6 +802,9 @@
     if (allowedQuirks.contains(WebsiteAutoplayQuirk::SynthesizedPauseEvents))
         quirks |= AutoplayQuirk::SynthesizedPauseEvents;
 
+    if (allowedQuirks.contains(WebsiteAutoplayQuirk::ArbitraryUserGestures))
+        quirks |= AutoplayQuirk::ArbitraryUserGestures;
+
     documentLoader->setAllowedAutoplayQuirks(quirks);
 
     switch (websitePolicies.autoplayPolicy) {

Modified: branches/safari-604-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp (223683 => 223684)


--- branches/safari-604-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2017-10-19 08:27:10 UTC (rev 223683)
+++ branches/safari-604-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2017-10-19 08:37:41 UTC (rev 223684)
@@ -5620,6 +5620,9 @@
     if (allowedQuirks.contains(WebsiteAutoplayQuirk::SynthesizedPauseEvents))
         quirks |= AutoplayQuirk::SynthesizedPauseEvents;
 
+    if (allowedQuirks.contains(WebsiteAutoplayQuirk::ArbitraryUserGestures))
+        quirks |= AutoplayQuirk::ArbitraryUserGestures;
+
     documentLoader->setAllowedAutoplayQuirks(quirks);
 
     AutoplayPolicy autoplayPolicy = AutoplayPolicy::Default;

Modified: branches/safari-604-branch/Tools/ChangeLog (223683 => 223684)


--- branches/safari-604-branch/Tools/ChangeLog	2017-10-19 08:27:10 UTC (rev 223683)
+++ branches/safari-604-branch/Tools/ChangeLog	2017-10-19 08:37:41 UTC (rev 223684)
@@ -1,3 +1,17 @@
+2017-10-19  Jason Marcell  <jmarc...@apple.com>
+
+        Cherry-pick r223451. rdar://problem/34985194
+
+    2017-10-12  Matt Rajca  <mra...@apple.com>
+
+            Add API support for quirk that lets an arbitrary click allow auto-play.
+            https://bugs.webkit.org/show_bug.cgi?id=178227
+
+            Reviewed by Alex Christensen.
+
+            * TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm:
+            (TEST): Added API test.
+
 2017-10-18  Jason Marcell  <jmarc...@apple.com>
 
         Cherry-pick r221921. rdar://problem/35041482

Modified: branches/safari-604-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm (223683 => 223684)


--- branches/safari-604-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm	2017-10-19 08:27:10 UTC (rev 223683)
+++ branches/safari-604-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm	2017-10-19 08:37:41 UTC (rev 223684)
@@ -596,6 +596,39 @@
     runUntilReceivesAutoplayEvent(kWKAutoplayEventDidPreventFromAutoplaying);
 }
 
+TEST(WebKit2, WebsitePoliciesArbitraryUserGestureQuirk)
+{
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+
+    auto delegate = adoptNS([[AutoplayPoliciesDelegate alloc] init]);
+    [webView setNavigationDelegate:delegate.get()];
+
+    WKRetainPtr<WKPreferencesRef> preferences(AdoptWK, WKPreferencesCreate());
+    WKPreferencesSetNeedsSiteSpecificQuirks(preferences.get(), true);
+    WKPageGroupSetPreferences(WKPageGetPageGroup([webView _pageForTesting]), preferences.get());
+
+    [delegate setAllowedAutoplayQuirksForURL:^_WKWebsiteAutoplayQuirk(NSURL *url)
+    {
+        return _WKWebsiteAutoplayQuirkArbitraryUserGestures;
+    }];
+    [delegate setAutoplayPolicyForURL:^(NSURL *)
+    {
+        return _WKWebsiteAutoplayPolicyDeny;
+    }];
+
+    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"autoplay-check" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+    [webView loadRequest:request];
+    [webView waitForMessage:@"did-not-play"];
+
+    const NSPoint clickPoint = NSMakePoint(760, 560);
+    [webView mouseDownAtPoint:clickPoint simulatePressure:NO];
+    [webView mouseUpAtPoint:clickPoint];
+
+    [webView stringByEvaluatingJavaScript:@"playVideo()"];
+    [webView waitForMessage:@"autoplayed"];
+}
+
 TEST(WebKit2, WebsitePoliciesAutoplayQuirks)
 {
     auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to