Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <title>Moving media element to other document to bypass autoplay</title> | |
| 3 <script src="../resources/testharness.js"></script> | |
| 4 <script src="../resources/testharnessreport.js"></script> | |
| 5 <script src="media-file.js"></script> | |
| 6 <body> | |
| 7 <script> | |
| 8 function createAndMoveVideo() { | |
| 9 var v = document.implementation.createHTMLDocument().createElement('video'); | |
| 10 v.src = findMediaFile('video', 'content/test'); | |
| 11 document.body.appendChild(v); | |
| 12 return v; | |
| 13 } | |
| 14 | |
| 15 test(function() { | |
| 16 assert_true(window.internals != null, 'This test only works with internals e xposed present'); | |
| 17 }, 'internals are exposed'); | |
| 18 | |
| 19 async_test(function(t) { | |
| 20 window.internals.settings.setMediaPlaybackRequiresUserGesture(false); | |
| 21 var v = createAndMoveVideo(); | |
| 22 assert_true(v.paused, 'Video should be paused before calling play()'); | |
| 23 | |
| 24 v.play().then( | |
| 25 function(e) { | |
|
mlamouri (slow - plz ping)
2016/06/09 10:57:58
v.play().then(
t.step_func_done,
t.step_func_d
Zhiqiang Zhang (Slow)
2016/06/09 11:20:18
Done.
| |
| 26 t.done(); | |
| 27 }, | |
| 28 function(e) { | |
| 29 assert_unreached('Video should autoplay when gesture not required'); | |
| 30 t.done(); | |
| 31 }); | |
| 32 }, 'Test that video should autoplay without gesture requirement'); | |
| 33 | |
| 34 async_test(function(t) { | |
| 35 window.internals.settings.setMediaPlaybackRequiresUserGesture(true); | |
| 36 var v = createAndMoveVideo(); | |
| 37 assert_true(v.paused, 'Video should be paused before calling play()'); | |
| 38 | |
| 39 v.play().then( | |
| 40 function(e) { | |
| 41 assert_unreached('Video should not autoplay when gesture required'); | |
| 42 t.done(); | |
| 43 }, | |
| 44 function(e) { | |
| 45 t.done(); | |
| 46 }); | |
|
mlamouri (slow - plz ping)
2016/06/09 10:57:58
ditto
Zhiqiang Zhang (Slow)
2016/06/09 11:20:18
Done.
| |
| 47 }, 'Test that video should not autoplay when gesture required'); | |
| 48 </script> | |
| 49 </body> | |
| OLD | NEW |