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 = findMediaFile("video", "content/test"); |
| 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 parent = document.createElement("div"); |
| 23 document.body.appendChild(parent); |
| 24 |
| 25 // Require a user gesture, but override it for muted videos. |
| 26 internals.settings.setMediaPlaybackRequiresUserGesture(true); |
| 27 internals.settings.setAutoplayExperimentMode("enabled-forvideo-ifmuted"); |
| 28 |
| 29 var videoShouldPlay = prepareVideo(parent); |
| 30 var 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 } |
| 43 |
| 44 </script> |
| 45 <p>Test that the autoplay experiment doesn't play media once the media |
| 46 is no longer eligible for autoplay.</p> |
| 47 <body onLoad="runTest()"> |
| 48 </body> |
OLD | NEW |