Chromium Code Reviews| 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..553c3e7551f2fcc8e779001c3890da85fb0beb46 |
| --- /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(); |
|
mlamouri (slow - plz ping)
2017/02/15 10:46:02
Can you return too just to make sure we don't run
Zhiqiang Zhang (Slow)
2017/02/15 11:26:41
Done.
|
| + |
| + 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) { |
| + testInstance = t; |
|
mlamouri (slow - plz ping)
2017/02/15 10:46:02
drop this?
Zhiqiang Zhang (Slow)
2017/02/15 11:26:41
Done.
|
| + // 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> |