Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Moving a media element from one document to another should not break …
…autoplay https://bugs.webkit.org/show_bug.cgi?id=241631 rdar://95060381 Patch by Youenn Fablet <youennf@gmail.com> on 2022-06-16 Reviewed by Eric Carlson. When pausing a video element when being detached from a document, autoplay might get broken if the element is interrupted due to invisibility. In that case, the session will store the fact that the element is paused and when the end of invisibility interruption happens, the session state is Paused instead of Autoplay. To prevent this, we do not pause when being detached if we are alread interrupted due to invisibility. Covered by added test. * LayoutTests/http/tests/webrtc/resources/utility-frame.html: Added. * LayoutTests/http/tests/webrtc/video-mediastream-invisible-autoplay-detached-expected.txt: Added. * LayoutTests/http/tests/webrtc/video-mediastream-invisible-autoplay-detached.html: Added. * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::pauseAfterDetachedTask): Canonical link: https://commits.webkit.org/251595@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295590 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
1 parent
b13a5ff
commit f137908f57f04b737f24a764216001d3b0c562a9
Showing
4 changed files
with
87 additions
and
1 deletion.
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
| @@ -0,0 +1,5 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <body> | ||
| </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
| @@ -0,0 +1,10 @@ | ||
| Test that "invisible autoplay not allowed restriction" pauses realtime media when scrolled out of view and restarts as expected. | ||
|
|
||
| ** setting video.srcObject | ||
| ** waiting to play | ||
|
|
||
| ** element played | ||
| ** element paused | ||
| ** element played | ||
| ** test finished | ||
|
|
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
| @@ -0,0 +1,71 @@ | ||
| <html> | ||
| <head> | ||
| </head> | ||
| <script> | ||
| if (window.testRunner) { | ||
| testRunner.dumpAsText(); | ||
| testRunner.waitUntilDone(); | ||
| } | ||
| if (window.internals) | ||
| internals.settings.setInvisibleAutoplayNotPermitted(true); | ||
| </script> | ||
| <body> | ||
| <video autoplay width=320px height=240px id=videoElement controls playsInline></video> | ||
| <p>Test that "invisible autoplay not allowed restriction" pauses realtime media when scrolled out of view and restarts as expected.</p> | ||
| <div id="log"></div> | ||
| <iframe wdith=640px height=480px id="testFrame" src="resources/utility-frame.html"></iframe> | ||
| <script> | ||
| let myVideo = videoElement; | ||
|
|
||
| function doLog(msg) | ||
| { | ||
| log.innerHTML += msg + "<br>"; | ||
| } | ||
|
|
||
| async function start() | ||
| { | ||
| doLog('** setting video.srcObject'); | ||
| myVideo.srcObject = await navigator.mediaDevices.getUserMedia({ video: true }); | ||
| doLog('** waiting to play'); | ||
| myVideo.onplay = play1; | ||
| doLog(''); | ||
| } | ||
|
|
||
| async function play1() | ||
| { | ||
| myVideo.onplay = undefined; | ||
|
|
||
| doLog('** element played'); | ||
|
|
||
| myVideo.style.display = "none"; | ||
| document.body.removeChild(myVideo); | ||
| await new Promise(resolve => setTimeout(resolve, 500)); | ||
| if (myVideo.paused) { | ||
| pause1(); | ||
| return; | ||
| } | ||
| myVideo.onpause = pause1; | ||
| } | ||
|
|
||
| async function pause1() | ||
| { | ||
| myVideo.onpause = undefined; | ||
|
|
||
| doLog('** element paused'); | ||
| testFrame.contentDocument.body.appendChild(myVideo); | ||
| myVideo.style.removeProperty("display"); | ||
| myVideo.onplay = finish; | ||
| } | ||
|
|
||
| function finish() | ||
| { | ||
| myVideo.onplay = undefined; | ||
| doLog('** element played'); | ||
| doLog('** test finished'); | ||
| if (window.testRunner) | ||
| testRunner.notifyDone(); | ||
| } | ||
| start(); | ||
| </script> | ||
| </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