Chromium Code Reviews| Index: LayoutTests/media/video-autoplay-experiment-just-once.html |
| diff --git a/LayoutTests/media/video-autoplay-experiment-just-once.html b/LayoutTests/media/video-autoplay-experiment-just-once.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..96bc33f3ab1f219d77d4cdd0d5c99401341e0a4f |
| --- /dev/null |
| +++ b/LayoutTests/media/video-autoplay-experiment-just-once.html |
| @@ -0,0 +1,49 @@ |
| +<script src=media-file.js></script> |
| +<script src=video-test.js></script> |
| +<script> |
| + |
| +function runTest() |
| +{ |
| + function prepareVideo(parent) |
| + { |
| + var video = document.createElement("video"); |
| + video.src = mediaFile; |
| + video.autoplay = true; |
| + parent.appendChild(video); |
| + |
| + return video; |
| + } |
| + |
| + function didPlaybackStart(element) |
| + { |
| + return !element.paused || element.ended; |
| + } |
| + |
| + 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.
|
| + var parent = document.createElement("div"); |
| + document.body.appendChild(parent); |
| + |
| + // Require a user gesture, but override it for muted videos. |
| + internals.settings.setMediaPlaybackRequiresUserGesture(true); |
| + internals.settings.setAutoplayExperimentMode("enabled-forvideo-ifmuted"); |
| + |
| + var videoShouldPlay = prepareVideo(parent); |
| + var videoShouldNotPlay = prepareVideo(parent); |
| + |
| + // Pause() will clear the autoplaying flag, which should also prevent the |
| + // gesture override experiment from autoplaying. |
| + videoShouldNotPlay.pause(); |
| + |
| + // Mute them both, and see if only one starts. |
| + videoShouldPlay.muted = true; |
| + videoShouldNotPlay.muted = true; |
| + logResult(didPlaybackStart(videoShouldPlay), "First video should play"); |
| + logResult(!didPlaybackStart(videoShouldNotPlay), "Second video should not play"); |
| + testRunner.notifyDone(); |
| +} |
| + |
| +</script> |
| +<p>Test that the autoplay experiment doesn't play media once the media |
| +is no longer eligible for autoplay.</p> |
| +<body onLoad="runTest()"> |
| +</body> |