Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
WebsitePolicies: let clients select specific autoplay quirks
https://bugs.webkit.org/show_bug.cgi?id=173343

Reviewed by Alex Christensen.
Source/WebCore:

Tests: Updated API tests accordingly to use new values.

Replace the 'allowsAutoplayQuirks' bool with an OptionSet so clients can selectively
pick auto-play quirks.

* dom/Document.cpp:
(WebCore::Document::processingUserGestureForMedia):
* html/HTMLMediaElement.cpp:
(WebCore::needsAutoplayPlayPauseEventsQuirk):
* loader/DocumentLoader.h:
(WebCore::DocumentLoader::allowedAutoplayQuirks):
(WebCore::DocumentLoader::setAllowedAutoplayQuirks):
(WebCore::DocumentLoader::allowsAutoplayQuirks): Deleted.
(WebCore::DocumentLoader::setAllowsAutoplayQuirks): Deleted.

Source/WebKit2:

Replace the 'allowsAutoplayQuirks' bool with an OptionSet so clients can selectively
pick auto-play quirks.

* Shared/WebsitePolicies.h:
(WebKit::WebsitePolicies::encode):
(WebKit::WebsitePolicies::decode):
* UIProcess/API/APIWebsitePolicies.h:
* UIProcess/API/C/WKWebsitePolicies.cpp:
(WKWebsitePoliciesSetAllowedAutoplayQuirks):
(WKWebsitePoliciesGetAllowedAutoplayQuirks):
(WKWebsitePoliciesSetAllowsAutoplayQuirks): Deleted.
(WKWebsitePoliciesGetAllowsAutoplayQuirks): Deleted.
* UIProcess/API/C/WKWebsitePolicies.h:
* UIProcess/API/Cocoa/_WKWebsitePolicies.h:
* UIProcess/API/Cocoa/_WKWebsitePolicies.mm:
(-[_WKWebsitePolicies setAllowedAutoplayQuirks:]):
(-[_WKWebsitePolicies allowedAutoplayQuirks]):
(-[_WKWebsitePolicies setAllowsAutoplayQuirks:]): Deleted.
(-[_WKWebsitePolicies allowsAutoplayQuirks]): Deleted.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updateWebsitePolicies):

Tools:

* TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm:
(-[AutoplayPoliciesDelegate _webView:decidePolicyForNavigationAction:decisionHandler:]):
(TEST): Updated tests.

Canonical link: https://commits.webkit.org/190205@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218229 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Matt Rajca committed Jun 14, 2017
1 parent e54a8b9 commit 1d5d4bf
Show file tree
Hide file tree
Showing 15 changed files with 172 additions and 30 deletions.
22 changes: 22 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,25 @@
2017-06-13 Matt Rajca <mrajca@apple.com>

WebsitePolicies: let clients select specific autoplay quirks
https://bugs.webkit.org/show_bug.cgi?id=173343

Reviewed by Alex Christensen.

Tests: Updated API tests accordingly to use new values.

Replace the 'allowsAutoplayQuirks' bool with an OptionSet so clients can selectively
pick auto-play quirks.

* dom/Document.cpp:
(WebCore::Document::processingUserGestureForMedia):
* html/HTMLMediaElement.cpp:
(WebCore::needsAutoplayPlayPauseEventsQuirk):
* loader/DocumentLoader.h:
(WebCore::DocumentLoader::allowedAutoplayQuirks):
(WebCore::DocumentLoader::setAllowedAutoplayQuirks):
(WebCore::DocumentLoader::allowsAutoplayQuirks): Deleted.
(WebCore::DocumentLoader::setAllowsAutoplayQuirks): Deleted.

2017-06-13 Zalan Bujtas <zalan@apple.com>

Synchronous media query callbacks on nested frames could produced a detached FrameView.
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/dom/Document.cpp
Expand Up @@ -6468,7 +6468,7 @@ bool Document::processingUserGestureForMedia() const
return topDocument().hasHadUserInteraction();

auto* loader = this->loader();
if (loader && loader->allowsAutoplayQuirks())
if (loader && loader->allowedAutoplayQuirks().contains(AutoplayQuirk::InheritedUserGestures))
return topDocument().hasHadUserInteraction();

