| Index: third_party/WebKit/LayoutTests/media/autoplay-when-visible-multiple-times.html
|
| diff --git a/third_party/WebKit/LayoutTests/media/autoplay-when-visible-multiple-times.html b/third_party/WebKit/LayoutTests/media/autoplay-when-visible-multiple-times.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8f2b782a97f13767a17e5c28aa150cf43d6f6d8f
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/media/autoplay-when-visible-multiple-times.html
|
| @@ -0,0 +1,53 @@
|
| +<!DOCTYPE html>
|
| +<title>Test behaviour of autoplay muted videos with regards to visibility</title>
|
| +<script src="../resources/testharness.js"></script>
|
| +<script src="../resources/testharnessreport.js"></script>
|
| +<script src="media-file.js"></script>
|
| +<body>
|
| +<script>
|
| + window.internals.settings.setMediaPlaybackRequiresUserGesture(true);
|
| + window.internals.runtimeFlags.autoplayMutedVideosEnabled = true;
|
| +
|
| + var gCycleCount = 0;
|
| +
|
| + var video;
|
| +
|
| + function runStepsWhenInvisible(t) {
|
| + assert_true(video.paused);
|
| + video.style.top = '0px';
|
| +
|
| + video.onplay = null;
|
| + video.onpause = t.unreached_func();
|
| + video.addEventListener('play', t.step_func(_ => runStepsWhenVisible(t)), { once: true });
|
| + }
|
| +
|
| + function runStepsWhenVisible(t) {
|
| + assert_false(video.paused);
|
| +
|
| + if (gCycleCount++ >= 3) {
|
| + t.done();
|
| + return;
|
| + }
|
| + video.style.top = '-10000px';
|
| +
|
| + video.onpause = null;
|
| + video.onplay = t.unreached_func();
|
| + video.addEventListener('pause', t.step_func(_ => runStepsWhenInvisible(t)), { once: true });
|
| + }
|
| +
|
| + async_test(function(t) {
|
| + // Create a video off screen.
|
| + {
|
| + video = document.createElement('video');
|
| + video.src = findMediaFile('video', 'content/test');
|
| + video.muted = true;
|
| + video.autoplay = true;
|
| + video.loop = true;
|
| + video.style.position = 'absolute';
|
| + video.style.top = '-10000px';
|
| + document.body.appendChild(video);
|
| + }
|
| +
|
| + video.addEventListener('canplay', t.step_func(_ => runStepsWhenInvisible(t)), { once : true });
|
| + });
|
| +</script>
|
|
|