Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Unified Diff: LayoutTests/media/video-autoplay-experiment-just-once.html

Issue 1179223002: Implement autoplay gesture override experiment. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: CL feedback. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..013961122e2f8d01db6ff9720cb1314a6f7816a0
--- /dev/null
+++ b/LayoutTests/media/video-autoplay-experiment-just-once.html
@@ -0,0 +1,51 @@
+<script src=media-file.js></script>
+<script src=video-test.js></script>
+<script>
+
+var mediaFile;
+
+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");
+ 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>

Powered by Google App Engine
This is Rietveld 408576698