OLD | NEW |
---|---|
1 <html> | 1 <!DOCTYPE HTML> |
2 <head> | 2 <title>Test that a 'play' event is fired by a new audio element on playing.</tit le> |
3 <title>'play' event</title> | 3 <script src="media-file.js"></script> |
4 <script src=media-file.js></script> | 4 <script src="../resources/testharness.js"></script> |
5 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 5 <script src="../resources/testharnessreport.js"></script> |
6 (Please avoid writing new tests using video-test.js) --> | 6 <script> |
7 <script src=video-test.js></script> | 7 async_test(function(t) { |
8 | 8 var eventCount = 0; |
9 <script> | 9 var audio = new Audio(); |
10 function start() | 10 audio.onplay = t.step_func(function() { |
11 { | 11 eventCount++; |
Srirama
2016/05/26 17:39:32
Should i reset each event to null so that it won't
fs
2016/05/26 18:29:21
If there were risk of seeing the same event twice
Srirama
2016/05/26 18:54:29
Done.
| |
12 mediaElement = new Audio(); | 12 }); |
13 waitForEvent('error'); | 13 audio.onloadedmetadata = t.step_func(function() { |
14 waitForEvent('loadedmetadata'); | 14 eventCount++; |
15 waitForEvent('canplay'); | 15 }); |
16 waitForEvent('play'); | 16 audio.oncanplay = t.step_func(function() { |
17 waitForEvent('playing', function() { endTest(); }); | 17 eventCount++; |
18 run("mediaElement.src = findMediaFile('audio', 'content/test')") ; | 18 }); |
19 run("mediaElement.volume = 1"); | 19 audio.onplaying = t.step_func_done(function() { |
20 run("mediaElement.play()"); | 20 assert_equals(eventCount, 3); |
21 } | 21 }); |
22 </script> | 22 audio.onerror = t.unreached_func("Should not fire 'error' event"); |
23 </head> | 23 audio.src = findMediaFile("audio", "content/test"); |
24 | 24 audio.play(); |
25 <body onload="start()"> | 25 }); |
26 <p>Test that a 'play' event listener is triggered when fired by a new audio element.</p> | 26 </script> |
27 </body> | |
28 </html> | |
OLD | NEW |