OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Tests cues with <timestamps> tags.</title> |
3 <head> | 3 <script src="track-helpers.js"></script> |
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | 4 <script src="../../resources/testharness.js"></script> |
| 5 <script src="../../resources/testharnessreport.js"></script> |
| 6 <script> |
| 7 check_cues_from_track("captions-webvtt/tc024-timestamp.vtt", function(track) { |
| 8 assert_equals(track.cues.length, 3); |
5 | 9 |
6 <script src=../media-file.js></script> | 10 // TODO(srirama.m): Timestamps are handled as ProcessingInstructions, |
7 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 11 // but because ProcessingInstructions are used in XML and not HTML, |
8 (Please avoid writing new tests using video-test.js) --> | 12 // they are ignored here. This should later be tested with oncuechange event
s. |
9 <script src=../video-test.js></script> | |
10 <script> | |
11 | 13 |
12 var numberOfTrackTests = 2; | 14 var children = [ { type: "text", value: "This cue is painted on." } ]; |
| 15 assert_cue_fragment_as_textcontent(track.cues[0], children); |
13 | 16 |
14 function trackLoaded() | 17 children = [ { type: "text", value: "I said Bear is coming!!!!" } ]; |
15 { | 18 assert_cue_fragment_as_textcontent(track.cues[1], children); |
16 numberOfTracksLoaded++; | |
17 if (numberOfTracksLoaded == numberOfTrackTests) { | |
18 testTrack(0); | |
19 testTrackError(1); | |
20 } | |
21 } | |
22 | 19 |
23 function testTrack(i) | 20 children = [ { type: "text", value: "I said Bear is coming now!!!!" } ]; |
24 { | 21 assert_cue_fragment_as_textcontent(track.cues[2], children); |
25 findMediaElement(); | 22 }); |
26 testExpected("video.textTracks[" + i + "].cues.length", "3"); | |
27 | 23 |
28 // Note: Timestamps are handled as ProcessingInstructions, but b
ecause ProcessingInstructions | 24 check_cues_from_track("captions-webvtt/tc024-timestamp-bad.vtt", function(track)
{ |
29 // are used in XML and not HTML, they are ignored here. | 25 assert_equals(track.cues.length, 3); |
30 // This should later be tested with oncuechange events. | |
31 var fragment = document.createDocumentFragment(); | |
32 fragment.appendChild(document.createTextNode("This cue is painte
d on.")); | |
33 | 26 |
34 testExpected("video.textTracks[" + i + "].cues[0].getCueAsHTML()
.textContent", fragment.textContent); | 27 var children = [ { type: "text", value: "This cue is painted on.\nBut since
the last two timestamps are out of order, they are ignored." } ]; |
| 28 assert_cue_fragment_as_textcontent(track.cues[0], children); |
35 | 29 |
36 fragment = document.createDocumentFragment(); | 30 children = [ { type: "text", value: "I said Bear is coming!!!!\nAll of these
timestamps are before the start of the cue, so get ignored." } ]; |
37 fragment.appendChild(document.createTextNode("I said Bear is com
ing!!!!")); | 31 assert_cue_fragment_as_textcontent(track.cues[1], children); |
38 | 32 |
39 testExpected("video.textTracks[" + i + "].cues[1].getCueAsHTML()
.textContent", fragment.textContent); | 33 children = [ { type: "text", value: "I said Bear is coming now!!!!\nAll of t
hese timestamps are after the end of the cue, so get ignored." } ]; |
40 | 34 assert_cue_fragment_as_textcontent(track.cues[2], children); |
41 fragment = document.createDocumentFragment(); | 35 }); |
42 fragment.appendChild(document.createTextNode("I said Bear is com
ing now!!!!")); | 36 </script> |
43 | |
44 testExpected("video.textTracks[" + i + "].cues[2].getCueAsHTML()
.textContent", fragment.textContent); | |
45 | |
46 allTestsEnded(); | |
47 } | |
48 | |
49 function testTrackError(i) | |
50 { | |
51 findMediaElement(); | |
52 testExpected("video.textTracks[" + i + "].cues.length", "3"); | |
53 | |
54 var fragment = document.createDocumentFragment(); | |
55 fragment.appendChild(document.createTextNode("This cue is painte
d on.\nBut since the last two timestamps are out of order, they are ignored.")); | |
56 | |
57 testExpected("video.textTracks[" + i + "].cues[0].getCueAsHTML()
.textContent", fragment.textContent); | |
58 | |
59 fragment = document.createDocumentFragment(); | |
60 fragment.appendChild(document.createTextNode("I said Bear is com
ing!!!!\nAll of these timestamps are before the start of the cue, so get ignored
.")); | |
61 | |
62 testExpected("video.textTracks[" + i + "].cues[1].getCueAsHTML()
.textContent", fragment.textContent); | |
63 | |
64 fragment = document.createDocumentFragment(); | |
65 fragment.appendChild(document.createTextNode("I said Bear is com
ing now!!!!\nAll of these timestamps are after the end of the cue, so get ignore
d.")); | |
66 | |
67 testExpected("video.textTracks[" + i + "].cues[2].getCueAsHTML()
.textContent", fragment.textContent); | |
68 | |
69 allTestsEnded(); | |
70 } | |
71 </script> | |
72 </head> | |
73 <body onload="enableAllTextTracks()"> | |
74 <p>Tests cues with <timestamps> tags.</p> | |
75 <video> | |
76 <track src="captions-webvtt/tc024-timestamp.vtt" onload="trackLoaded
()"> | |
77 <track src="captions-webvtt/tc024-timestamp-bad.vtt" onload="trackLo
aded()"> | |
78 </video> | |
79 </body> | |
80 </html> | |
OLD | NEW |