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

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: addressed mlamouri's comments on 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();
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.
29
30 video.style.top = '-10000px';
31
32 video.onpause = null;
33 video.onplay = t.unreached_func();
34 video.addEventListener('pause', t.step_func(_ => runStepsWhenInvisible(t)), { once: true });
35 }
36
37 async_test(function(t) {
38 testInstance = t;
mlamouri (slow - plz ping) 2017/02/15 10:46:02 drop this?
Zhiqiang Zhang (Slow) 2017/02/15 11:26:41 Done.
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