return false;
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/html/HTMLMediaElement.cpp
Expand Up @@ -599,7 +599,7 @@ static bool needsAutoplayPlayPauseEventsQuirk(const Document& document)
return false;

auto* loader = document.loader();
return loader && loader->allowsAutoplayQuirks();
return loader && loader->allowedAutoplayQuirks().contains(AutoplayQuirk::SynthesizedPauseEvents);
}

HTMLMediaElement* HTMLMediaElement::bestMediaElementForShowingPlaybackControlsManager(MediaElementSession::PlaybackControlsPurpose purpose)
Expand Down
11 changes: 8 additions & 3 deletions Source/WebCore/loader/DocumentLoader.h
Expand Up @@ -85,6 +85,11 @@ enum class AutoplayPolicy {
Deny,
};

enum class AutoplayQuirk {
SynthesizedPauseEvents = 1 << 0,
InheritedUserGestures = 1 << 1,
};

class DocumentLoader : public RefCounted<DocumentLoader>, private CachedRawResourceClient {
WTF_MAKE_FAST_ALLOCATED;
friend class ContentFilter;
Expand Down Expand Up @@ -242,8 +247,8 @@ class DocumentLoader : public RefCounted<DocumentLoader>, private CachedRawResou
AutoplayPolicy autoplayPolicy() const { return m_autoplayPolicy; }
void setAutoplayPolicy(AutoplayPolicy policy) { m_autoplayPolicy = policy; }

bool allowsAutoplayQuirks() const { return m_allowsAutoplayQuirks; }
void setAllowsAutoplayQuirks(bool allowsQuirks) { m_allowsAutoplayQuirks = allowsQuirks; }
OptionSet<AutoplayQuirk> allowedAutoplayQuirks() const { return m_allowedAutoplayQuirks; }
void setAllowedAutoplayQuirks(OptionSet<AutoplayQuirk> allowedQuirks) { m_allowedAutoplayQuirks = allowedQuirks; }

void addSubresourceLoader(ResourceLoader*);
void removeSubresourceLoader(ResourceLoader*);
Expand Down Expand Up @@ -475,7 +480,7 @@ class DocumentLoader : public RefCounted<DocumentLoader>, private CachedRawResou
#endif
bool m_userContentExtensionsEnabled { true };
AutoplayPolicy m_autoplayPolicy { AutoplayPolicy::Default };
bool m_allowsAutoplayQuirks { false };
OptionSet<AutoplayQuirk> m_allowedAutoplayQuirks;

#ifndef NDEBUG
bool m_hasEverBeenAttached { false };
Expand Down
31 changes: 31 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,34 @@
2017-06-13 Matt Rajca <mrajca@apple.com>

WebsitePolicies: let clients select specific autoplay quirks
https://bugs.webkit.org/show_bug.cgi?id=173343

Reviewed by Alex Christensen.

Replace the 'allowsAutoplayQuirks' bool with an OptionSet so clients can selectively
pick auto-play quirks.

* Shared/WebsitePolicies.h:
(WebKit::WebsitePolicies::encode):
(WebKit::WebsitePolicies::decode):
* UIProcess/API/APIWebsitePolicies.h:
* UIProcess/API/C/WKWebsitePolicies.cpp:
(WKWebsitePoliciesSetAllowedAutoplayQuirks):
(WKWebsitePoliciesGetAllowedAutoplayQuirks):
(WKWebsitePoliciesSetAllowsAutoplayQuirks): Deleted.
(WKWebsitePoliciesGetAllowsAutoplayQuirks): Deleted.
* UIProcess/API/C/WKWebsitePolicies.h:
* UIProcess/API/Cocoa/_WKWebsitePolicies.h:
* UIProcess/API/Cocoa/_WKWebsitePolicies.mm:
(-[_WKWebsitePolicies setAllowedAutoplayQuirks:]):
(-[_WKWebsitePolicies allowedAutoplayQuirks]):
(-[_WKWebsitePolicies setAllowsAutoplayQuirks:]): Deleted.
(-[_WKWebsitePolicies allowsAutoplayQuirks]): Deleted.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updateWebsitePolicies):

