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

Side by Side Diff: third_party/WebKit/LayoutTests/media/video-autoplay-experiment-just-once.html

Issue 1470153004: Autoplay experiment metric fixes and additions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: back to using some of ::testing, since it works. Created 4 years, 10 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 unified diff | Download patch
OLDNEW
1 <script src=media-file.js></script> 1 <script src=media-file.js></script>
2 <script src=video-test.js></script> 2 <script src=video-test.js></script>
3 <script> 3 <script>
4 4
5 function runTest() 5 function runTest()
6 { 6 {
7 var canPlayThroughCount = 0;
8 var videoShouldPlay;
9 var videoShouldNotPlay;
10
11 testRunner.waitUntilDone();
12
13 function canPlayThrough()
14 {
15 canPlayThroughCount++;
16 if (canPlayThroughCount == 2) {
17 // Pause() will clear the autoplaying flag, which should also preven t the
18 // gesture override experiment from autoplaying.
19 videoShouldNotPlay.pause();
20
21 // Mute them both, and see if only one starts.
22 videoShouldPlay.muted = true;
23 videoShouldNotPlay.muted = true;
24 logResult(didPlaybackStart(videoShouldPlay), "First video should pla y");
25 logResult(!didPlaybackStart(videoShouldNotPlay), "Second video shoul d not play");
26 testRunner.notifyDone();
27 }
28 }
29
7 function prepareVideo(parent) 30 function prepareVideo(parent)
8 { 31 {
9 var video = document.createElement("video"); 32 var video = document.createElement("video");
33 video.oncanplaythrough = canPlayThrough;
10 video.src = findMediaFile("video", "content/test"); 34 video.src = findMediaFile("video", "content/test");
11 video.autoplay = true; 35 video.autoplay = true;
12 parent.appendChild(video); 36 parent.appendChild(video);
13 37
14 return video; 38 return video;
15 } 39 }
16 40
17 function didPlaybackStart(element) 41 function didPlaybackStart(element)
18 { 42 {
19 return !element.paused || element.ended; 43 return !element.paused || element.ended;
20 } 44 }
21 45
22 var parent = document.createElement("div"); 46 var parent = document.createElement("div");
23 document.body.appendChild(parent); 47 document.body.appendChild(parent);
24 48
25 // Require a user gesture, but override it for muted videos. 49 // Require a user gesture, but override it for muted videos.
26 internals.settings.setMediaPlaybackRequiresUserGesture(true); 50 internals.settings.setMediaPlaybackRequiresUserGesture(true);
27 internals.settings.setAutoplayExperimentMode("enabled-forvideo-ifmuted"); 51 internals.settings.setAutoplayExperimentMode("enabled-forvideo-ifmuted");
28 52
29 var videoShouldPlay = prepareVideo(parent); 53 videoShouldPlay = prepareVideo(parent);
30 var videoShouldNotPlay = prepareVideo(parent); 54 videoShouldNotPlay = prepareVideo(parent);
31
32 // Pause() will clear the autoplaying flag, which should also prevent the
33 // gesture override experiment from autoplaying.
34 videoShouldNotPlay.pause();
35
36 // Mute them both, and see if only one starts.
37 videoShouldPlay.muted = true;
38 videoShouldNotPlay.muted = true;
39 logResult(didPlaybackStart(videoShouldPlay), "First video should play");
40 logResult(!didPlaybackStart(videoShouldNotPlay), "Second video should not pl ay");
41 testRunner.notifyDone();
42 } 55 }
43 56
44 </script> 57 </script>
45 <p>Test that the autoplay experiment doesn't play media once the media 58 <p>Test that the autoplay experiment doesn't play media once the media
46 is no longer eligible for autoplay.</p> 59 is no longer eligible for autoplay.</p>
47 <body onLoad="runTest()"> 60 <body onLoad="runTest()">
48 </body> 61 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698