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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLMediaElement.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title>Test behaviour of autoplay muted videos with regards to visibility</title >
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script>
5 <script src="media-file.js"></script>
6 <body>
7 <script>
8 window.internals.settings.setMediaPlaybackRequiresUserGesture(true);
9 window.internals.runtimeFlags.autoplayMutedVideosEnabled = true;
10
11 var gCycleCount = 0;
12
13 var video;
14
15 function runStepsWhenInvisible(t) {
16 assert_true(video.paused);
17 video.style.top = '0px';
18
19 video.onplay = null;
20 video.onpause = t.unreached_func();
21 video.addEventListener('play', t.step_func(_ => runStepsWhenVisible(t)), { o nce: true });
22 }
23
24 function runStepsWhenVisible(t) {
25 assert_false(video.paused);
26
27 if (gCycleCount++ >= 3) {
28 t.done();
29 return;
30 }
31 video.style.top = '-10000px';
32
33 video.onpause = null;
34 video.onplay = t.unreached_func();
35 video.addEventListener('pause', t.step_func(_ => runStepsWhenInvisible(t)), { once: true });
36 }
37
38 async_test(function(t) {
39 // Create a video off screen.
40 {
41 video = document.createElement('video');
42 video.src = findMediaFile('video', 'content/test');
43 video.muted = true;
44 video.autoplay = true;
45 video.loop = true;
46 video.style.position = 'absolute';
47 video.style.top = '-10000px';
48 document.body.appendChild(video);
49 }
50
51 video.addEventListener('canplay', t.step_func(_ => runStepsWhenInvisible(t)) , { once : true });
52 });
53 </script>
OLDNEW
« 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