| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <title>Tests cues with voice markup <v>.</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/tc026-voice.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 { |
| 8 (Please avoid writing new tests using video-test.js) --> | 12 type: "span", |
| 9 <script src=../video-test.js></script> | 13 value: [ |
| 10 <script> | 14 { type: "text", value: "Bear is Coming!!!!!" }, |
| 15 { type: "style", value: { className: "blue", title: "Speaker" }
} |
| 16 ] |
| 17 }, |
| 18 { type: "text", value: "\nText span with a class and an annotation." } |
| 19 ]; |
| 20 assert_cue_fragment(track.cues[0], children); |
| 11 | 21 |
| 12 var numberOfTrackTests = 2; | 22 children = [ |
| 23 { |
| 24 type: "span", |
| 25 value: |
| 26 [ |
| 27 { type: "text", value: "I said Bear is coming!!!!" }, |
| 28 { type: "style", value: { title: "Doe Hunter"} } |
| 29 ] |
| 30 } |
| 31 ]; |
| 32 assert_cue_fragment(track.cues[1], children); |
| 13 | 33 |
| 14 function trackLoaded() | 34 children = [ |
| 15 { | 35 { type: "text", value: "I said " }, |
| 16 numberOfTracksLoaded++; | 36 { |
| 17 if (numberOfTracksLoaded == numberOfTrackTests) { | 37 type: "span", |
| 18 testTrack(0); | 38 value: |
| 19 testTrackError(1); | 39 [ |
| 20 } | 40 { type: "text", value: "Bear is coming now" }, |
| 21 } | 41 { type: "style", value: { className: "blue", title: "Speaker"} } |
| 42 ] |
| 43 }, |
| 44 { type: "text", value: "!!!!" } |
| 45 ]; |
| 46 assert_cue_fragment(track.cues[2], children); |
| 47 }); |
| 22 | 48 |
| 23 function testTrack(i) | 49 check_cues_from_track("captions-webvtt/tc026-voice-bad.vtt", function(track) { |
| 24 { | 50 assert_equals(track.cues.length, 3); |
| 25 findMediaElement(); | |
| 26 testExpected("video.textTracks[" + i + "].cues.length", "3"); | |
| 27 | 51 |
| 28 var fragment = document.createDocumentFragment(); | 52 var children = [ |
| 29 var cspan = document.createElement("span"); | 53 { type: "text", value: "Bear is Coming!!!!!" }, |
| 30 cspan.className = "blue"; | 54 { type: "text", value: "\nThis is two annotations for an empty tag." } |
| 31 cspan.title = "Speaker"; | 55 ]; |
| 32 cspan.appendChild(document.createTextNode("Bear is Coming!!!!!")
); | 56 assert_cue_fragment(track.cues[0], children); |
| 33 fragment.appendChild(cspan); | |
| 34 fragment.appendChild(document.createTextNode("\nText span with a
class and an annotation.")); | |
| 35 | 57 |
| 36 testExpected(fragment.isEqualNode(video.textTracks[i].cues[0].ge
tCueAsHTML()), true); | 58 children = [ |
| 59 { type: "text", value: "I said Bear is coming!!!!" }, |
| 60 { type: "text", value: "\nThis does not parse as a voice tag." } |
| 61 ]; |
| 62 assert_cue_fragment(track.cues[1], children); |
| 37 | 63 |
| 38 fragment = document.createDocumentFragment(); | 64 children = [ |
| 39 cspan = document.createElement("span"); | 65 { type: "text", value: "I said " }, |
| 40 cspan.title = "Doe Hunter"; | 66 { type: "text", value: "Bear is coming now" }, |
| 41 cspan.appendChild(document.createTextNode("I said Bear is coming
!!!!")); | 67 { type: "text", value: "!!!!\nThis does not parse as a voice tag." } |
| 42 fragment.appendChild(cspan); | 68 ]; |
| 43 | 69 assert_cue_fragment(track.cues[2], children); |
| 44 testExpected(fragment.isEqualNode(video.textTracks[i].cues[1].ge
tCueAsHTML()), true); | 70 }); |
| 45 | 71 </script> |
| 46 | |
| 47 fragment = document.createDocumentFragment(); | |
| 48 fragment.appendChild(document.createTextNode("I said ")); | |
| 49 cspan = document.createElement("span"); | |
| 50 cspan.className = "blue"; | |
| 51 cspan.title = "Speaker"; | |
| 52 cspan.appendChild(document.createTextNode("Bear is coming now"))
; | |
| 53 fragment.appendChild(cspan); | |
| 54 fragment.appendChild(document.createTextNode("!!!!")); | |
| 55 | |
| 56 testExpected(fragment.isEqualNode(video.textTracks[i].cues[2].ge
tCueAsHTML()), true); | |
| 57 | |
| 58 allTestsEnded(); | |
| 59 } | |
| 60 | |
| 61 function testTrackError(i) | |
| 62 { | |
| 63 findMediaElement(); | |
| 64 testExpected("video.textTracks[" + i + "].cues.length", "3"); | |
| 65 | |
| 66 var fragment = document.createDocumentFragment(); | |
| 67 fragment.appendChild(document.createTextNode("Bear is Coming!!!!
!")); | |
| 68 fragment.appendChild(document.createTextNode("\nThis is two anno
tations for an empty tag.")); | |
| 69 | |
| 70 | |
| 71 testExpected(fragment.isEqualNode(video.textTracks[i].cues[0].ge
tCueAsHTML()), true); | |
| 72 | |
| 73 fragment = document.createDocumentFragment(); | |
| 74 fragment.appendChild(document.createTextNode("I said Bear is com
ing!!!!")); | |
| 75 fragment.appendChild(document.createTextNode("\nThis does not pa
rse as a voice tag.")); | |
| 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 fragment.appendChild(document.createTextNode("Bear is coming now
")); | |
| 82 fragment.appendChild(document.createTextNode("!!!!\nThis does no
t parse as a voice tag.")); | |
| 83 | |
| 84 testExpected(fragment.isEqualNode(video.textTracks[i].cues[2].ge
tCueAsHTML()), true); | |
| 85 | |
| 86 allTestsEnded(); | |
| 87 } | |
| 88 </script> | |
| 89 </head> | |
| 90 <body onload="enableAllTextTracks()"> | |
| 91 <p>Tests cues with voice markup <v>.</p> | |
| 92 <video> | |
| 93 <track src="captions-webvtt/tc026-voice.vtt" onload="trackLoaded()"> | |
| 94 <track src="captions-webvtt/tc026-voice-bad.vtt" onload="trackLoaded
()"> | |
| 95 </video> | |
| 96 </body> | |
| 97 </html> | |
| OLD | NEW |