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