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

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

Issue 2052623002: [Android, Media] Enable autoplay settings for muted autoplay, wired them up to the media element. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix-settings-npe
Patch Set: Rebased, added a test 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 src="media-controls.js"></script>
7 <script> 7 <script>
8 test(function() { 8 test(function() {
9 assert_true(!!window.internals 9 assert_true(!!window.internals
10 && !!window.internals.settings 10 && !!window.internals.settings
11 && !!window.internals.runtimeFlags 11 && !!window.internals.runtimeFlags
12 && !!window.eventSender, 12 && !!window.eventSender,
13 "This test only works when run as a layout test!"); 13 "This test only works when run as a layout test!");
14 }, "Prerequisites to running the rest of the tests"); 14 }, "Prerequisites to running the rest of the tests");
15 15
16 window.internals.settings.setMediaPlaybackRequiresUserGesture(true); 16 window.internals.settings.setMediaPlaybackRequiresUserGesture(true);
17 window.internals.runtimeFlags.autoplayMutedVideosEnabled = true; 17 window.internals.runtimeFlags.autoplayMutedVideosEnabled = true;
18 testRunner.setAutoplayAllowed(true);
18 19
19 function createMutedVideoElement() { 20 function createMutedVideoElement() {
20 var e = document.createElement('video'); 21 var e = document.createElement('video');
21 e.src = findMediaFile('video', 'content/test'); 22 e.src = findMediaFile('video', 'content/test');
22 e.muted = true; 23 e.muted = true;
23 return e; 24 return e;
24 } 25 }
25 26
26 async_test(function(t) { 27 async_test(function(t) {
27 var e = createMutedVideoElement(); 28 var e = createMutedVideoElement();
(...skipping 25 matching lines...) Expand all
53 e.play().then(t.step_func(function() { 54 e.play().then(t.step_func(function() {
54 eventSender.mouseDown(); 55 eventSender.mouseDown();
55 eventSender.mouseUp(); 56 eventSender.mouseUp();
56 })); 57 }));
57 58
58 document.onclick = t.step_func_done(function() { 59 document.onclick = t.step_func_done(function() {
59 e.muted = false; 60 e.muted = false;
60 assert_false(e.paused, "The video should not be paused."); 61 assert_false(e.paused, "The video should not be paused.");
61 }); 62 });
62 }, "Test that unmuting autoplayed video with gesture doesn't pause it."); 63 }, "Test that unmuting autoplayed video with gesture doesn't pause it.");
64
65 promise_test(function(t) {
66 testRunner.setAutoplayAllowed(false);
67 return promise_rejects(
68 t,
69 new DOMException(
70 'play() can only be initiated by a user gesture.',
71 'NotAllowedError'),
72 createMutedVideoElement().play());
73 }, "Test that muted videos don't autoplay when the setting is disabled");
63 </script> 74 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698