2017-06-13 Wenson Hsieh <wenson_hsieh@apple.com>

Add missing availability declarations to SPI in WKUIDelegatePrivate.h
Expand Down
13 changes: 10 additions & 3 deletions Source/WebKit2/Shared/WebsitePolicies.h
Expand Up @@ -25,6 +25,8 @@

#pragma once

#include <wtf/OptionSet.h>

namespace WebKit {

enum class WebsiteAutoplayPolicy {
Expand All @@ -34,10 +36,15 @@ enum class WebsiteAutoplayPolicy {
Deny
};

enum class WebsiteAutoplayQuirk {
SynthesizedPauseEvents = 1 << 0,
InheritedUserGestures = 1 << 1,
};

struct WebsitePolicies {

bool contentBlockersEnabled { true };
bool allowsAutoplayQuirks { false };
OptionSet<WebsiteAutoplayQuirk> allowedAutoplayQuirks;
WebsiteAutoplayPolicy autoplayPolicy { WebsiteAutoplayPolicy::Default };

template<class Encoder> void encode(Encoder&) const;
Expand All @@ -48,7 +55,7 @@ template<class Encoder> void WebsitePolicies::encode(Encoder& encoder) const
{
encoder << contentBlockersEnabled;
encoder.encodeEnum(autoplayPolicy);
encoder << allowsAutoplayQuirks;
encoder << allowedAutoplayQuirks;
}

template<class Decoder> bool WebsitePolicies::decode(Decoder& decoder, WebsitePolicies& result)
Expand All @@ -57,7 +64,7 @@ template<class Decoder> bool WebsitePolicies::decode(Decoder& decoder, WebsitePo
return false;
if (!decoder.decodeEnum(result.autoplayPolicy))
return false;
if (!decoder.decode(result.allowsAutoplayQuirks))
if (!decoder.decode(result.allowedAutoplayQuirks))
return false;
return true;
}
Expand Down
5 changes: 3 additions & 2 deletions Source/WebKit2/UIProcess/API/APIWebsitePolicies.h
Expand Up @@ -27,6 +27,7 @@

#include "APIObject.h"
#include "WebsitePolicies.h"
#include <wtf/OptionSet.h>

namespace API {

Expand All @@ -39,8 +40,8 @@ class WebsitePolicies final : public ObjectImpl<Object::Type::WebsitePolicies> {
bool contentBlockersEnabled() const { return m_websitePolicies.contentBlockersEnabled; }
void setContentBlockersEnabled(bool enabled) { m_websitePolicies.contentBlockersEnabled = enabled; }

bool allowsAutoplayQuirks() const { return m_websitePolicies.allowsAutoplayQuirks; }
void setAllowsAutoplayQuirks(bool allowsQuirks) { m_websitePolicies.allowsAutoplayQuirks = allowsQuirks; }
OptionSet<WebKit::WebsiteAutoplayQuirk> allowedAutoplayQuirks() const { return m_websitePolicies.allowedAutoplayQuirks; }
void setAllowedAutoplayQuirks(OptionSet<WebKit::WebsiteAutoplayQuirk> allowedQuirks) { m_websitePolicies.allowedAutoplayQuirks = allowedQuirks; }

WebKit::WebsiteAutoplayPolicy autoplayPolicy() const { return m_websitePolicies.autoplayPolicy; }
void setAutoplayPolicy(WebKit::WebsiteAutoplayPolicy policy) { m_websitePolicies.autoplayPolicy = policy; }
Expand Down
24 changes: 20 additions & 4 deletions Source/WebKit2/UIProcess/API/C/WKWebsitePolicies.cpp
Expand Up @@ -52,14 +52,30 @@ bool WKWebsitePoliciesGetContentBlockersEnabled(WKWebsitePoliciesRef websitePoli
return toImpl(websitePolicies)->contentBlockersEnabled();
}

void WKWebsitePoliciesSetAllowsAutoplayQuirks(WKWebsitePoliciesRef websitePolicies, bool allowsQuirks)
void WKWebsitePoliciesSetAllowedAutoplayQuirks(WKWebsitePoliciesRef websitePolicies, WKWebsiteAutoplayQuirk allowedQuirks)
{
toImpl(websitePolicies)->setAllowsAutoplayQuirks(allowsQuirks);
OptionSet<WebsiteAutoplayQuirk> quirks;
if (allowedQuirks & kWKWebsiteAutoplayQuirkInheritedUserGestures)
quirks |= WebsiteAutoplayQuirk::InheritedUserGestures;

if (allowedQuirks & kWKWebsiteAutoplayQuirkSynthesizedPauseEvents)
quirks |= WebsiteAutoplayQuirk::SynthesizedPauseEvents;

toImpl(websitePolicies)->setAllowedAutoplayQuirks(quirks);
}

bool WKWebsitePoliciesGetAllowsAutoplayQuirks(WKWebsitePoliciesRef websitePolicies)
WKWebsiteAutoplayQuirk WKWebsitePoliciesGetAllowedAutoplayQuirks(WKWebsitePoliciesRef websitePolicies)
{
return toImpl(websitePolicies)->allowsAutoplayQuirks();
WKWebsiteAutoplayQuirk quirks = 0;
auto allowedQuirks = toImpl(websitePolicies)->allowedAutoplayQuirks();

if (allowedQuirks.contains(WebsiteAutoplayQuirk::SynthesizedPauseEvents))
quirks |= kWKWebsiteAutoplayQuirkSynthesizedPauseEvents;

if (allowedQuirks.contains(WebsiteAutoplayQuirk::InheritedUserGestures))
quirks |= kWKWebsiteAutoplayQuirkInheritedUserGestures;

return quirks;
}

WKWebsiteAutoplayPolicy WKWebsitePoliciesGetAutoplayPolicy(WKWebsitePoliciesRef websitePolicies)
Expand Down
10 changes: 8 additions & 2 deletions Source/WebKit2/UIProcess/API/C/WKWebsitePolicies.h
Expand Up @@ -40,13 +40,19 @@ enum WKWebsiteAutoplayPolicy {
kWKWebsiteAutoplayPolicyDeny
};

typedef uint32_t WKWebsiteAutoplayQuirk;
enum {
kWKWebsiteAutoplayQuirkSynthesizedPauseEvents = 1 << 0,
kWKWebsiteAutoplayQuirkInheritedUserGestures = 1 << 1,
};

WK_EXPORT WKWebsitePoliciesRef WKWebsitePoliciesCreate();

WK_EXPORT bool WKWebsitePoliciesGetContentBlockersEnabled(WKWebsitePoliciesRef);
WK_EXPORT void WKWebsitePoliciesSetContentBlockersEnabled(WKWebsitePoliciesRef, bool);

WK_EXPORT bool WKWebsitePoliciesGetAllowsAutoplayQuirks(WKWebsitePoliciesRef);
WK_EXPORT void WKWebsitePoliciesSetAllowsAutoplayQuirks(WKWebsitePoliciesRef, bool);
WK_EXPORT WKWebsiteAutoplayQuirk WKWebsitePoliciesGetAllowedAutoplayQuirks(WKWebsitePoliciesRef);
WK_EXPORT void WKWebsitePoliciesSetAllowedAutoplayQuirks(WKWebsitePoliciesRef, WKWebsiteAutoplayQuirk);

WK_EXPORT WKWebsiteAutoplayPolicy WKWebsitePoliciesGetAutoplayPolicy(WKWebsitePoliciesRef);
WK_EXPORT void WKWebsitePoliciesSetAutoplayPolicy(WKWebsitePoliciesRef, WKWebsiteAutoplayPolicy);
Expand Down
7 changes: 6 additions & 1 deletion Source/WebKit2/UIProcess/API/Cocoa/_WKWebsitePolicies.h
Expand Up @@ -34,11 +34,16 @@ typedef NS_ENUM(NSInteger, _WKWebsiteAutoplayPolicy) {
_WKWebsiteAutoplayPolicyDeny
} WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));

typedef NS_OPTIONS(NSUInteger, _WKWebsiteAutoplayQuirk) {
_WKWebsiteAutoplayQuirkSynthesizedPauseEvents = 1 << 0,
_WKWebsiteAutoplayQuirkInheritedUserGestures = 1 << 1,
} WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));

WK_CLASS_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA))
@interface _WKWebsitePolicies : NSObject

