Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <title>Test that a media element doesn't reload on removing the current source e lement and inserting a new source element.</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></audio> |
| 7 <script src=video-test.js></script> | 7 <script> |
| 8 <script> | 8 async_test(function(t) { |
| 9 var audio, sourceA, sourceB; | 9 var audio = document.querySelector("audio"); |
| 10 | 10 |
| 11 function canplaythrough(e) | 11 audio.oncanplaythrough = t.step_func_done(function() { |
| 12 { | 12 assert_equals(audio.currentSrc, sourceA.src); |
| 13 testExpected("audio.currentSrc == sourceA.src", true); | 13 }); |
| 14 endTest(); | |
| 15 } | |
| 16 | 14 |
| 17 function loadedMetadataA() | 15 audio.onloadedmetadata = t.step_func(function() { |
| 18 { | 16 audio.onloadedmetadata = null; |
|
fs
2016/06/11 18:59:50
This seems redundant with the definition below? (T
Srirama
2016/06/12 09:51:04
Done.
| |
| 19 consoleWrite("loadedMetadataA"); | 17 audio.removeChild(sourceA); |
| 20 audio.removeChild(sourceA); | 18 audio.appendChild(sourceB); |
| 21 audio.appendChild(sourceB); | 19 audio.onloadedmetadata = t.unreached_func(); |
| 22 waitForEventAndFail("loadedmetadata"); | 20 }); |
| 23 } | |
| 24 | 21 |
| 25 function onWindowLoad(e) | 22 var sourceA = document.createElement("source"); |
| 26 { | 23 sourceA.src = findMediaFile("audio", "content/test"); |
| 27 audio = document.getElementById('a'); | 24 var sourceB = document.createElement("source"); |
| 28 waitForEvent("loadstart"); | 25 sourceB.src = findMediaFile("audio", "content/silence"); |
| 29 waitForEvent("progress"); | 26 audio.appendChild(sourceA); |
| 30 waitForEvent("emptied"); | 27 }); |
| 31 waitForEvent("suspend"); | 28 </script> |
| 32 waitForEvent("loadeddata"); | |
| 33 waitForEvent("canplay"); | |
| 34 waitForEventOnce('canplaythrough', canplaythrough); | |
| 35 | |
| 36 sourceA = document.createElement("source"); | |
| 37 var audioFile = findMediaFile("audio", "content/test"); | |
| 38 sourceA.setAttribute("src", audioFile); | |
| 39 sourceB = document.createElement("source"); | |
| 40 audioFile = findMediaFile("audio", "content/silence"); | |
| 41 sourceB.setAttribute("src", audioFile); | |
| 42 | |
| 43 waitForEventOnce("loadedmetadata", loadedMetadataA); | |
| 44 audio.appendChild(sourceA); | |
| 45 } | |
| 46 | |
| 47 window.addEventListener('load', onWindowLoad, false); | |
| 48 </script> | |
| 49 </head> | |
| 50 <body> | |
| 51 <audio id="a"></audio> | |
| 52 </body> | |
| 53 </html> | |
| OLD | NEW |