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

Side by Side Diff: third_party/WebKit/LayoutTests/media/autoplay-muted.html

Issue 2047333002: Pause autoplay muted video when unmuting if there's no user gesture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@autoplay-flag
Patch Set: Check isGestureNeeded when unmuting Created 4 years, 6 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Test for autoplay of muted video</title> 2 <title>Test for autoplay of muted video</title>
3 <script src="../resources/testharness.js"></script> 3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script> 4 <script src="../resources/testharnessreport.js"></script>
5 <script src="media-file.js"></script> 5 <script src="media-file.js"></script>
6 <script src="media-controls.js"></script>
6 <script> 7 <script>
8 test(function()
9 {
10 assert_true(!!window.internals
11 && !!window.internals.settings
12 && !!window.internals.runtimeFlags
13 && !!window.eventSender,
14 "This test only works when run as a layout test!");
15 }, "Prerequisites to running the rest of the tests");
16
7 window.internals.settings.setMediaPlaybackRequiresUserGesture(true); 17 window.internals.settings.setMediaPlaybackRequiresUserGesture(true);
8 window.internals.runtimeFlags.autoplayMutedVideosEnabled = true; 18 window.internals.runtimeFlags.autoplayMutedVideosEnabled = true;
9 19
10 function createMutedVideoElement() { 20 function createMutedVideoElement() {
11 var e = document.createElement('video'); 21 var e = document.createElement('video');
12 e.src = findMediaFile('video', 'content/test'); 22 e.src = findMediaFile('video', 'content/test');
13 e.muted = true; 23 e.muted = true;
14 return e; 24 return e;
15 } 25 }
16 26
17 async_test(function(t) 27 async_test(function(t)
18 { 28 {
19 var e = createMutedVideoElement(); 29 var e = createMutedVideoElement();
20 e.autoplay = true; 30 e.autoplay = true;
21 31
22 var expectedEvents = [ 32 var expectedEvents = [
23 'canplay', 'play', 'playing']; 33 'canplay', 'play', 'playing'];
24 var eventWatcher = new EventWatcher(t, e, expectedEvents); 34 var eventWatcher = new EventWatcher(t, e, expectedEvents);
25 eventWatcher.wait_for(expectedEvents) 35 eventWatcher.wait_for(expectedEvents).then(
26 .then(t.step_func_done(function() 36 t.step_func_done(function()
27 { 37 {
mlamouri (slow - plz ping) 2016/06/09 17:43:16 style: { at end of previous line (here and other p
28 assert_false(e.paused); 38 assert_false(e.paused);
29 })); 39 }));
30 }, "muted-autoplay"); 40 }, "Test that a muted video with an autoplay attribute autoplays.");
31 41
32 promise_test(function() 42 promise_test(function()
33 { 43 {
34 return createMutedVideoElement().play(); 44 return createMutedVideoElement().play();
35 }, "muted-playjs"); 45 }, "Test that play() on a muted video succeeds without gesture.");
46
47 promise_test(function(t)
48 {
49 var e = createMutedVideoElement();
50 return e.play().then(
51 t.step_func_done(function()
52 {
53 e.muted = false;
54 assert_true(e.paused, "The video should be paused.");
55 }));
56 }, "Test that unmuting an autoplayed video without gesture pauses.");
57
58 async_test(function(t)
59 {
60 var e = createMutedVideoElement();
61 e.play().then(
62 t.step_func(function()
63 {
64 document.onclick = t.step_func_done(function()
mlamouri (slow - plz ping) 2016/06/09 17:43:16 can you move this outside of the play() handler? j
65 {
66 e.muted = false;
67 assert_false(e.paused,
68 "The video should not be paused.");
69 });
70
71 eventSender.mouseDown();
72 eventSender.mouseUp();
73 }));
74 }, "Test that unmuting autoplayed video with gesture doesn't pause it.");
36 </script> 75 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698