Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Audible autoplay videos should not get paused when outside the viewport
https://bugs.webkit.org/show_bug.cgi?id=170610 <rdar://problem/31505984> Reviewed by Eric Carlson. Source/WebCore: Audible autoplay videos should not get paused when outside the viewport as this would be observable by the user. Test: media/video-restricted-invisible-autoplay-allowed-if-audible.html * html/MediaElementSession.cpp: (WebCore::MediaElementSession::autoplayPermitted): LayoutTests: Add layout test coverage. * media/video-restricted-invisible-autoplay-allowed-if-audible-expected.txt: Added. * media/video-restricted-invisible-autoplay-allowed-if-audible.html: Copied from LayoutTests/media/video-restricted-invisible-autoplay-not-allowed.html. * media/video-restricted-invisible-autoplay-allowed-when-visible.html: * media/video-restricted-invisible-autoplay-not-allowed.html: Canonical link: https://commits.webkit.org/187548@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215120 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
7 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
LayoutTests/media/video-restricted-invisible-autoplay-allowed-if-audible-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
Test that "invisible autoplay not allowed restriction" does not pause audible media when scrolled out of view. | ||
|
||
** setting video.src | ||
|
||
EVENT(play) | ||
EXPECTED (video.paused == 'false') OK | ||
RUN(video.style.display = "none") | ||
EXPECTED (video.paused == 'false') OK | ||
RUN(video.style.removeProperty("display")) | ||
RUN(video.style.visibility = "hidden") | ||
EXPECTED (video.paused == 'false') OK | ||
RUN(video.style.removeProperty("visibility")) | ||
RUN(document.documentElement.style.height = window.innerHeight + 20 + video.offsetHeight) | ||
RUN(window.scrollBy(0, 20 + video.offsetHeight)) | ||
EXPECTED (video.paused == 'false') OK | ||
END OF TEST | ||
|
58 changes: 58 additions & 0 deletions
58
LayoutTests/media/video-restricted-invisible-autoplay-allowed-if-audible.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<html> | ||
<head> | ||
<script src="media-file.js"></script> | ||
<script src="video-test.js"></script> | ||
<script> | ||
if (window.internals) | ||
internals.settings.setInvisibleAutoplayNotPermitted(true); | ||
|
||
function start() | ||
{ | ||
findMediaElement(); | ||
consoleWrite('** setting video.src'); | ||
video.src = findMediaFile('video', 'content/test'); | ||
video.volume = 1; | ||
|
||
waitForEventOnce('play', play1); | ||
consoleWrite(''); | ||
} | ||
|
||
function play1() | ||
{ | ||
waitForEventAndFail('pause'); | ||
|
||
testExpected('video.paused', false); | ||
run('video.style.display = "none"'); | ||
setTimeout(play2, 10); | ||
} | ||
|
||
function play2() | ||
{ | ||
testExpected('video.paused', false); | ||
run('video.style.removeProperty("display")'); | ||
run('video.style.visibility = "hidden"'); | ||
setTimeout(play3, 10); | ||
} | ||
|
||
function play3() | ||
{ | ||
testExpected('video.paused', false); | ||
run('video.style.removeProperty("visibility")'); | ||
run('document.documentElement.style.height = window.innerHeight + 20 + video.offsetHeight'); | ||
run('window.scrollBy(0, 20 + video.offsetHeight)'); | ||
setTimeout(play4, 10); | ||
} | ||
|
||
function play4() | ||
{ | ||
testExpected('video.paused', false); | ||
endTest(); | ||
} | ||
</script> | ||
</head> | ||
|
||
<body onload="start()"> | ||
<video controls autoplay></video> | ||
<p>Test that "invisible autoplay not allowed restriction" does not pause audible media when scrolled out of view.</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters