Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: third_party/WebKit/LayoutTests/media/autoplay-when-visible-multiple-times.html

Issue 2654123002: Autoplay muted video when visible and pause when invisible (Closed)
Patch Set: fixed tests Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLMediaElement.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLMediaElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698