| <html> |
| <head> |
| <script src="../../media/video-test.js"></script> |
| <script> |
| if (window.internals) |
| internals.settings.setInvisibleAutoplayNotPermitted(true); |
| async function start() |
| { |
| findMediaElement(); |
| consoleWrite('** setting video.srcObject'); |
| video.srcObject = await navigator.mediaDevices.getUserMedia({ audio: true, video: true }); |
| video.muted = true; |
| |
| waitForEventOnce('play', play1); |
| consoleWrite(''); |
| } |
| |
| function play1() |
| { |
| run('video.style.display = "none"'); |
| waitForEventOnce('pause', pause1); |
| } |
| |
| function pause1() |
| { |
| run('video.style.removeProperty("display")') |
| waitForEventOnce('play', play2); |
| } |
| |
| async function play2() |
| { |
| run('video.style.visibility = "hidden"'); |
| waitForEventOnce('pause', pause2); |
| } |
| |
| async function pause2() |
| { |
| // At this point, we are interrupted, calling play should be a no-op and should not confuse our interruption state tracking. |
| video.play(); |
| |
| run('video.style.removeProperty("visibility")'); |
| waitForEventOnce('play', play3); |
| } |
| |
| function play3() |
| { |
| run('document.documentElement.style.height = window.innerHeight + 20 + video.offsetHeight'); |
| run('window.scrollBy(0, 20 + video.offsetHeight)'); |
| waitForEventOnce('pause', pause3); |
| } |
| |
| function pause3() |
| { |
| run('window.scrollTo(0, 0)'); |
| waitForEventOnce('play', finish); |
| } |
| |
| function finish() |
| { |
| video.srcObject.getVideoTracks()[0].stop(); |
| video.srcObject = null; |
| endTest(); |
| } |
| </script> |
| </head> |
| |
| <body onload="start()"> |
| <video controls autoplay></video> |
| <p>Test that "invisible autoplay not allowed restriction" pauses realtime media when scrolled out of view and restarts as expected.</p> |
| </body> |
| </html> |