Changeset 211062 in webkit
- Timestamp:
- Jan 23, 2017 2:25:59 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r211054 r211062 1 2017-01-23 Matt Rajca <mrajca@apple.com> 2 3 Pass down website autoplay policies to media elements 4 https://bugs.webkit.org/show_bug.cgi?id=167132 5 6 Reviewed by Alex Christensen. 7 8 The playbackRequiresUserGesture APIs are already covered by tests. This patch adds API tests 9 for autoplay website policies. 10 11 * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: 12 (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction): 13 1 14 2017-01-23 Joseph Pecoraro <pecoraro@apple.com> 2 15 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
r211033 r211062 818 818 documentLoader->setUserContentExtensionsEnabled(websitePolicies.contentBlockersEnabled); 819 819 820 #if PLATFORM(MAC) 821 coreFrame->settings().setAudioPlaybackRequiresUserGesture(!websitePolicies.autoplayEnabled); 822 #endif 823 820 824 // We call this synchronously because WebCore cannot gracefully handle a frame load without a synchronous navigation policy reply. 821 825 if (receivedPolicyAction) -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r211045 r211062 507 507 C54237F116B8957D00E638FC /* PasteboardNotifications_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C54237ED16B8955800E638FC /* PasteboardNotifications_Bundle.cpp */; }; 508 508 C5E1AFFE16B221F1006CC1F2 /* execCopy.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C5E1AFFD16B22179006CC1F2 /* execCopy.html */; }; 509 C9CB7DE11E2ED6F900B26082 /* autoplayCheck.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C9CB7DE01E2ED2A700B26082 /* autoplayCheck.html */; }; 509 510 CD59F53419E9110D00CF1835 /* file-with-mse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD59F53219E910AA00CF1835 /* file-with-mse.html */; }; 510 511 CD59F53519E9110D00CF1835 /* test-mse.mp4 in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD59F53319E910BC00CF1835 /* test-mse.mp4 */; }; … … 605 606 dstSubfolderSpec = 7; 606 607 files = ( 608 C9CB7DE11E2ED6F900B26082 /* autoplayCheck.html in Copy Resources */, 607 609 7AEAD4811E20122700416EFE /* CrossPartitionFileSchemeAccess.html in Copy Resources */, 608 610 CDB4115A1E0B00DB00EAD352 /* video-with-muted-audio.html in Copy Resources */, … … 1266 1268 C5E1AFFD16B22179006CC1F2 /* execCopy.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = execCopy.html; sourceTree = "<group>"; }; 1267 1269 C95501BE19AD2FAF0049BE3E /* Preferences.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Preferences.mm; sourceTree = "<group>"; }; 1270 C9CB7DE01E2ED2A700B26082 /* autoplayCheck.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = autoplayCheck.html; sourceTree = "<group>"; }; 1268 1271 CD225C071C45A69200140761 /* ParsedContentRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParsedContentRange.cpp; sourceTree = "<group>"; }; 1269 1272 CD5393C71757BA9700C07123 /* MD5.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MD5.cpp; sourceTree = "<group>"; }; … … 1946 1949 isa = PBXGroup; 1947 1950 children = ( 1948 9BD4239B1E04BFD000200395 /* chinese-character-with-image.html */,1949 07492B391DF8ADA400633DE1 /* enumerateMediaDevices.html */,1950 1951 C045F9461385C2F800C0F3CD /* 18-characters.html */, 1951 1952 1C2B81851C89252300A5529F /* Ahem.ttf */, … … 1953 1954 F6B7BE9617469B7E008A3445 /* associate-form-controls.html */, 1954 1955 76E182DE15475A8300F1FADD /* auto-submitting-form.html */, 1956 C9CB7DE01E2ED2A700B26082 /* autoplayCheck.html */, 1955 1957 7C486BA01AA1254B003F6F9B /* bundle-file.html */, 1958 9BD4239B1E04BFD000200395 /* chinese-character-with-image.html */, 1956 1959 1A50AA1F1A2A4EA500F4C345 /* close-from-within-create-page.html */, 1957 1960 9B270FED1DDC25FD002D53F3 /* closed-shadow-tree-test.html */, 1958 1961 5C9E56861DF9148E00C9EE33 /* contentBlockerCheck.html */, 1959 1962 290F4274172A1FDE00939FF0 /* custom-protocol-sync-xhr.html */, 1963 07492B391DF8ADA400633DE1 /* enumerateMediaDevices.html */, 1960 1964 C5E1AFFD16B22179006CC1F2 /* execCopy.html */, 1961 1965 BC2D004A12A9FEB300E732A3 /* file-with-anchor.html */, -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm
r209558 r211062 27 27 28 28 #import "PlatformUtilities.h" 29 #import "TestWKWebView.h" 29 30 #import <WebKit/WKUserContentControllerPrivate.h> 30 31 #import <WebKit/WKWebViewPrivate.h> … … 39 40 static size_t alertCount; 40 41 41 @interface WebsitePoliciesDelegate : NSObject <WKNavigationDelegate, WKUIDelegate>42 @end 43 44 @implementation WebsitePoliciesDelegate42 @interface ContentBlockingWebsitePoliciesDelegate : NSObject <WKNavigationDelegate, WKUIDelegate> 43 @end 44 45 @implementation ContentBlockingWebsitePoliciesDelegate 45 46 46 47 - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler … … 124 125 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); 125 126 126 auto delegate = adoptNS([[ WebsitePoliciesDelegate alloc] init]);127 auto delegate = adoptNS([[ContentBlockingWebsitePoliciesDelegate alloc] init]); 127 128 [webView setNavigationDelegate:delegate.get()]; 128 129 [webView setUIDelegate:delegate.get()]; … … 149 150 } 150 151 152 #if PLATFORM(MAC) 153 154 @interface AutoplayPoliciesDelegate : NSObject <WKNavigationDelegate, WKUIDelegate> 155 @property (nonatomic) BOOL allowAutoplay; 156 @end 157 158 @implementation AutoplayPoliciesDelegate 159 160 - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler 161 { 162 // _webView:decidePolicyForNavigationAction:decisionHandler: should be called instead if it is implemented. 163 EXPECT_TRUE(false); 164 decisionHandler(WKNavigationActionPolicyAllow); 165 } 166 167 - (void)_webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy, _WKWebsitePolicies *))decisionHandler 168 { 169 _WKWebsitePolicies *websitePolicies = [[[_WKWebsitePolicies alloc] init] autorelease]; 170 websitePolicies.autoplayEnabled = _allowAutoplay; 171 decisionHandler(WKNavigationActionPolicyAllow, websitePolicies); 172 } 173 174 @end 175 176 TEST(WebKit2, WebsitePoliciesAutoplayEnabled) 177 { 178 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 179 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); 180 181 auto delegate = adoptNS([[AutoplayPoliciesDelegate alloc] init]); 182 [webView setNavigationDelegate:delegate.get()]; 183 184 NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"autoplayCheck" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]; 185 186 [delegate setAllowAutoplay:YES]; 187 [webView loadRequest:request]; 188 [webView waitForMessage:@"autoplayed"]; 189 190 [delegate setAllowAutoplay:NO]; 191 [webView loadRequest:request]; 192 [webView waitForMessage:@"did-not-play"]; 193 194 [delegate setAllowAutoplay:YES]; 195 [webView loadRequest:request]; 196 [webView waitForMessage:@"autoplayed"]; 197 } 198 199 #endif // PLATFORM(MAC) 200 151 201 #endif
Note: See TracChangeset
for help on using the changeset viewer.