| OLD | NEW |
| 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 <body> |
| 7 <script> | 8 <script> |
| 8 test(function() { | 9 test(function() { |
| 9 assert_true(!!window.internals | 10 assert_true(!!window.internals |
| 10 && !!window.internals.settings | 11 && !!window.internals.settings |
| 11 && !!window.internals.runtimeFlags | 12 && !!window.internals.runtimeFlags |
| 12 && !!window.eventSender, | 13 && !!window.eventSender, |
| 13 "This test only works when run as a layout test!"); | 14 "This test only works when run as a layout test!"); |
| 14 }, "Prerequisites to running the rest of the tests"); | 15 }, "Prerequisites to running the rest of the tests"); |
| 15 | 16 |
| 16 window.internals.settings.setMediaPlaybackRequiresUserGesture(true); | 17 window.internals.settings.setMediaPlaybackRequiresUserGesture(true); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 28 return createMutedMediaElement('video'); | 29 return createMutedMediaElement('video'); |
| 29 } | 30 } |
| 30 | 31 |
| 31 function createMutedAudioElement() { | 32 function createMutedAudioElement() { |
| 32 return createMutedMediaElement('audio'); | 33 return createMutedMediaElement('audio'); |
| 33 } | 34 } |
| 34 | 35 |
| 35 async_test(function(t) { | 36 async_test(function(t) { |
| 36 var e = createMutedVideoElement(); | 37 var e = createMutedVideoElement(); |
| 37 e.autoplay = true; | 38 e.autoplay = true; |
| 39 document.body.appendChild(e); |
| 38 | 40 |
| 39 var expectedEvents = [ 'canplay', 'play', 'playing']; | 41 var expectedEvents = [ 'canplay', 'play', 'playing']; |
| 40 var eventWatcher = new EventWatcher(t, e, expectedEvents); | 42 var eventWatcher = new EventWatcher(t, e, expectedEvents); |
| 41 eventWatcher.wait_for(expectedEvents).then( | 43 eventWatcher.wait_for(expectedEvents).then( |
| 42 t.step_func_done(function() { | 44 t.step_func_done(function() { |
| 43 assert_false(e.paused); | 45 assert_false(e.paused); |
| 44 })); | 46 })); |
| 45 }, "Test that a muted video with an autoplay attribute autoplays."); | 47 }, "Test that a muted video with an autoplay attribute autoplays."); |
| 46 | 48 |
| 47 promise_test(function() { | 49 promise_test(function() { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 promise_test(function(t) { | 95 promise_test(function(t) { |
| 94 testRunner.setAutoplayAllowed(false); | 96 testRunner.setAutoplayAllowed(false); |
| 95 return promise_rejects( | 97 return promise_rejects( |
| 96 t, | 98 t, |
| 97 new DOMException( | 99 new DOMException( |
| 98 'play() can only be initiated by a user gesture.', | 100 'play() can only be initiated by a user gesture.', |
| 99 'NotAllowedError'), | 101 'NotAllowedError'), |
| 100 createMutedVideoElement().play()); | 102 createMutedVideoElement().play()); |
| 101 }, "Test that muted videos don't autoplay when the setting is disabled"); | 103 }, "Test that muted videos don't autoplay when the setting is disabled"); |
| 102 </script> | 104 </script> |
| 105 </body> |
| OLD | NEW |