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

Unified Diff: third_party/WebKit/LayoutTests/media/media-element-play-after-eos.html

Issue 2285143003: Improve readability of media-element-play-after-eos.html (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/media/media-element-play-after-eos.html
diff --git a/third_party/WebKit/LayoutTests/media/media-element-play-after-eos.html b/third_party/WebKit/LayoutTests/media/media-element-play-after-eos.html
index dcc55461eb1242339a1ed0e8ccf3327c69628b53..be4404e32212da7d0b238e7eb5ac5f2cb511a493 100644
--- a/third_party/WebKit/LayoutTests/media/media-element-play-after-eos.html
+++ b/third_party/WebKit/LayoutTests/media/media-element-play-after-eos.html
@@ -5,39 +5,35 @@
<script src="media-file.js"></script>
<audio></audio>
<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) {
var loop = true;
var audio = document.querySelector("audio");
audio.src = findMediaFile("audio", "content/silence");
- audio.onloadedmetadata = t.step_func(function() {
- audio.onplaying = t.step_func(mediaPlaying);
-
- 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();
- });
-
+ var watcher = new EventWatcher(t, audio, ["loadedmetadata", "playing", "pause", "ended"]);
+ watcher.wait_for("loadedmetadata").then(t.step_func(function() {
audio.play();
- });
-
- function mediaPlaying() {
- audio.onplaying = null;
+ return watcher.wait_for("playing");
+ })).then(t.step_func(function() {
+ 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(function() {
+ assert_true(audio.ended);
+ audio.play();
+ return watcher.wait_for("playing");
+ })).then(t.step_func(function() {
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>
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698