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 <body> |
8 <script> | 8 <script> |
9 test(function() { | 9 test(function() { |
10 assert_true(!!window.internals | 10 assert_true(!!window.internals |
11 && !!window.internals.settings | 11 && !!window.internals.settings |
12 && !!window.internals.runtimeFlags | 12 && !!window.internals.runtimeFlags |
13 && !!window.eventSender, | 13 && !!window.eventSender, |
14 "This test only works when run as a layout test!"); | 14 "This test only works when run as a layout test!"); |
15 }, "Prerequisites to running the rest of the tests"); | 15 }, "Prerequisites to running the rest of the tests"); |
16 | 16 |
17 window.internals.settings.setMediaPlaybackRequiresUserGesture(true); | 17 window.internals.settings.setAutoplayPolicy('user-gesture-required'); |
18 window.internals.runtimeFlags.autoplayMutedVideosEnabled = true; | 18 window.internals.runtimeFlags.autoplayMutedVideosEnabled = true; |
19 testRunner.setAutoplayAllowed(true); | 19 testRunner.setAutoplayAllowed(true); |
20 | 20 |
21 function createMutedMediaElement(type) { | 21 function createMutedMediaElement(type) { |
22 var e = document.createElement(type); | 22 var e = document.createElement(type); |
23 e.src = findMediaFile(type, 'content/test'); | 23 e.src = findMediaFile(type, 'content/test'); |
24 e.muted = true; | 24 e.muted = true; |
25 return e; | 25 return e; |
26 } | 26 } |
27 | 27 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 testRunner.setAutoplayAllowed(false); | 101 testRunner.setAutoplayAllowed(false); |
102 return promise_rejects( | 102 return promise_rejects( |
103 t, | 103 t, |
104 new DOMException( | 104 new DOMException( |
105 'play() can only be initiated by a user gesture.', | 105 'play() can only be initiated by a user gesture.', |
106 'NotAllowedError'), | 106 'NotAllowedError'), |
107 createMutedVideoElement().play()); | 107 createMutedVideoElement().play()); |
108 }, "Test that muted videos don't autoplay when the setting is disabled"); | 108 }, "Test that muted videos don't autoplay when the setting is disabled"); |
109 </script> | 109 </script> |
110 </body> | 110 </body> |
OLD | NEW |