Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <title>Test behaviour of autoplay muted videos with regards to visibility</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 window.internals.settings.setMediaPlaybackRequiresUserGesture(true); | |
| 9 window.internals.runtimeFlags.autoplayMutedVideosEnabled = true; | |
| 10 | |
| 11 var gCycleCount = 0; | |
| 12 | |
| 13 var video; | |
| 14 | |
| 15 function runStepsWhenInvisible(t) { | |
| 16 assert_true(video.paused); | |
| 17 video.style.top = '0px'; | |
| 18 | |
| 19 video.onplay = null; | |
| 20 video.onpause = t.unreached_func(); | |
| 21 video.addEventListener('play', t.step_func(_ => runStepsWhenVisible(t)), { o nce: true }); | |
| 22 } | |
| 23 | |
| 24 function runStepsWhenVisible(t) { | |
| 25 assert_false(video.paused); | |
| 26 | |
| 27 if (gCycleCount++ >= 3) | |
| 28 t.done(); | |
|
mlamouri (slow - plz ping)
2017/02/15 10:46:02
Can you return too just to make sure we don't run
Zhiqiang Zhang (Slow)
2017/02/15 11:26:41
Done.
| |
| 29 | |
| 30 video.style.top = '-10000px'; | |
| 31 | |
| 32 video.onpause = null; | |
| 33 video.onplay = t.unreached_func(); | |
| 34 video.addEventListener('pause', t.step_func(_ => runStepsWhenInvisible(t)), { once: true }); | |
| 35 } | |
| 36 | |
| 37 async_test(function(t) { | |
| 38 testInstance = t; | |
|
mlamouri (slow - plz ping)
2017/02/15 10:46:02
drop this?
Zhiqiang Zhang (Slow)
2017/02/15 11:26:41
Done.
| |
| 39 // Create a video off screen. | |
| 40 { | |
| 41 video = document.createElement('video'); | |
| 42 video.src = findMediaFile('video', 'content/test'); | |
| 43 video.muted = true; | |
| 44 video.autoplay = true; | |
| 45 video.loop = true; | |
| 46 video.style.position = 'absolute'; | |
| 47 video.style.top = '-10000px'; | |
| 48 document.body.appendChild(video); | |
| 49 } | |
| 50 | |
| 51 video.addEventListener('canplay', t.step_func(_ => runStepsWhenInvisible(t)) , { once : true }); | |
| 52 }); | |
| 53 </script> | |
| OLD | NEW |