OLD | NEW |
1 <html> | 1 <!DOCTYPE html> |
2 <head> | 2 <title>Test loading video twice.</title> |
3 <script src=../../media-resources/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-resources/media-file.js"></script> |
6 <script src=../../media-resources/video-test.js></script> | 6 <body> |
7 <script> | 7 <script> |
| 8 async_test(function(t) { |
8 var file = findMediaFile("video", "http://127.0.0.1:8000/resources/test"); | 9 var file = findMediaFile("video", "http://127.0.0.1:8000/resources/test"); |
9 | 10 createAndLoadVideo(false); |
10 function createVideo() { | 11 function createAndLoadVideo(endTest) { |
11 var video = document.createElement("video"); | 12 var video = document.createElement("video"); |
12 document.body.appendChild(video); | 13 document.body.appendChild(video); |
13 findMediaElement(); | 14 var expectedEvents = ["loadedmetadata", "loadeddata", "canplay", "canpla
ythrough"]; |
14 waitForEvent('loadedmetadata'); | 15 var watcher = new EventWatcher(t, video, expectedEvents); |
15 waitForEvent('loadeddata'); | 16 watcher.wait_for(expectedEvents).then(t.step_func(function() { |
16 waitForEvent('canplay'); | 17 if (endTest) { |
| 18 t.done(); |
| 19 } else { |
| 20 document.body.removeChild(video); |
| 21 createAndLoadVideo(true); |
| 22 } |
| 23 })); |
| 24 |
| 25 video.src = file; |
17 } | 26 } |
18 | 27 }); |
19 function firstCanPlayThrough() { | 28 </script> |
20 document.body.removeChild(video); | |
21 createVideo(); | |
22 waitForEventOnce('canplaythrough', endTest); | |
23 run("video.src = file"); | |
24 } | |
25 | |
26 function init() { | |
27 createVideo(); | |
28 waitForEventOnce('canplaythrough', firstCanPlayThrough); | |
29 run("video.src = file"); | |
30 } | |
31 </script> | |
32 </head> | |
33 <body onload="init()"> | |
34 </body> | |
35 </html> | |
OLD | NEW |