OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Tests cues with <b>, <i>, <u>, <rt> and <ruby&
gt; 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=../media-file.js></script> | 5 <script src="../../resources/testharnessreport.js"></script> |
6 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 6 <script> |
7 (Please avoid writing new tests using video-test.js) --> | 7 check_cues_from_track("captions-webvtt/tc023-markup.vtt", function(track) { |
8 <script src=../video-test.js></script> | 8 assert_equals(track.cues.length, 4); |
9 <script> | |
10 | 9 |
11 var numberOfTrackTests = 2; | 10 var children = [ |
| 11 { type: "text", value: "The following bear is bold:\n" }, |
| 12 { type: "b", value: [ { type: "text", value: "Bear" } ] }, |
| 13 { type: "text", value: " is Coming!!!!!" } |
| 14 ]; |
| 15 assert_cue_fragment(track.cues[0], children); |
12 | 16 |
13 function trackLoaded() | 17 children = [ |
14 { | 18 { type: "text", value: "The following bear is in italics and has a class
of \"larger\":\n" }, |
15 numberOfTracksLoaded++; | 19 { type: "i", value: [ { type: "text", value: "Bear" } ] }, |
16 if (numberOfTracksLoaded == numberOfTrackTests) { | 20 { type: "text", value: " is Coming!!!!!" } |
17 testTrack(0); | 21 ]; |
18 testTrackError(1); | 22 |
| 23 var fragment = createFragment(children); |
| 24 fragment.querySelector("i").className = "larger"; |
| 25 assert_true(fragment.isEqualNode(track.cues[1].getCueAsHTML())); |
| 26 |
| 27 children = [ |
| 28 { type: "text", value: "The following bear is underlined even though the
element has a blank:\nI said " }, |
| 29 { type: "u", value: [ { type: "text", value: "Bear" } ] }, |
| 30 { type: "text", value: " is coming!!!!" } |
| 31 ]; |
| 32 assert_cue_fragment(track.cues[2], children); |
| 33 |
| 34 children = [ |
| 35 { type: "text", value: "The following bear is ruby annotated:\nI said "
}, |
| 36 { |
| 37 type: "ruby", |
| 38 value: [ |
| 39 { type: "text", value: "Bear" }, |
| 40 { |
| 41 type: "rt", |
| 42 value: [ { type: "text", value: "bear with me" } ] |
19 } | 43 } |
20 } | 44 ] |
| 45 }, |
| 46 { type: "text", value: " is coming!!!!" } |
| 47 ]; |
| 48 assert_cue_fragment(track.cues[3], children); |
| 49 }); |
21 | 50 |
22 function testTrack(i) | 51 check_cues_from_track("captions-webvtt/tc023-markup-bad.vtt", function(track) { |
23 { | 52 assert_equals(track.cues.length, 4); |
24 findMediaElement(); | |
25 testExpected("video.textTracks[" + i + "].cues.length", "4"); | |
26 | 53 |
27 var fragment = document.createDocumentFragment(); | 54 var children = [ |
28 fragment.appendChild(document.createTextNode("The following bear
is bold:\n")); | 55 { type: "text", value: "The following bear starts bold but end is broken
:\n" }, |
29 var bold = document.createElement("b"); | 56 { |
30 bold.appendChild(document.createTextNode("Bear")); | 57 type: "b", |
31 fragment.appendChild(bold); | 58 value: |
32 fragment.appendChild(document.createTextNode(" is Coming!!!!!"))
; | 59 [ |
| 60 { type: "text", value: "Bear" }, |
| 61 { type: "text", value: " is Coming!!!!!" } |
| 62 ] |
| 63 } |
| 64 ]; |
| 65 assert_cue_fragment(track.cues[0], children); |
33 | 66 |
34 testExpected(fragment.isEqualNode(video.textTracks[i].cues[0].ge
tCueAsHTML()), true); | 67 children = [ |
35 | 68 { type: "text", value: "The following bear is not in italics but the mar
kup is removed:\n" }, |
36 fragment = document.createDocumentFragment(); | 69 { type: "text", value: "Bear" }, |
37 fragment.appendChild(document.createTextNode("The following bear
is in italics and has a class of \"larger\":\n")); | 70 { type: "text", value: " is Coming!!!!!" } |
38 var italics = document.createElement("i"); | 71 ]; |
39 italics.className = "larger"; | 72 assert_cue_fragment(track.cues[1], children); |
40 italics.appendChild(document.createTextNode("Bear")); | |
41 fragment.appendChild(italics); | |
42 fragment.appendChild(document.createTextNode(" is Coming!!!!!"))
; | |
43 | |
44 testExpected(fragment.isEqualNode(video.textTracks[i].cues[1].ge
tCueAsHTML()), true); | |
45 | |
46 fragment = document.createDocumentFragment(); | |
47 fragment.appendChild(document.createTextNode("The following bear
is underlined even though the element has a blank:\nI said ")); | |
48 var underline = document.createElement("u"); | |
49 underline.appendChild(document.createTextNode("Bear")); | |
50 fragment.appendChild(underline); | |
51 fragment.appendChild(document.createTextNode(" is coming!!!!")); | |
52 | |
53 testExpected(fragment.isEqualNode(video.textTracks[i].cues[2].ge
tCueAsHTML()), true); | |
54 | |
55 fragment = document.createDocumentFragment(); | |
56 fragment.appendChild(document.createTextNode("The following bear
is ruby annotated:\nI said ")); | |
57 var ruby = document.createElement("ruby"); | |
58 ruby.appendChild(document.createTextNode("Bear")); | |
59 var rt = document.createElement("rt"); | |
60 rt.appendChild(document.createTextNode("bear with me")); | |
61 ruby.appendChild(rt); | |
62 fragment.appendChild(ruby); | |
63 fragment.appendChild(document.createTextNode(" is coming!!!!")); | |
64 | |
65 testExpected(fragment.isEqualNode(video.textTracks[i].cues[3].ge
tCueAsHTML()), true); | |
66 | |
67 allTestsEnded(); | |
68 } | |
69 | |
70 function testTrackError(i) | |
71 { | |
72 findMediaElement(); | |
73 testExpected("video.textTracks[" + i + "].cues.length", "4"); | |
74 | |
75 var fragment = document.createDocumentFragment(); | |
76 fragment.appendChild(document.createTextNode("The following bear
starts bold but end is broken:\n")); | |
77 var bold = document.createElement("b"); | |
78 bold.appendChild(document.createTextNode("Bear")); | |
79 bold.appendChild(document.createTextNode(" is Coming!!!!!")); | |
80 fragment.appendChild(bold); | |
81 | |
82 testExpected(fragment.isEqualNode(video.textTracks[i].cues[0].ge
tCueAsHTML()), true); | |
83 | |
84 fragment = document.createDocumentFragment(); | |
85 fragment.appendChild(document.createTextNode("The following bear
is not in italics but the markup is removed:\n")); | |
86 fragment.appendChild(document.createTextNode("Bear")); | |
87 fragment.appendChild(document.createTextNode(" is Coming!!!!!"))
; | |
88 | |
89 testExpected(fragment.isEqualNode(video.textTracks[i].cues[1].ge
tCueAsHTML()), true); | |
90 | 73 |
91 | 74 |
92 fragment = document.createDocumentFragment(); | 75 children = [ |
93 fragment.appendChild(document.createTextNode("The following bear
is not underlined and markup is removed:\nI said ")); | 76 { type: "text", value: "The following bear is not underlined and markup
is removed:\nI said " }, |
94 fragment.appendChild(document.createTextNode("Bear")); | 77 { type: "text", value : "Bear" }, |
95 fragment.appendChild(document.createTextNode(" is coming!!!!")); | 78 { type: "text", value : " is coming!!!!" } |
| 79 ]; |
| 80 assert_cue_fragment(track.cues[2], children); |
96 | 81 |
97 testExpected(fragment.isEqualNode(video.textTracks[i].cues[2].ge
tCueAsHTML()), true); | 82 children = [ |
98 | 83 { type: "text", value: "The following bear is not ruby annotated and mar
kup is removed:\nI said " }, |
99 fragment = document.createDocumentFragment(); | 84 { type: "text", value: "Bear" }, |
100 fragment.appendChild(document.createTextNode("The following bear
is not ruby annotated and markup is removed:\nI said ")); | 85 { type: "text", value: "bear with me" }, |
101 fragment.appendChild(document.createTextNode("Bear")); | 86 { type: "text", value: " is coming!!!!" } |
102 fragment.appendChild(document.createTextNode("bear with me")); | 87 ]; |
103 fragment.appendChild(document.createTextNode(" is coming!!!!")); | 88 assert_cue_fragment(track.cues[3], children); |
104 | 89 }); |
105 testExpected(fragment.isEqualNode(video.textTracks[i].cues[3].ge
tCueAsHTML()), true); | 90 </script> |
106 | |
107 allTestsEnded(); | |
108 } | |
109 </script> | |
110 </head> | |
111 <body onload="enableAllTextTracks()"> | |
112 <p>Tests cues with <b>, <i>, <u>, <rt> and <r
uby> tags.</p> | |
113 <video> | |
114 <track src="captions-webvtt/tc023-markup.vtt" onload="trackLoaded()"
> | |
115 <track src="captions-webvtt/tc023-markup-bad.vtt" onload="trackLoade
d()"> | |
116 </video> | |
117 </body> | |
118 </html> | |
OLD | NEW |