Changeset 252438 in webkit
- Timestamp:
- Nov 13, 2019, 4:25:27 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 7 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/dom/Document.cpp (modified) (1 diff)
-
Source/WebCore/dom/Document.h (modified) (1 diff)
-
Source/WebCore/html/HTMLMediaElement.cpp (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (modified) (4 diffs)
-
Tools/TestWebKitAPI/Tests/WebKit/media-loading.html (added)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r252436 r252438 1 2019-11-13 Jer Noble <jer.noble@apple.com> 2 3 Link mediaDataLoadsAutomatically setting to AutoplayPolicy 4 https://bugs.webkit.org/show_bug.cgi?id=201738 5 <rdar://problem/55315194> 6 7 Reviewed by Eric Carlson. 8 9 This change has two effects: on Mac, when the embedding app sets an AutoplayPolicy to 10 deny autoplay, this will also deny the ability to load media data beyond "preload"; on iOS 11 when the embedding app sets an AutoplayPolicy to allow autoplay, this will also allow media 12 data to load beyond "preload". 13 14 * dom/Document.cpp: 15 (WebCore::Document::mediaDataLoadsAutomatically const): 16 * dom/Document.h: 17 * html/HTMLMediaElement.cpp: 18 (WebCore::HTMLMediaElement::finishInitialization): 19 * html/MediaElementSession.cpp: 20 (WebCore::MediaElementSession::allowsAutomaticMediaDataLoading const): 21 1 22 2019-11-13 Devin Rousso <drousso@apple.com> 2 23 -
trunk/Source/WebCore/dom/Document.cpp
r252221 r252438 5362 5362 } 5363 5363 5364 bool Document::mediaDataLoadsAutomatically() const 5365 { 5366 if (auto* loader = this->loader()) { 5367 AutoplayPolicy policy = loader->autoplayPolicy(); 5368 if (policy != AutoplayPolicy::Default) 5369 return policy != AutoplayPolicy::Deny; 5370 } 5371 5372 return settings().mediaDataLoadsAutomatically(); 5373 } 5374 5364 5375 void Document::storageBlockingStateDidChange() 5365 5376 { -
trunk/Source/WebCore/dom/Document.h
r252205 r252438 1095 1095 bool audioPlaybackRequiresUserGesture() const; 1096 1096 bool videoPlaybackRequiresUserGesture() const; 1097 bool mediaDataLoadsAutomatically() const; 1097 1098 1098 1099 #if ENABLE(MEDIA_SESSION) -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r252325 r252438 526 526 #endif 527 527 528 if (!document. settings().mediaDataLoadsAutomatically() && !document.quirks().needsPreloadAutoQuirk())528 if (!document.mediaDataLoadsAutomatically() && !document.quirks().needsPreloadAutoQuirk()) 529 529 m_mediaSession->addBehaviorRestriction(MediaElementSession::AutoPreloadingNotPermitted); 530 530 -
trunk/Tools/ChangeLog
r252437 r252438 1 2019-11-13 Jer Noble <jer.noble@apple.com> 2 3 Link mediaDataLoadsAutomatically setting to AutoplayPolicy 4 https://bugs.webkit.org/show_bug.cgi?id=201738 5 <rdar://problem/55315194> 6 7 Reviewed by Eric Carlson. 8 9 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 10 * TestWebKitAPI/Tests/WebKit/media-loading.html: Added. 11 * TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm: 12 (TEST): 13 1 14 2019-11-13 Carlos Alberto Lopez Perez <clopez@igalia.com> 2 15 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r252309 r252438 906 906 CD78E11E1DB7EE2A0014A2DE /* FullscreenDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD78E11B1DB7EA360014A2DE /* FullscreenDelegate.html */; }; 907 907 CD7F89DC22A86CDA00D683AE /* WKWebViewSuspendAllMediaPlayback.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD7F89DB22A86CDA00D683AE /* WKWebViewSuspendAllMediaPlayback.mm */; }; 908 CD8394DF232AF7C000149495 /* media-loading.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD8394DE232AF15E00149495 /* media-loading.html */; }; 908 909 CD9E292E1C90C33F000BB800 /* audio-only.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD9E292D1C90C1BA000BB800 /* audio-only.html */; }; 909 910 CDA29B2920FD2A9900F15CED /* ExitFullscreenOnEnterPiP.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDA29B2820FD2A9900F15CED /* ExitFullscreenOnEnterPiP.mm */; }; … … 1139 1140 dstSubfolderSpec = 7; 1140 1141 files = ( 1142 CD8394DF232AF7C000149495 /* media-loading.html in Copy Resources */, 1141 1143 55A817FF2181021A0004A39A /* 100x100-red.tga in Copy Resources */, 1142 1144 1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */, … … 2410 2412 CD78E11B1DB7EA360014A2DE /* FullscreenDelegate.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = FullscreenDelegate.html; sourceTree = "<group>"; }; 2411 2413 CD7F89DB22A86CDA00D683AE /* WKWebViewSuspendAllMediaPlayback.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewSuspendAllMediaPlayback.mm; sourceTree = "<group>"; }; 2414 CD8394DE232AF15E00149495 /* media-loading.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "media-loading.html"; sourceTree = "<group>"; }; 2412 2415 CD89D0381C4EDB2A00040A04 /* WebCoreNSURLSession.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreNSURLSession.mm; sourceTree = "<group>"; }; 2413 2416 CD9E292B1C90A71F000BB800 /* RequiresUserActionForPlayback.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RequiresUserActionForPlayback.mm; sourceTree = "<group>"; }; … … 3870 3873 1C2B81841C8924A200A5529F /* webfont.html */, 3871 3874 468F2F932368DAA700F4B864 /* window-open-then-document-open.html */, 3875 CD8394DE232AF15E00149495 /* media-loading.html */, 3872 3876 ); 3873 3877 name = Resources; -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm
r249705 r252438 175 175 } 176 176 177 @interface AutoplayPoliciesDelegate : NSObject<WKNavigationDelegate, WKUIDelegatePrivate>177 @interface AutoplayPoliciesDelegate : TestNavigationDelegate <WKNavigationDelegate, WKUIDelegatePrivate> 178 178 @property (nonatomic, copy) _WKWebsiteAutoplayPolicy(^autoplayPolicyForURL)(NSURL *); 179 179 @property (nonatomic, copy) _WKWebsiteAutoplayQuirk(^allowedAutoplayQuirksForURL)(NSURL *); … … 536 536 runUntilReceivesAutoplayEvent(kWKAutoplayEventUserDidInterfereWithPlayback); 537 537 ASSERT_TRUE(*receivedAutoplayEventFlags & kWKAutoplayEventFlagsHasAudio); 538 } 539 540 TEST(WebKit, WebsitePoliciesPerDocumentAutoplayBehaviorMediaLoading) 541 { 542 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 543 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); 544 545 auto delegate = adoptNS([[AutoplayPoliciesDelegate alloc] init]); 546 [webView setNavigationDelegate:delegate.get()]; 547 548 __block bool receivedLoadedEvent = false; 549 __block bool receivedSuspendEvent = false; 550 551 [webView performAfterReceivingMessage:@"loadeddata" action:^{ receivedLoadedEvent = true; }]; 552 [webView performAfterReceivingMessage:@"suspend" action:^{ receivedSuspendEvent = true; }]; 553 554 [delegate setAutoplayPolicyForURL:^(NSURL *) { 555 return _WKWebsiteAutoplayPolicyDeny; 556 }]; 557 558 [webView loadTestPageNamed:@"media-loading"]; 559 560 TestWebKitAPI::Util::run(&receivedSuspendEvent); 561 EXPECT_FALSE(receivedLoadedEvent); 562 563 [webView loadHTMLString:@"" baseURL:nil]; 564 [delegate waitForDidFinishNavigation]; 565 566 [webView setNavigationDelegate:delegate.get()]; 567 568 receivedLoadedEvent = false; 569 receivedSuspendEvent = false; 570 571 [delegate setAutoplayPolicyForURL:^(NSURL *) { 572 return _WKWebsiteAutoplayPolicyAllow; 573 }]; 574 575 [webView loadTestPageNamed:@"media-loading"]; 576 577 TestWebKitAPI::Util::run(&receivedLoadedEvent); 538 578 } 539 579
Note:
See TracChangeset
for help on using the changeset viewer.