Commit 00f5b745 authored by srirama.m's avatar srirama.m Committed by Commit bot

Improve readability of media-element-play-after-eos.html

Review-Url: https://codereview.chromium.org/2285143003
Cr-Commit-Position: refs/heads/master@{#415219}
parent f5a81bb9
...@@ -5,39 +5,35 @@ ...@@ -5,39 +5,35 @@
<script src="media-file.js"></script> <script src="media-file.js"></script>
<audio></audio> <audio></audio>
<script> <script>
// TODO(srirama.m): Modify the test to record events and check for order
// at the end of test. See autoplay-with-preload-none.html for help.
async_test(function(t) { async_test(function(t) {
var loop = true; var loop = true;
var audio = document.querySelector("audio"); var audio = document.querySelector("audio");
audio.src = findMediaFile("audio", "content/silence"); audio.src = findMediaFile("audio", "content/silence");
audio.onloadedmetadata = t.step_func(function() { var watcher = new EventWatcher(t, audio, ["loadedmetadata", "playing", "pause", "ended"]);
audio.onplaying = t.step_func(mediaPlaying); watcher.wait_for("loadedmetadata").then(t.step_func(function() {
audio.onpause = t.step_func(function() {
assert_true(audio.paused);
});
audio.onended = t.step_func(function() {
assert_true(audio.ended, true);
if (!loop) {
t.done();
return;
}
loop = false;
audio.onplaying = t.step_func(mediaPlaying);
audio.play();
});
audio.play(); audio.play();
}); return watcher.wait_for("playing");
})).then(t.step_func(function() {
function mediaPlaying() { audio.currentTime = audio.duration - 0.2;
audio.onplaying = null; return watcher.wait_for("playing");
})).then(t.step_func(function() {
return watcher.wait_for("pause");
})).then(t.step_func(function() {
assert_true(audio.paused);
return watcher.wait_for("ended");
})).then(t.step_func(function() {
assert_true(audio.ended);
audio.play();
return watcher.wait_for("playing");
})).then(t.step_func(function() {
audio.currentTime = audio.duration - 0.2; audio.currentTime = audio.duration - 0.2;
} return watcher.wait_for("playing");
})).then(t.step_func(function() {
return watcher.wait_for("pause");
})).then(t.step_func(function() {
assert_true(audio.paused);
return watcher.wait_for("ended");
})).then(t.step_func_done());
}); });
</script> </script>
\ No newline at end of file
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