OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Tests cues with class markup <c>.</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/tc025-class.vtt", function(track) { |
| 8 assert_equals(track.cues.length, 3); |
5 | 9 |
6 <script src=../media-file.js></script> | 10 var children = [ |
7 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 11 { type: "span", style: { className: "black" }, |
8 (Please avoid writing new tests using video-test.js) --> | 12 value: [ { type: "text", value: "Bear is Coming!!!!!" } ] } |
9 <script src=../video-test.js></script> | 13 ]; |
10 <script> | 14 assert_cue_fragment(track.cues[0], children); |
11 | 15 |
12 var numberOfTrackTests = 2; | 16 children = [ |
| 17 { type: "span", style: { className: "green" }, |
| 18 value: [ { type: "text", value: "I said Bear is coming!!!!" } ] } |
| 19 ]; |
| 20 assert_cue_fragment(track.cues[1], children); |
13 | 21 |
14 function trackLoaded() | 22 children = [ |
15 { | 23 { type: "text", value: "I said " }, |
16 numberOfTracksLoaded++; | 24 { type: "span", style: { className: "red uppercase" }, |
17 if (numberOfTracksLoaded == numberOfTrackTests) { | 25 value: [ { type: "text", value: "Bear is coming now" } ] }, |
18 testTrack(0); | 26 { type: "text", value: "!!!!" } |
19 testTrackError(1); | 27 ]; |
20 } | 28 assert_cue_fragment(track.cues[2], children); |
21 } | 29 }); |
22 | 30 |
23 function testTrack(i) | 31 check_cues_from_track("captions-webvtt/tc025-class-bad.vtt", function(track) { |
24 { | 32 assert_equals(track.cues.length, 3); |
25 findMediaElement(); | |
26 testExpected("video.textTracks[" + i + "].cues.length", "3"); | |
27 | 33 |
28 var fragment = document.createDocumentFragment(); | 34 var children = [ |
29 var cspan = document.createElement("span"); | 35 { type: "span", value: [ { type: "text", value: "Bear is Coming!!!!!" }
] }, |
30 cspan.className = "black"; | 36 { type: "text", value: "\nThe space signified an annotation start." } |
31 cspan.appendChild(document.createTextNode("Bear is Coming!!!!!")
); | 37 ]; |
32 fragment.appendChild(cspan); | 38 assert_cue_fragment(track.cues[0], children); |
33 | 39 |
34 testExpected(fragment.isEqualNode(video.textTracks[i].cues[0].ge
tCueAsHTML()), true); | 40 children = [ |
| 41 { type: "span", style: { className: "red&large" }, |
| 42 value: [ { type: "text", value: "I said Bear is coming!!!!" } ] }, |
| 43 { type: "text", value: "\nProbably should only allow characters that CSS
allows in class names." } |
| 44 ]; |
| 45 assert_cue_fragment(track.cues[1], children); |
35 | 46 |
36 fragment = document.createDocumentFragment(); | 47 children = [ |
37 cspan = document.createElement("span"); | 48 { type: "text", value: "I said " }, |
38 cspan.className = "green"; | 49 { type: "span", style: { className: "9red upper+case" }, |
39 cspan.appendChild(document.createTextNode("I said Bear is coming
!!!!")); | 50 value: [ { type: "text", value: "Bear is coming now" } ] }, |
40 fragment.appendChild(cspan); | 51 { type: "text", value: "!!!!\nProbably should only allow characters that
CSS allows in class names." } |
41 | 52 ]; |
42 testExpected(fragment.isEqualNode(video.textTracks[i].cues[1].ge
tCueAsHTML()), true); | 53 assert_cue_fragment(track.cues[2], children); |
43 | 54 }); |
44 fragment = document.createDocumentFragment(); | 55 </script> |
45 fragment.appendChild(document.createTextNode("I said ")); | |
46 cspan = document.createElement("span"); | |
47 cspan.className = "red uppercase"; | |
48 cspan.appendChild(document.createTextNode("Bear is coming now"))
; | |
49 fragment.appendChild(cspan); | |
50 fragment.appendChild(document.createTextNode("!!!!")); | |
51 | |
52 testExpected(fragment.isEqualNode(video.textTracks[i].cues[2].ge
tCueAsHTML()), true); | |
53 | |
54 allTestsEnded(); | |
55 } | |
56 | |
57 function testTrackError(i) | |
58 { | |
59 findMediaElement(); | |
60 testExpected("video.textTracks[" + i + "].cues.length", "3"); | |
61 | |
62 var fragment = document.createDocumentFragment(); | |
63 var cspan = document.createElement("span"); | |
64 cspan.appendChild(document.createTextNode("Bear is Coming!!!!!")
); | |
65 fragment.appendChild(cspan); | |
66 fragment.appendChild(document.createTextNode("\nThe space signif
ied an annotation start.")); | |
67 | |
68 testExpected(fragment.isEqualNode(video.textTracks[i].cues[0].ge
tCueAsHTML()), true); | |
69 | |
70 fragment = document.createDocumentFragment(); | |
71 cspan = document.createElement("span"); | |
72 cspan.className = "red&large"; | |
73 cspan.appendChild(document.createTextNode("I said Bear is coming
!!!!")); | |
74 fragment.appendChild(cspan); | |
75 fragment.appendChild(document.createTextNode("\nProbably should
only allow characters that CSS allows in class names.")); | |
76 | |
77 testExpected(fragment.isEqualNode(video.textTracks[i].cues[1].ge
tCueAsHTML()), true); | |
78 | |
79 fragment = document.createDocumentFragment(); | |
80 fragment.appendChild(document.createTextNode("I said ")); | |
81 cspan = document.createElement("span"); | |
82 cspan.className = "9red upper+case"; | |
83 cspan.appendChild(document.createTextNode("Bear is coming now"))
; | |
84 fragment.appendChild(cspan); | |
85 fragment.appendChild(document.createTextNode("!!!!\nProbably sho
uld only allow characters that CSS allows in class names.")); | |
86 | |
87 testExpected(fragment.isEqualNode(video.textTracks[i].cues[2].ge
tCueAsHTML()), true); | |
88 | |
89 allTestsEnded(); | |
90 } | |
91 </script> | |
92 </head> | |
93 <body onload="enableAllTextTracks()"> | |
94 <p>Tests cues with class markup <c>.</p> | |
95 <video> | |
96 <track src="captions-webvtt/tc025-class.vtt" onload="trackLoaded()"> | |
97 <track src="captions-webvtt/tc025-class-bad.vtt" onload="trackLoaded
()"> | |
98 </video> | |
99 </body> | |
100 </html> | |
OLD | NEW |