OLD | NEW |
1 <html> | 1 <!DOCTYPE html> |
2 <head> | 2 <title>Test that media file is not reloaded when an element is inserted into the
DOM.</title> |
3 <script src=media-file.js></script> | 3 <script src="../resources/testharness.js"></script> |
4 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 4 <script src="../resources/testharnessreport.js"></script> |
5 (Please avoid writing new tests using video-test.js) --> | 5 <script src="media-file.js"></script> |
6 <script src=video-test.js></script> | 6 <div id="parent"></div> |
| 7 <script> |
| 8 async_test(function(t) { |
| 9 var audio = document.createElement("audio"); |
7 | 10 |
8 <script> | 11 audio.oncanplaythrough = t.step_func(function() { |
| 12 audio.onloadstart = t.unreached_func("Should not fire 'loadstart' event"
); |
| 13 document.getElementById("parent").appendChild(audio); |
| 14 audio.play(); |
| 15 }); |
9 | 16 |
10 function playing() | 17 audio.onplaying = t.step_func_done(); |
11 { | 18 audio.onloadstart = t.step_func(function() {}); |
12 consoleWrite("EVENT(playing)<br>"); | 19 audio.ondurationchange = t.step_func(function() {}); |
13 endTest(); | 20 audio.onplay = t.step_func(function() {}); |
14 } | 21 audio.onloadeddata = t.step_func(function() {}); |
15 | 22 |
16 function canplaythrough() | 23 audio.src = findMediaFile("audio", "content/test"); |
17 { | 24 audio.load(); |
18 consoleWrite("EVENT(canplaythrough)"); | 25 }) |
19 consoleWrite(""); | 26 </script> |
20 run("document.getElementById('parent').appendChild(mediaElement)
"); | |
21 run("mediaElement.play()"); | |
22 consoleWrite(""); | |
23 } | |
24 | |
25 function start() | |
26 { | |
27 run("mediaElement = document.createElement('audio')"); | |
28 | |
29 mediaElement.setAttribute('oncanplaythrough', "canplaythrough()"
); | |
30 mediaElement.setAttribute('onplaying', "playing()"); | |
31 | |
32 waitForEvent("loadstart"); | |
33 waitForEvent("waiting"); | |
34 waitForEvent("ratechange"); | |
35 waitForEvent("durationchange"); | |
36 waitForEvent("pause"); | |
37 waitForEvent("play"); | |
38 waitForEvent("canplaythrough"); | |
39 waitForEvent('loadeddata'); | |
40 | |
41 var mediaFile = findMediaFile("audio", "content/test"); | |
42 run("mediaElement.src = '" + mediaFile + "'"); | |
43 run("mediaElement.load()"); | |
44 | |
45 consoleWrite(""); | |
46 } | |
47 | |
48 </script> | |
49 </head> | |
50 | |
51 <body onload="start()"> | |
52 | |
53 <p>Test that media file is not reloaded when an element is inserted into the
DOM.</p> | |
54 | |
55 <div id="parent"></div> | |
56 | |
57 </body> | |
58 </html> | |
OLD | NEW |