Commit 9ebd080e authored by srirama.m's avatar srirama.m Committed by Commit bot

Remove video-test.js dependency from video-autoplay-experiment-just-once.html

BUG=588956

Review-Url: https://codereview.chromium.org/2145893003
Cr-Commit-Position: refs/heads/master@{#405200}
parent 7668db46
Test that the autoplay experiment doesn't play media once the media is no longer eligible for autoplay. Test that the autoplay experiment doesn't play media once the media is no longer eligible for autoplay.
First video should play OK PASS First video is playing
Second video should not play OK PASS Second video isn't playing
<!DOCTYPE html>
<script src=media-file.js></script> <script src=media-file.js></script>
<!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956
(Please avoid writing new tests using video-test.js) -->
<script src=video-test.js></script>
<script> <script>
function runTest() {
function runTest()
{
var canPlayThroughCount = 0; var canPlayThroughCount = 0;
var videoShouldPlay; var videoShouldPlay;
var videoShouldNotPlay; var videoShouldNotPlay;
testRunner.waitUntilDone(); testRunner.waitUntilDone();
testRunner.dumpAsText();
function canPlayThrough() function canPlayThrough() {
{
canPlayThroughCount++; canPlayThroughCount++;
if (canPlayThroughCount == 2) { if (canPlayThroughCount == 2) {
// Pause() will clear the autoplaying flag, which should also prevent the // Pause() will clear the autoplaying flag, which should also prevent the
...@@ -23,16 +19,27 @@ function runTest() ...@@ -23,16 +19,27 @@ function runTest()
// Scroll them into view, and see if they start playing. // Scroll them into view, and see if they start playing.
parent.scrollIntoView(true); parent.scrollIntoView(true);
// TODO(liberato): remove once autoplay gesture override experiment concludes. // TODO(liberato): remove once autoplay gesture override experiment concludes.
window.internals.triggerAutoplayViewportCheck(videoShouldPlay); internals.triggerAutoplayViewportCheck(videoShouldPlay);
window.internals.triggerAutoplayViewportCheck(videoShouldNotPlay); internals.triggerAutoplayViewportCheck(videoShouldNotPlay);
logResult(didPlaybackStart(videoShouldPlay), "First video should play"); var result;
logResult(!didPlaybackStart(videoShouldNotPlay), "Second video should not play"); if (didPlaybackStart(videoShouldPlay))
result = document.createTextNode("PASS First video is playing");
else
result = document.createTextNode("FAIL First video isn't playing");
document.body.appendChild(result);
document.body.appendChild(document.createElement("br"));
if (!didPlaybackStart(videoShouldNotPlay))
result = document.createTextNode("PASS Second video isn't playing");
else
result = document.createTextNode("FAIL Second video is playing");
document.body.appendChild(result);
testRunner.notifyDone(); testRunner.notifyDone();
} }
} }
function prepareVideo(parent) function prepareVideo(parent) {
{
var video = document.createElement("video"); var video = document.createElement("video");
video.oncanplaythrough = canPlayThrough; video.oncanplaythrough = canPlayThrough;
video.src = findMediaFile("video", "content/test"); video.src = findMediaFile("video", "content/test");
...@@ -42,8 +49,7 @@ function runTest() ...@@ -42,8 +49,7 @@ function runTest()
return video; return video;
} }
function didPlaybackStart(element) function didPlaybackStart(element) {
{
return !element.paused || element.ended; return !element.paused || element.ended;
} }
...@@ -65,7 +71,6 @@ function runTest() ...@@ -65,7 +71,6 @@ function runTest()
videoShouldPlay = prepareVideo(parent); videoShouldPlay = prepareVideo(parent);
videoShouldNotPlay = prepareVideo(parent); videoShouldNotPlay = prepareVideo(parent);
} }
</script> </script>
<p>Test that the autoplay experiment doesn't play media once the media <p>Test that the autoplay experiment doesn't play media once the media
is no longer eligible for autoplay.</p> is no longer eligible for autoplay.</p>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment