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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <title>Test "ended" event fires again after changing source after "ended" event. </title>
3 <head> 3 <script src="../resources/testharness.js"></script>
4 <script src=media-file.js></script> 4 <script src="../resources/testharnessreport.js"></script>
5 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 5 <script src="media-file.js"></script>
6 (Please avoid writing new tests using video-test.js) --> 6 <audio autoplay></audio>
7 <script src=video-test.js></script> 7 <script>
8 async_test(function(t) {
9 var endedCount = 0;
10 var audio = document.querySelector("audio");
8 11
9 <script> 12 audio.onended = t.step_func(function() {
10 var endedCount = 0; 13 switch (++endedCount)
11 var canplaythroughCount = 0; 14 {
12 var audio; 15 case 1:
16 assert_greater_than(audio.playbackRate, 0);
17 assert_true(audio.ended);
13 18
14 function start() 19 // Verify ended stays true even if playbackRate == 0
15 { 20 // since that is technically still "forward".
16 audio = document.querySelector("audio"); 21 audio.playbackRate = 0;
17 waitForEvent("ended", ended); 22 assert_true(audio.ended);
18 23
19 audio.src = findMediaFile("audio", "content/silence") 24 // Verify "backward" playback causes ended to become false.
20 } 25 audio.playbackRate = -0.1;
26 assert_false(audio.ended);
21 27
22 function ended() 28 // Change src but don't seek so that internal state isn't reset.
23 { 29 audio.src = findMediaFile("audio", "content/silence");
24 switch (++endedCount) 30 assert_false(audio.ended);
25 {
26 case 1:
27 testExpected("audio.playbackRate", 0, ">");
28 testExpected("audio.ended", true);
29 31
30 // Verify ended stays true even if playbackRate == 0 32 break;
31 // since that is technically still "forward". 33 case 2:
32 run("audio.playbackRate = 0"); 34 assert_true(audio.ended);
33 testExpected("audio.ended", true); 35 t.done();
36 break;
37 }
38 });
34 39
35 // Verify "backward" playback causes ended to become fal se. 40 audio.src = findMediaFile("audio", "content/silence")
36 run("audio.playbackRate = -0.1"); 41 });
37 testExpected("audio.ended", false); 42 </script>
38
39
40 // Change src but don't seek so that internal state isn' t reset.
41 audio.src = findMediaFile("audio", "content/silence")
42 testExpected("audio.ended", false);
43
44 consoleWrite("");
45 break;
46 case 2:
47 testExpected("audio.ended", true);
48 endTest();
49 break;
50 }
51 }
52 </script>
53 </head>
54 <body onload="start()">
55 <audio controls autoplay></audio>
56 <p><b>Test ended by:</b>
57 <ol>
58 <li>Play to the end.</li>
59 <li>When 'ended' event fires, change the source.</li>
60 <li>Verify that 'ended' event fires again on different source.</li>
61 </ol>
62 </p>
63 </body>
64 </html>
OLDNEW
« 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