Index: third_party/WebKit/LayoutTests/media/media-ended.html |
diff --git a/third_party/WebKit/LayoutTests/media/media-ended.html b/third_party/WebKit/LayoutTests/media/media-ended.html |
index 640906efcf7948435ada02f98dfe02b70569f533..181634795f6905879981f29f2d5c305e1825e048 100644 |
--- a/third_party/WebKit/LayoutTests/media/media-ended.html |
+++ b/third_party/WebKit/LayoutTests/media/media-ended.html |
@@ -1,64 +1,42 @@ |
<!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 endedCount = 0; |
- var canplaythroughCount = 0; |
- var audio; |
- |
- function start() |
- { |
- audio = document.querySelector("audio"); |
- waitForEvent("ended", ended); |
- |
- audio.src = findMediaFile("audio", "content/silence") |
- } |
- |
- function ended() |
- { |
- switch (++endedCount) |
- { |
- case 1: |
- testExpected("audio.playbackRate", 0, ">"); |
- testExpected("audio.ended", true); |
- |
- // Verify ended stays true even if playbackRate == 0 |
- // since that is technically still "forward". |
- run("audio.playbackRate = 0"); |
- testExpected("audio.ended", true); |
- |
- // Verify "backward" playback causes ended to become false. |
- run("audio.playbackRate = -0.1"); |
- testExpected("audio.ended", false); |
- |
- |
- // Change src but don't seek so that internal state isn't reset. |
- audio.src = findMediaFile("audio", "content/silence") |
- testExpected("audio.ended", false); |
- |
- consoleWrite(""); |
- break; |
- case 2: |
- testExpected("audio.ended", true); |
- endTest(); |
- break; |
- } |
- } |
- </script> |
- </head> |
- <body onload="start()"> |
- <audio controls autoplay></audio> |
- <p><b>Test ended by:</b> |
- <ol> |
- <li>Play to the end.</li> |
- <li>When 'ended' event fires, change the source.</li> |
- <li>Verify that 'ended' event fires again on different source.</li> |
- </ol> |
- </p> |
- </body> |
-</html> |
+<title>Test "ended" event fires again after changing source after "ended" event.</title> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<script src="media-file.js"></script> |
+<audio autoplay></audio> |
+<script> |
+async_test(function(t) { |
+ var endedCount = 0; |
+ var audio = document.querySelector("audio"); |
+ |
+ audio.onended = t.step_func(function() { |
+ switch (++endedCount) |
+ { |
+ case 1: |
+ assert_greater_than(audio.playbackRate, 0); |
+ assert_true(audio.ended); |
+ |
+ // Verify ended stays true even if playbackRate == 0 |
+ // since that is technically still "forward". |
+ audio.playbackRate = 0; |
+ assert_true(audio.ended); |
+ |
+ // Verify "backward" playback causes ended to become false. |
+ audio.playbackRate = -0.1; |
+ assert_false(audio.ended); |
+ |
+ // Change src but don't seek so that internal state isn't reset. |
+ audio.src = findMediaFile("audio", "content/silence"); |
+ assert_false(audio.ended); |
+ |
+ break; |
+ case 2: |
+ assert_true(audio.ended); |
+ t.done(); |
+ break; |
+ } |
+ }); |
+ |
+ audio.src = findMediaFile("audio", "content/silence") |
+}); |
+</script> |