OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <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.
| |
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></audio> |
7 <script src=video-test.js></script> | 7 <script> |
8 <script> | 8 async_test(function(t) { |
9 var repeated = false; | 9 var loop = true; |
10 var mediaElement = new Audio(); | 10 var audio = document.querySelector("audio"); |
11 audio.src = findMediaFile("audio", "content/silence"); | |
11 | 12 |
12 function start() | 13 audio.onloadedmetadata = t.step_func(function() { |
13 { | 14 audio.onplaying = t.step_func(mediaPlaying); |
14 mediaElement.src = findMediaFile('audio', 'content/silence'); | 15 |
15 waitForEvent("loadedmetadata", mediaLoadedMetadata); | 16 audio.onpause = t.step_func(function() { |
17 assert_true(audio.paused); | |
18 }); | |
19 | |
20 audio.onended = t.step_func(function() { | |
21 assert_true(audio.ended, true); | |
22 | |
23 if (!loop) { | |
24 t.done(); | |
25 return; | |
16 } | 26 } |
17 | 27 |
18 function mediaLoadedMetadata() | 28 loop = false; |
19 { | 29 audio.onplaying = t.step_func(mediaPlaying); |
20 waitForEventOnce("playing", mediaPlaying); | 30 audio.play(); |
21 waitForEvent("pause", mediaPause); | 31 }); |
22 waitForEvent("ended", mediaEnded); | |
23 run("mediaElement.play()"); | |
24 } | |
25 | 32 |
26 function mediaPlaying() | 33 audio.play(); |
27 { | 34 }); |
28 mediaElement.currentTime = mediaElement.duration - 0.2; | |
29 } | |
30 | 35 |
31 function mediaPause() | 36 function mediaPlaying() { |
32 { | 37 audio.onplaying = null; |
33 testExpected("mediaElement.paused", true); | 38 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.
| |
34 } | 39 } |
35 | 40 }); |
36 function mediaEnded() | 41 </script> |
37 { | |
38 testExpected("mediaElement.ended", true); | |
39 | |
40 if (repeated) { | |
41 endTest(); | |
42 return; | |
43 } | |
44 | |
45 repeated = true; | |
46 waitForEventOnce("playing", mediaPlaying); | |
47 run("mediaElement.play()"); | |
48 } | |
49 | |
50 </script> | |
51 </head> | |
52 <body onload="start()"> | |
53 <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> | |
54 </body> | |
55 </html> | |
OLD | NEW |