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 91c52fd63906d5fe66750c64417d61151932ab67..030b56d27f62b1ca27c6e00142173b6b7f2db7de 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 |
@@ -1,55 +1,41 @@ |
<!DOCTYPE html> |
-<html> |
- <head> |
- <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> |
- var repeated = false; |
- var mediaElement = new Audio(); |
- |
- function start() |
- { |
- mediaElement.src = findMediaFile('audio', 'content/silence'); |
- waitForEvent("loadedmetadata", mediaLoadedMetadata); |
+<title>This test ensures that media element fires the "playing" event every time it starts playing after eos. It also ensure that "pause" and "ended" events are fired when media playback ends.</title> |
foolip
2016/06/02 09:37:04
I'm not sure I understand why this needs to test t
Srirama
2016/06/02 13:29:37
It is from webkit times and there is an issue of n
foolip
2016/06/02 13:36:11
OK, so doing it twice is very intentional then.
|
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<script src="media-file.js"></script> |
+<audio></audio> |
+<script> |
+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; |
} |
- function mediaLoadedMetadata() |
- { |
- waitForEventOnce("playing", mediaPlaying); |
- waitForEvent("pause", mediaPause); |
- waitForEvent("ended", mediaEnded); |
- run("mediaElement.play()"); |
- } |
+ loop = false; |
+ audio.onplaying = t.step_func(mediaPlaying); |
+ audio.play(); |
+ }); |
- function mediaPlaying() |
- { |
- mediaElement.currentTime = mediaElement.duration - 0.2; |
- } |
- |
- function mediaPause() |
- { |
- testExpected("mediaElement.paused", true); |
- } |
- |
- function mediaEnded() |
- { |
- testExpected("mediaElement.ended", true); |
- |
- if (repeated) { |
- endTest(); |
- return; |
- } |
- |
- repeated = true; |
- waitForEventOnce("playing", mediaPlaying); |
- run("mediaElement.play()"); |
- } |
+ audio.play(); |
+ }); |
- </script> |
- </head> |
- <body onload="start()"> |
- <p>This tests ensure that media element emits the 'playing' event every time it starts playing after eos. It also ensure that 'pause' and 'ended' events are sent when media playback ends.</p> |
- </body> |
-</html> |
+ function mediaPlaying() { |
+ audio.onplaying = null; |
+ audio.currentTime = audio.duration - 0.2; |
foolip
2016/06/02 09:37:04
This all feels a bit convoluted to me, and AFAICT
Srirama
2016/06/02 13:29:37
Acknowledged.
|
+ } |
+}); |
+</script> |