Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <script src=media-file.js></script> | |
| 2 <script src=video-test.js></script> | |
| 3 <script> | |
| 4 | |
| 5 function runTest() | |
| 6 { | |
| 7 function prepareVideo(parent) | |
| 8 { | |
| 9 var video = document.createElement("video"); | |
| 10 video.src = mediaFile; | |
| 11 video.autoplay = true; | |
| 12 parent.appendChild(video); | |
| 13 | |
| 14 return video; | |
| 15 } | |
| 16 | |
| 17 function didPlaybackStart(element) | |
| 18 { | |
| 19 return !element.paused || element.ended; | |
| 20 } | |
| 21 | |
| 22 var mediaFile = findMediaFile("video", "content/test"); | |
|
philipj_slow
2015/09/11 07:17:47
So this actually works because prepareVideo() is i
liberato (no reviews please)
2015/09/11 19:01:42
Done.
| |
| 23 var parent = document.createElement("div"); | |
| 24 document.body.appendChild(parent); | |
| 25 | |
| 26 // Require a user gesture, but override it for muted videos. | |
| 27 internals.settings.setMediaPlaybackRequiresUserGesture(true); | |
| 28 internals.settings.setAutoplayExperimentMode("enabled-forvideo-ifmuted"); | |
| 29 | |
| 30 var videoShouldPlay = prepareVideo(parent); | |
| 31 var videoShouldNotPlay = prepareVideo(parent); | |
| 32 | |
| 33 // Pause() will clear the autoplaying flag, which should also prevent the | |
| 34 // gesture override experiment from autoplaying. | |
| 35 videoShouldNotPlay.pause(); | |
| 36 | |
| 37 // Mute them both, and see if only one starts. | |
| 38 videoShouldPlay.muted = true; | |
| 39 videoShouldNotPlay.muted = true; | |
| 40 logResult(didPlaybackStart(videoShouldPlay), "First video should play"); | |
| 41 logResult(!didPlaybackStart(videoShouldNotPlay), "Second video should not pl ay"); | |
| 42 testRunner.notifyDone(); | |
| 43 } | |
| 44 | |
| 45 </script> | |
| 46 <p>Test that the autoplay experiment doesn't play media once the media | |
| 47 is no longer eligible for autoplay.</p> | |
| 48 <body onLoad="runTest()"> | |
| 49 </body> | |
| OLD | NEW |