| 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", value: [ { type: "text", value: "Bear is Coming!!!!!" }
] } |
| 8 (Please avoid writing new tests using video-test.js) --> | 12 ]; |
| 9 <script src=../video-test.js></script> | 13 assert_cue_fragment_with_style(track.cues[0], children, { className: "black"
}); |
| 10 <script> | |
| 11 | 14 |
| 12 var numberOfTrackTests = 2; | 15 children = [ |
| 16 { type: "span", value: [ { type: "text", value: "I said Bear is coming!!
!!" } ] } |
| 17 ]; |
| 18 assert_cue_fragment_with_style(track.cues[1], children, { className: "green"
}); |
| 13 | 19 |
| 14 function trackLoaded() | 20 children = [ |
| 15 { | 21 { type: "text", value: "I said " }, |
| 16 numberOfTracksLoaded++; | 22 { type: "span", value: [ { type: "text", value: "Bear is coming now" } ]
}, |
| 17 if (numberOfTracksLoaded == numberOfTrackTests) { | 23 { type: "text", value: "!!!!" } |
| 18 testTrack(0); | 24 ]; |
| 19 testTrackError(1); | 25 assert_cue_fragment_with_style(track.cues[2], children, { className: "red up
percase" }); |
| 20 } | 26 }); |
| 21 } | |
| 22 | 27 |
| 23 function testTrack(i) | 28 check_cues_from_track("captions-webvtt/tc025-class-bad.vtt", function(track) { |
| 24 { | 29 assert_equals(track.cues.length, 3); |
| 25 findMediaElement(); | |
| 26 testExpected("video.textTracks[" + i + "].cues.length", "3"); | |
| 27 | 30 |
| 28 var fragment = document.createDocumentFragment(); | 31 var children = [ |
| 29 var cspan = document.createElement("span"); | 32 { type: "span", value: [ { type: "text", value: "Bear is Coming!!!!!" }
] }, |
| 30 cspan.className = "black"; | 33 { type: "text", value: "\nThe space signified an annotation start." } |
| 31 cspan.appendChild(document.createTextNode("Bear is Coming!!!!!")
); | 34 ]; |
| 32 fragment.appendChild(cspan); | 35 assert_cue_fragment(track.cues[0], children); |
| 33 | 36 |
| 34 testExpected(fragment.isEqualNode(video.textTracks[i].cues[0].ge
tCueAsHTML()), true); | 37 children = [ |
| 38 { type: "span", value: [ { type: "text", value: "I said Bear is coming!!
!!" } ] }, |
| 39 { type: "text", value: "\nProbably should only allow characters that CSS
allows in class names." } |
| 40 ]; |
| 41 assert_cue_fragment_with_style(track.cues[1], children, { className: "red&la
rge" }); |
| 35 | 42 |
| 36 fragment = document.createDocumentFragment(); | 43 children = [ |
| 37 cspan = document.createElement("span"); | 44 { type: "text", value: "I said " }, |
| 38 cspan.className = "green"; | 45 { type: "span", value: [ { type: "text", value: "Bear is coming now" } ]
}, |
| 39 cspan.appendChild(document.createTextNode("I said Bear is coming
!!!!")); | 46 { type: "text", value: "!!!!\nProbably should only allow characters that
CSS allows in class names." } |
| 40 fragment.appendChild(cspan); | 47 ]; |
| 41 | 48 assert_cue_fragment_with_style(track.cues[2], children, { className: "9red u
pper+case" }); |
| 42 testExpected(fragment.isEqualNode(video.textTracks[i].cues[1].ge
tCueAsHTML()), true); | 49 }); |
| 43 | 50 </script> |
| 44 fragment = document.createDocumentFragment(); | |
| 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 |