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

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: finalizing implementation and 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 expectations = [ 'paused', 'playing', 'paused', 'playing', 'paused', 'play ing', 'paused' ];
whywhat 2017/02/13 16:50:15 I don't think this is needed at all: - you know wh
Zhiqiang Zhang (Slow) 2017/02/13 17:48:05 Now add/remove event listeners to ensure the event
12 var expectationId = 0;
13
14 function checkExpectations(t, observed) {
15 assert_equals(expectations[expectationId++], observed);
16 if (expectationId >= expectations.length)
17 t.done();
18 }
19
20 var video;
21
22 function runStepsWhenInvisible(t) {
23 assert_true(video.paused);
24 checkExpectations(t, 'paused');
whywhat 2017/02/13 16:50:15 you could simplify these two lines (ditto below) b
Zhiqiang Zhang (Slow) 2017/02/13 17:48:05 This no longer applies as removed.
25 video.style.top = '0px';
26 }
27
28 function runStepsWhenVisible(t) {
29 assert_false(video.paused);
30 checkExpectations(t, 'playing');
31 video.style.top = '-10000px';
32 }
33
34 async_test(function(t) {
35 // Create a video off screen.
36 {
37 video = document.createElement('video');
38 video.src = findMediaFile('video', 'content/test');
39 video.muted = true;
40 video.autoplay = true;
41 video.loop = true;
42 video.style.position = 'absolute';
43 video.style.top = '-10000px';
44 document.body.appendChild(video);
45 }
46
47 video.addEventListener('canplay', t.step_func(_ => runStepsWhenInvisible(t)) );
whywhat 2017/02/13 16:50:15 will this event fire only once during this test? m
Zhiqiang Zhang (Slow) 2017/02/13 17:48:05 Done.
48 video.addEventListener('play', t.step_func(_ => runStepsWhenVisible(t)));
whywhat 2017/02/13 16:50:15 I'd rather have a visibility observer to check the
Zhiqiang Zhang (Slow) 2017/02/13 17:48:05 I prefer not to use visibility observer as the int
49 video.addEventListener('pause', t.step_func(_ => runStepsWhenInvisible(t)));
50 });
51 </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