| 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 { type: "span", style: { className: "blue", title: "Speaker" }, |
| 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 { type: "text", value: "\nText span with a class and an annotation." } |
| 10 <script> | 14 ]; |
| 15 assert_cue_fragment(track.cues[0], children); |
| 11 | 16 |
| 12 var numberOfTrackTests = 2; | 17 children = [ |
| 18 { type: "span", style: { title: "Doe Hunter" }, |
| 19 value: [ { type: "text", value: "I said Bear is coming!!!!" } ] } |
| 20 ]; |
| 21 assert_cue_fragment(track.cues[1], children); |
| 13 | 22 |
| 14 function trackLoaded() | 23 children = [ |
| 15 { | 24 { type: "text", value: "I said " }, |
| 16 numberOfTracksLoaded++; | 25 { type: "span", style: { className: "blue", title: "Speaker" }, |
| 17 if (numberOfTracksLoaded == numberOfTrackTests) { | 26 value: [ { type: "text", value: "Bear is coming now" } ] }, |
| 18 testTrack(0); | 27 { type: "text", value: "!!!!" } |
| 19 testTrackError(1); | 28 ]; |
| 20 } | 29 assert_cue_fragment(track.cues[2], children); |
| 21 } | 30 }); |
| 22 | 31 |
| 23 function testTrack(i) | 32 check_cues_from_track("captions-webvtt/tc026-voice-bad.vtt", function(track) { |
| 24 { | 33 assert_equals(track.cues.length, 3); |
| 25 findMediaElement(); | |
| 26 testExpected("video.textTracks[" + i + "].cues.length", "3"); | |
| 27 | 34 |
| 28 var fragment = document.createDocumentFragment(); | 35 var children = [ |
| 29 var cspan = document.createElement("span"); | 36 { type: "text", value: "Bear is Coming!!!!!" }, |
| 30 cspan.className = "blue"; | 37 { type: "text", value: "\nThis is two annotations for an empty tag." } |
| 31 cspan.title = "Speaker"; | 38 ]; |
| 32 cspan.appendChild(document.createTextNode("Bear is Coming!!!!!")
); | 39 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 | 40 |
| 36 testExpected(fragment.isEqualNode(video.textTracks[i].cues[0].ge
tCueAsHTML()), true); | 41 children = [ |
| 42 { type: "text", value: "I said Bear is coming!!!!" }, |
| 43 { type: "text", value: "\nThis does not parse as a voice tag." } |
| 44 ]; |
| 45 assert_cue_fragment(track.cues[1], children); |
| 37 | 46 |
| 38 fragment = document.createDocumentFragment(); | 47 children = [ |
| 39 cspan = document.createElement("span"); | 48 { type: "text", value: "I said " }, |
| 40 cspan.title = "Doe Hunter"; | 49 { type: "text", value: "Bear is coming now" }, |
| 41 cspan.appendChild(document.createTextNode("I said Bear is coming
!!!!")); | 50 { type: "text", value: "!!!!\nThis does not parse as a voice tag." } |
| 42 fragment.appendChild(cspan); | 51 ]; |
| 43 | 52 assert_cue_fragment(track.cues[2], children); |
| 44 testExpected(fragment.isEqualNode(video.textTracks[i].cues[1].ge
tCueAsHTML()), true); | 53 }); |
| 45 | 54 </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 |