haikuwebkit/LayoutTests/media/video-restricted-invisible-...

22 lines
554 B
Plaintext
Raw Permalink Normal View History

Autoplay Muted Videos Don't Play When Outside Viewport https://bugs.webkit.org/show_bug.cgi?id=175748 <rdar://problem/33974383> Reviewed by Eric Carlson. Source/WebCore: Test: media/video-restricted-invisible-autoplay-not-allowed-source.html The media session is notified that its client (the media element) will begin autoplaying inside prepareForLoad(), where the m_autoplaying flag is also set. But loading via <source> elements does not go through prepareForLoad(); the HTML standard states that the <source> element loading path does not trigger the "media element load algorithm" which is implemented in prepareForLoad(). Since the m_autoplaying flag is initially set to true, notify the media session that the element will begin autoplaying inside the element's constructor. Drive-by fix: Doing the above causes other tests to crash, as purturbing play state during style change can cause re-entrancy in the native controls code, or fail, since we will transition from autoplay -> play even if there's not yet a src or source to the media element. Add a task queue for updating the autoplay state and check the ready state before allowing autoplay to transition to play. * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::canTransitionFromAutoplayToPlay const): (WebCore::HTMLMediaElement::isVisibleInViewportChanged): LayoutTests: * media/video-restricted-invisible-autoplay-not-allowed-source-expected.txt: Added. * media/video-restricted-invisible-autoplay-not-allowed-source.html: Added. Canonical link: https://commits.webkit.org/192472@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221016 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-22 16:13:22 +00:00
Test that "invisible autoplay not allowed restriction" pauses media when scrolled out of view.
** setting video source.src
EVENT(play)
RUN(video.style.display = "none")
EVENT(pause)
RUN(video.style.removeProperty("display"))
EVENT(play)
RUN(video.style.visibility = "hidden")
EVENT(pause)
RUN(video.style.removeProperty("visibility"))
EVENT(play)
RUN(document.documentElement.style.height = window.innerHeight + 20 + video.offsetHeight)
RUN(window.scrollBy(0, 20 + video.offsetHeight))
EVENT(pause)
RUN(window.scrollTo(0, 0))
EVENT(play)
END OF TEST