OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Test adding cues to a disabled text track. </title> |
3 <head> | 3 <script src="../media-file.js"></script> |
4 <script src="../media-file.js"></script> | 4 <script src="../../resources/testharness.js"></script> |
5 <!-- TODO(philipj): 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 <script> | 8 var cueDuration = 0.1; |
9 function onLoad() | 9 var video = document.createElement("video"); |
10 { | 10 var track = video.addTextTrack("subtitles"); |
11 if (window.testRunner) | 11 track.mode = "disabled"; |
12 testRunner.dumpAsText(); | |
13 | 12 |
14 var cueDuration = 0.1; | 13 for (var i = 0; i < 10; ++i) { |
15 var video = document.querySelector("#vid"); | 14 var start = i * cueDuration; |
16 var track = video.addTextTrack("subtitles"); | 15 var end = start + cueDuration; |
17 track.mode = "disabled"; | 16 track.addCue(new VTTCue(start, end, "Test Cue " + i)); |
| 17 } |
18 | 18 |
19 for (var i = 0; i < 10; ++i) { | 19 // Waiting for 2 cue durations to elapse. |
20 var start = i * cueDuration; | 20 video.ontimeupdate = t.step_func(function(e) { |
21 var end = start + cueDuration; | 21 if (e.target.currentTime < (2 * cueDuration)) |
22 track.addCue(new VTTCue(start, end, "Test Cue " + i)); | 22 return; |
23 } | |
24 | 23 |
25 consoleWrite("Waiting for 2 cue durations to elapse."); | 24 // End test after at least 2 cueDurations to make sure the test |
| 25 // doesn't crash during the period the first 2 cues would have been |
| 26 // rendered if the track was not disabled. |
| 27 // 2 cue durations have elapsed. |
| 28 t.done(); |
| 29 }); |
26 | 30 |
27 video.addEventListener('timeupdate', function (e) | 31 video.src = findMediaFile("video", "../content/test"); |
28 { | 32 video.play(); |
29 if (e.target.currentTime < 2 * cueDuration) | 33 }); |
30 return; | 34 </script> |
31 | |
32 // End test after at least 2 cueDurations to make sure the
test | |
33 // doesn't crash during the period the first 2 cues would
have been | |
34 // rendered if the track was not disabled. | |
35 consoleWrite("2 cue durations have elapsed."); | |
36 endTest(); | |
37 }); | |
38 video.play(); | |
39 } | |
40 </script> | |
41 </head> | |
42 <body onload="onLoad()"> | |
43 <p>Test adding cues to a disabled text track. </p> | |
44 <video id="vid" src="../content/test.ogv" controls></video> | |
45 </body> | |
46 </html> | |
OLD | NEW |