| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Moving media element to other document to bypass autoplay</title> | 2 <title>Moving media element to other document to bypass autoplay</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 <body> | 6 <body> |
| 7 <script> | 7 <script> |
| 8 function createAndMoveVideo() { | 8 function createAndMoveVideo() { |
| 9 var v = document.implementation.createHTMLDocument().createElement('video'); | 9 var v = document.implementation.createHTMLDocument().createElement('video'); |
| 10 v.src = findMediaFile('video', 'content/test'); | 10 v.src = findMediaFile('video', 'content/test'); |
| 11 document.body.appendChild(v); | 11 document.body.appendChild(v); |
| 12 return v; | 12 return v; |
| 13 } | 13 } |
| 14 | 14 |
| 15 test(function() { | 15 test(function() { |
| 16 assert_true(window.internals != null, 'This test only works with internals e
xposed present'); | 16 assert_true(window.internals != null, 'This test only works with internals e
xposed present'); |
| 17 }, 'internals are exposed'); | 17 }, 'internals are exposed'); |
| 18 | 18 |
| 19 async_test(function(t) { | 19 async_test(function(t) { |
| 20 window.internals.settings.setMediaPlaybackRequiresUserGesture(false); | 20 window.internals.settings.setAutoplayPolicy('no-user-gesture-required'); |
| 21 var v = createAndMoveVideo(); | 21 var v = createAndMoveVideo(); |
| 22 assert_true(v.paused, 'Video should be paused before calling play()'); | 22 assert_true(v.paused, 'Video should be paused before calling play()'); |
| 23 | 23 |
| 24 v.play().then( | 24 v.play().then( |
| 25 t.step_func_done(), | 25 t.step_func_done(), |
| 26 t.step_func_done(function() { | 26 t.step_func_done(function() { |
| 27 assert_unreached('Video should autoplay when gesture not required'); | 27 assert_unreached('Video should autoplay when gesture not required'); |
| 28 })); | 28 })); |
| 29 }, 'Test that video should autoplay without gesture requirement'); | 29 }, 'Test that video should autoplay without gesture requirement'); |
| 30 | 30 |
| 31 async_test(function(t) { | 31 async_test(function(t) { |
| 32 window.internals.settings.setMediaPlaybackRequiresUserGesture(true); | 32 window.internals.settings.setAutoplayPolicy('user-gesture-required'); |
| 33 var v = createAndMoveVideo(); | 33 var v = createAndMoveVideo(); |
| 34 assert_true(v.paused, 'Video should be paused before calling play()'); | 34 assert_true(v.paused, 'Video should be paused before calling play()'); |
| 35 | 35 |
| 36 v.play().then( | 36 v.play().then( |
| 37 t.step_func_done(function() { | 37 t.step_func_done(function() { |
| 38 assert_unreached('Video should not autoplay when gesture required'); | 38 assert_unreached('Video should not autoplay when gesture required'); |
| 39 }), | 39 }), |
| 40 t.step_func_done()); | 40 t.step_func_done()); |
| 41 }, 'Test that video should not autoplay when gesture required'); | 41 }, 'Test that video should not autoplay when gesture required'); |
| 42 </script> | 42 </script> |
| 43 </body> | 43 </body> |
| OLD | NEW |