@property (nonatomic) BOOL contentBlockersEnabled;
@property (nonatomic) BOOL allowsAutoplayQuirks;
@property (nonatomic) _WKWebsiteAutoplayQuirk allowedAutoplayQuirks;
@property (nonatomic) _WKWebsiteAutoplayPolicy autoplayPolicy;

@end
Expand Down
25 changes: 21 additions & 4 deletions Source/WebKit2/UIProcess/API/Cocoa/_WKWebsitePolicies.mm
Expand Up @@ -57,14 +57,31 @@ - (BOOL)contentBlockersEnabled
return _websitePolicies->contentBlockersEnabled();
}

- (void)setAllowsAutoplayQuirks:(BOOL)allowsQuirks
- (void)setAllowedAutoplayQuirks:(_WKWebsiteAutoplayQuirk)allowedQuirks
{
_websitePolicies->setAllowsAutoplayQuirks(allowsQuirks);
OptionSet<WebKit::WebsiteAutoplayQuirk> quirks;

if (allowedQuirks & _WKWebsiteAutoplayQuirkInheritedUserGestures)
quirks |= WebKit::WebsiteAutoplayQuirk::InheritedUserGestures;

if (allowedQuirks & _WKWebsiteAutoplayQuirkSynthesizedPauseEvents)
quirks |= WebKit::WebsiteAutoplayQuirk::SynthesizedPauseEvents;

_websitePolicies->setAllowedAutoplayQuirks(quirks);
}

