OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Tests TextTrack's activeCues are indexed and updated during video playbac k.</title> |
3 <head> | 3 <script src="../../resources/testharness.js"></script> |
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | 4 <script src="../../resources/testharnessreport.js"></script> |
5 <script src="../media-file.js"></script> | |
6 <video> | |
7 <track src="captions-webvtt/cues-overlapping.vtt" kind="subtitles" default> | |
8 </video> | |
9 <script> | |
10 async_test(function(t) { | |
11 var video = document.querySelector("video"); | |
12 video.src = findMediaFile("video", "../content/test"); | |
13 video.oncanplaythrough = t.step_func(attemptTests); | |
5 | 14 |
6 <script src=../media-file.js></script> | 15 var seekedCount = 0; |
7 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 16 video.onseeked = t.step_func(function() { |
8 (Please avoid writing new tests using video-test.js) --> | 17 ++seekedCount; |
9 <script src=../video-test.js></script> | |
10 | 18 |
11 <script> | 19 assert_equals(video.currentTime, seekedCount * 0.5); |
20 assert_equals(track.track.activeCues.length, seekedCount - 1); | |
21 video.currentTime = (seekedCount + 1) * 0.5; | |
12 | 22 |
13 var seekedCount = 0; | 23 if (seekedCount == 4) |
14 var testTrack; | 24 t.done(); |
25 }); | |
15 | 26 |
16 var trackLoaded = false; | 27 var track = document.querySelector("track"); |
17 var videoCanPlayThrough = false; | 28 track.onload = t.step_func(attemptTests); |
18 | 29 |
19 function attemptTests() | 30 var eventCount = 0; |
fs
2016/06/13 15:20:18
Maybe it would be possible to sequence this as:
t
Srirama
2016/06/13 17:33:38
Done. I think the intention of waiting for 'canpla
| |
20 { | 31 function attemptTests() { |
21 if (!trackLoaded || !videoCanPlayThrough) | 32 eventCount++; |
22 return; | 33 if (eventCount != 2) |
34 return; | |
23 | 35 |
24 testTrack = document.getElementById("testTrack"); | 36 assert_equals(track.track.cues.length, 3); |
25 testExpected("testTrack.track.cues.length", 3); | 37 video.currentTime = 0.5; |
26 run("video.currentTime = 0.5"); | 38 } |
27 consoleWrite(""); | 39 }); |
28 } | 40 </script> |
29 | |
30 function seeked() | |
31 { | |
32 ++seekedCount; | |
33 consoleWrite(""); | |
34 | |
35 activeCues = testTrack.track.activeCues; | |
36 | |
37 testExpected("video.currentTime", seekedCount * 0.5); | |
38 testExpected("activeCues.length", seekedCount - 1); | |
39 run("video.currentTime = " + (seekedCount + 1) * 0.5); | |
40 | |
41 consoleWrite(""); | |
42 | |
43 if (seekedCount == 4) | |
44 endTest(); | |
45 } | |
46 | |
47 waitForEvent('seeked', seeked); | |
48 | |
49 waitForEventOnce('canplaythrough', | |
50 function () | |
51 { | |
52 videoCanPlayThrough = true; | |
53 attemptTests(); | |
54 } | |
55 ); | |
56 | |
57 function loaded() | |
58 { | |
59 trackLoaded = true; | |
60 attemptTests(); | |
61 } | |
62 | |
63 function start() | |
64 { | |
65 findMediaElement(); | |
66 video.src = findMediaFile("video", "../content/test"); | |
67 } | |
68 </script> | |
69 </head> | |
70 <body onload="start()"> | |
71 <p>Tests TextTrack's activeCues are indexed and updated during video pla yback.</p> | |
72 <video controls> | |
73 <track id="testTrack" src="captions-webvtt/cues-overlapping.vtt" kin d="subtitles" onload="loaded()" default> | |
74 </video> | |
75 </body> | |
76 </html> | |
OLD | NEW |