OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src=media-file.js></script> | 4 <script src=media-file.js></script> |
| 5 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 |
| 6 (Please avoid writing new tests using video-test.js) --> |
5 <script src=video-test.js></script> | 7 <script src=video-test.js></script> |
6 <script> | 8 <script> |
7 var audio, sourceA, sourceB; | 9 var audio, sourceA, sourceB; |
8 | 10 |
9 function canplaythrough(e) | 11 function canplaythrough(e) |
10 { | 12 { |
11 testExpected("audio.currentSrc == sourceA.src", true); | 13 testExpected("audio.currentSrc == sourceA.src", true); |
12 endTest(); | 14 endTest(); |
13 } | 15 } |
14 | 16 |
15 function loadedMetadataA() | 17 function loadedMetadataA() |
16 { | 18 { |
17 consoleWrite("loadedMetadataA"); | 19 consoleWrite("loadedMetadataA"); |
18 audio.removeChild(sourceA); | 20 audio.removeChild(sourceA); |
19 audio.appendChild(sourceB); | 21 audio.appendChild(sourceB); |
20 waitForEventAndFail("loadedmetadata"); | 22 waitForEventAndFail("loadedmetadata"); |
21 } | 23 } |
22 | 24 |
23 function onWindowLoad(e) | 25 function onWindowLoad(e) |
24 { | 26 { |
25 audio = document.getElementById('a'); | 27 audio = document.getElementById('a'); |
26 waitForEvent("loadstart"); | 28 waitForEvent("loadstart"); |
27 waitForEvent("progress"); | 29 waitForEvent("progress"); |
28 waitForEvent("emptied"); | 30 waitForEvent("emptied"); |
29 waitForEvent("suspend"); | 31 waitForEvent("suspend"); |
30 waitForEvent("loadeddata"); | 32 waitForEvent("loadeddata"); |
31 waitForEvent("canplay"); | 33 waitForEvent("canplay"); |
32 waitForEventOnce('canplaythrough', canplaythrough); | 34 waitForEventOnce('canplaythrough', canplaythrough); |
33 | 35 |
34 sourceA = document.createElement("source"); | 36 sourceA = document.createElement("source"); |
35 var audioFile = findMediaFile("audio", "content/test"); | 37 var audioFile = findMediaFile("audio", "content/test"); |
36 sourceA.setAttribute("src", audioFile); | 38 sourceA.setAttribute("src", audioFile); |
37 sourceB = document.createElement("source"); | 39 sourceB = document.createElement("source"); |
38 audioFile = findMediaFile("audio", "content/silence"); | 40 audioFile = findMediaFile("audio", "content/silence"); |
39 sourceB.setAttribute("src", audioFile); | 41 sourceB.setAttribute("src", audioFile); |
40 | 42 |
41 waitForEventOnce("loadedmetadata", loadedMetadataA); | 43 waitForEventOnce("loadedmetadata", loadedMetadataA); |
42 audio.appendChild(sourceA); | 44 audio.appendChild(sourceA); |
43 } | 45 } |
44 | 46 |
45 window.addEventListener('load', onWindowLoad, false); | 47 window.addEventListener('load', onWindowLoad, false); |
46 </script> | 48 </script> |
47 </head> | 49 </head> |
48 <body> | 50 <body> |
49 <audio id="a"></audio> | 51 <audio id="a"></audio> |
50 </body> | 52 </body> |
51 </html> | 53 </html> |
OLD | NEW |