haikuwebkit/LayoutTests/media/video-concurrent-visible-pl...

15 lines
408 B
Plaintext
Raw Permalink Normal View History

Allow multiple playing videos on a page with 'autoplay' and 'playsinline' attributes https://bugs.webkit.org/show_bug.cgi?id=162366 <rdar://problem/28639600> Reviewed by Eric Carlson. Source/WebCore: Tests: media/video-concurrent-visible-playback.html media/video-multiple-concurrent-playback.html Separate out the concept of "video-only" from "video-with-audio" in PlatformMediaSession::MediaType, and only set the ConcurrentPlaybackNotPermitted restriction for "video-with-audio". This allows multiple silent video elements to play back simultaneously. However, the bug in question also shows bad behavior when both concurrent playback and invisible playback are not allowed. Namely, an invisible element will attempt to autoplay, interrupt visible elements, and then fail to play due to it's non-visibility. Add an extra check to canTransitionFromAutoplayToPlay() which asks the session if autoplay is allowed (which will return false if the element is not visible). * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::canTransitionFromAutoplayToPlay): (WebCore::HTMLMediaElement::mediaType): (WebCore::HTMLMediaElement::presentationType): (WebCore::HTMLMediaElement::updateShouldAutoplay): (WebCore::mediaElementIsAllowedToAutoplay): Deleted. * html/MediaElementSession.cpp: (WebCore::MediaElementSession::autoplayPermitted): * html/MediaElementSession.h: * platform/audio/PlatformMediaSession.h: * platform/audio/ios/MediaSessionManagerIOS.mm: (WebCore::MediaSessionManageriOS::resetRestrictions): * testing/Internals.cpp: (WebCore::Internals::setMediaSessionRestrictions): LayoutTests: * media/content/test-video-only.mp4: Added. * media/non-existent-video-playback-interrupted-expected.txt: * media/non-existent-video-playback-interrupted.html: * media/video-background-playback-expected.txt: * media/video-background-playback.html: * media/video-background-tab-playback-expected.txt: * media/video-background-tab-playback.html: * media/video-concurrent-playback-expected.txt: * media/video-concurrent-playback.html: * media/video-concurrent-visible-playback-expected.txt: Added. * media/video-concurrent-visible-playback.html: Added. * media/video-multiple-concurrent-playback-expected.txt: Added. * media/video-multiple-concurrent-playback.html: Added. * media/video-playback-interrupted-expected.txt: * media/video-playback-interrupted.html: * media/video-restricted-invisible-autoplay-not-allowed.html: Canonical link: https://commits.webkit.org/181931@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208149 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-31 16:36:00 +00:00
Test autoplay when both invisible playback and concurrent playback are not allowed.
RUN(video.src = findMediaFile("video", "content/test"))
RUN(video.src = findMediaFile("video", "content/test"))
RUN(video.src = findMediaFile("video", "content/test"))
EVENT(playing)
EXPECTED (videos[0].paused == 'true') OK
EXPECTED (videos[1].paused == 'false') OK
EXPECTED (videos[2].paused == 'true') OK
END OF TEST