- (BOOL)allowsAutoplayQuirks
- (_WKWebsiteAutoplayQuirk)allowedAutoplayQuirks
{
return _websitePolicies->allowsAutoplayQuirks();
_WKWebsiteAutoplayQuirk quirks = 0;
auto allowedQuirks = _websitePolicies->allowedAutoplayQuirks();

if (allowedQuirks.contains(WebKit::WebsiteAutoplayQuirk::InheritedUserGestures))
quirks |= _WKWebsiteAutoplayQuirkInheritedUserGestures;

if (allowedQuirks.contains(WebKit::WebsiteAutoplayQuirk::SynthesizedPauseEvents))
quirks |= _WKWebsiteAutoplayQuirkSynthesizedPauseEvents;

return quirks;
}

- (void)setAutoplayPolicy:(_WKWebsiteAutoplayPolicy)policy
Expand Down
Expand Up @@ -828,7 +828,16 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const Navigat
if (documentLoader->userContentExtensionsEnabled())
documentLoader->setUserContentExtensionsEnabled(websitePolicies.contentBlockersEnabled);

documentLoader->setAllowsAutoplayQuirks(websitePolicies.allowsAutoplayQuirks);
OptionSet<AutoplayQuirk> quirks;
auto allowedQuirks = websitePolicies.allowedAutoplayQuirks;

if (allowedQuirks.contains(WebsiteAutoplayQuirk::InheritedUserGestures))
quirks |= AutoplayQuirk::InheritedUserGestures;

if (allowedQuirks.contains(WebsiteAutoplayQuirk::SynthesizedPauseEvents))
quirks |= AutoplayQuirk::SynthesizedPauseEvents;

documentLoader->setAllowedAutoplayQuirks(quirks);

