OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Test for autoplay of video once the media stream is set to null</title> | 2 <title>Test for autoplay of video once the media stream is set to null</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> | 6 <script> |
7 test(function() { | 7 test(function() { |
8 assert_true(!!window.internals && !!window.internals.settings, | 8 assert_true(!!window.internals && !!window.internals.settings, |
9 "This test only works when run as a layout test!"); | 9 "This test only works when run as a layout test!"); |
10 }, "Prerequisites to running the rest of the tests"); | 10 }, "Prerequisites to running the rest of the tests"); |
11 | 11 |
12 window.internals.settings.setMediaPlaybackRequiresUserGesture(true); | 12 window.internals.settings.setAutoplayPolicy('user-gesture-required'); |
13 | 13 |
14 async_test(function(t) { | 14 async_test(function(t) { |
15 var v = document.createElement('video'); | 15 var v = document.createElement('video'); |
16 v.srcObject = (new AudioContext()).createMediaStreamDestination().stream
; | 16 v.srcObject = (new AudioContext()).createMediaStreamDestination().stream
; |
17 | 17 |
18 setTimeout(t.step_func(function() { | 18 setTimeout(t.step_func(function() { |
19 v.srcObject = null; | 19 v.srcObject = null; |
20 v.src = findMediaFile('video', 'content/test'); | 20 v.src = findMediaFile('video', 'content/test'); |
21 | 21 |
22 v.play() | 22 v.play() |
23 .then(t.unreached_func('The video must not play without user ges
ture.')) | 23 .then(t.unreached_func('The video must not play without user ges
ture.')) |
24 .catch(t.step_func_done(function() { | 24 .catch(t.step_func_done(function() { |
25 assert_true(v.paused); | 25 assert_true(v.paused); |
26 })); | 26 })); |
27 }), 0); | 27 }), 0); |
28 }, 'Test that switching from MediaStream to src= does not autoplay.'); | 28 }, 'Test that switching from MediaStream to src= does not autoplay.'); |
29 </script> | 29 </script> |
OLD | NEW |