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

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: Addressed comments 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLMediaElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 assert_true(!!window.internals
10 && !!window.internals.settings
11 && !!window.internals.runtimeFlags
12 && !!window.eventSender,
13 "This test only works when run as a layout test!");
14 }, "Prerequisites to running the rest of the tests");
15
7 window.internals.settings.setMediaPlaybackRequiresUserGesture(true); 16 window.internals.settings.setMediaPlaybackRequiresUserGesture(true);
8 window.internals.runtimeFlags.autoplayMutedVideosEnabled = true; 17 window.internals.runtimeFlags.autoplayMutedVideosEnabled = true;
9 18
10 function createMutedVideoElement() { 19 function createMutedVideoElement() {
11 var e = document.createElement('video'); 20 var e = document.createElement('video');
12 e.src = findMediaFile('video', 'content/test'); 21 e.src = findMediaFile('video', 'content/test');
13 e.muted = true; 22 e.muted = true;
14 return e; 23 return e;
15 } 24 }
16 25
17 async_test(function(t) 26 async_test(function(t) {
18 {
19 var e = createMutedVideoElement(); 27 var e = createMutedVideoElement();
20 e.autoplay = true; 28 e.autoplay = true;
21 29
22 var expectedEvents = [ 30 var expectedEvents = [ 'canplay', 'play', 'playing'];
23 'canplay', 'play', 'playing'];
24 var eventWatcher = new EventWatcher(t, e, expectedEvents); 31 var eventWatcher = new EventWatcher(t, e, expectedEvents);
25 eventWatcher.wait_for(expectedEvents) 32 eventWatcher.wait_for(expectedEvents).then(
26 .then(t.step_func_done(function() 33 t.step_func_done(function() {
27 { 34 assert_false(e.paused);
28 assert_false(e.paused); 35 }));
29 })); 36 }, "Test that a muted video with an autoplay attribute autoplays.");
30 }, "muted-autoplay");
31 37
32 promise_test(function() 38 promise_test(function() {
33 {
34 return createMutedVideoElement().play(); 39 return createMutedVideoElement().play();
35 }, "muted-playjs"); 40 }, "Test that play() on a muted video succeeds without gesture.");
41
42 promise_test(function(t) {
43 var e = createMutedVideoElement();
44 return e.play().then(t.step_func_done(function() {
45 e.muted = false;
46 assert_true(e.paused, "The video should be paused.");
47 }));
48 }, "Test that unmuting an autoplayed video without gesture pauses.");
49
50 async_test(function(t) {
51 var e = createMutedVideoElement();
52
53 e.play().then(t.step_func(function() {
54 eventSender.mouseDown();
55 eventSender.mouseUp();
56 }));
57
58 document.onclick = t.step_func_done(function() {
59 e.muted = false;
60 assert_false(e.paused, "The video should not be paused.");
61 });
62 }, "Test that unmuting autoplayed video with gesture doesn't pause it.");
36 </script> 63 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLMediaElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698