switch (websitePolicies.autoplayPolicy) {
case WebsiteAutoplayPolicy::Default:
Expand Down
11 changes: 10 additions & 1 deletion Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Expand Up @@ -5609,7 +5609,16 @@ void WebPage::updateWebsitePolicies(const WebsitePolicies& websitePolicies)
if (!documentLoader)
return;

documentLoader->setAllowsAutoplayQuirks(websitePolicies.allowsAutoplayQuirks);
OptionSet<AutoplayQuirk> quirks;
auto allowedQuirks = websitePolicies.allowedAutoplayQuirks;

if (allowedQuirks.contains(WebsiteAutoplayQuirk::InheritedUserGestures))
quirks |= AutoplayQuirk::InheritedUserGestures;

if (allowedQuirks.contains(WebsiteAutoplayQuirk::SynthesizedPauseEvents))
quirks |= AutoplayQuirk::SynthesizedPauseEvents;

documentLoader->setAllowedAutoplayQuirks(quirks);

switch (websitePolicies.autoplayPolicy) {
case WebsiteAutoplayPolicy::Default:
Expand Down
11 changes: 11 additions & 0 deletions Tools/ChangeLog
@@ -1,3 +1,14 @@
2017-06-13 Matt Rajca <mrajca@apple.com>

WebsitePolicies: let clients select specific autoplay quirks
https://bugs.webkit.org/show_bug.cgi?id=173343

Reviewed by Alex Christensen.

* TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm:
(-[AutoplayPoliciesDelegate _webView:decidePolicyForNavigationAction:decisionHandler:]):
(TEST): Updated tests.

2017-06-13 Daniel Bates <dabates@apple.com>

Implement W3C Secure Contexts Draft Specification
Expand Down
17 changes: 10 additions & 7 deletions Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm
Expand Up @@ -162,7 +162,7 @@ - (void)_webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigat

@interface AutoplayPoliciesDelegate : NSObject <WKNavigationDelegate, WKUIDelegate>
@property (nonatomic, copy) _WKWebsiteAutoplayPolicy(^autoplayPolicyForURL)(NSURL *);
@property (nonatomic, copy) BOOL(^allowsAutoplayQuirksForURL)(NSURL *);
@property (nonatomic, copy) _WKWebsiteAutoplayQuirk(^allowedAutoplayQuirksForURL)(NSURL *);
@end

@implementation AutoplayPoliciesDelegate
Expand All @@ -177,8 +177,8 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigati
- (void)_webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy, _WKWebsitePolicies *))decisionHandler
{
_WKWebsitePolicies *websitePolicies = [[[_WKWebsitePolicies alloc] init] autorelease];
if (_allowsAutoplayQuirksForURL)
websitePolicies.allowsAutoplayQuirks = _allowsAutoplayQuirksForURL(navigationAction.request.URL);
if (_allowedAutoplayQuirksForURL)
websitePolicies.allowedAutoplayQuirks = _allowedAutoplayQuirksForURL(navigationAction.request.URL);
if (_autoplayPolicyForURL)
websitePolicies.autoplayPolicy = _autoplayPolicyForURL(navigationAction.request.URL);
decisionHandler(WKNavigationActionPolicyAllow, websitePolicies);
Expand Down Expand Up @@ -459,8 +459,8 @@ static void runUntilReceivesAutoplayEvent(WKAutoplayEvent event)

NSURLRequest *requestWithAudio = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"autoplay-check" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];

[delegate setAllowsAutoplayQuirksForURL:^(NSURL *url) {
return YES;
[delegate setAllowedAutoplayQuirksForURL:^_WKWebsiteAutoplayQuirk(NSURL *url) {
return _WKWebsiteAutoplayQuirkSynthesizedPauseEvents;
}];
[delegate setAutoplayPolicyForURL:^(NSURL *) {
return _WKWebsiteAutoplayPolicyDeny;
Expand All @@ -474,8 +474,11 @@ static void runUntilReceivesAutoplayEvent(WKAutoplayEvent event)

NSURLRequest *requestWithAudioInFrame = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"autoplay-check-in-iframe" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];

[delegate setAllowsAutoplayQuirksForURL:^(NSURL *url) {
return [url.lastPathComponent isEqualToString:@"autoplay-check-frame.html"];
[delegate setAllowedAutoplayQuirksForURL:^_WKWebsiteAutoplayQuirk(NSURL *url) {
if ([url.lastPathComponent isEqualToString:@"autoplay-check-frame.html"])
return _WKWebsiteAutoplayQuirkInheritedUserGestures;

return _WKWebsiteAutoplayQuirkSynthesizedPauseEvents;
}];
[delegate setAutoplayPolicyForURL:^(NSURL *) {
return _WKWebsiteAutoplayPolicyDeny;
Expand Down

0 comments on commit 1d5d4bf

Please sign in to comment.