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

Unified Diff: third_party/WebKit/LayoutTests/media/media-ended.html

Issue 2043473002: Convert media-ended*, media-extension* and media-load* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | third_party/WebKit/LayoutTests/media/media-ended-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/media/media-ended-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698