OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
5 | 5 |
6 <script src=../media-file.js></script> | 6 <script src=../media-file.js></script> |
| 7 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 |
| 8 (Please avoid writing new tests using video-test.js) --> |
7 <script src=../video-test.js></script> | 9 <script src=../video-test.js></script> |
8 <script> | 10 <script> |
9 | 11 |
10 var numberOfTrackTests = 2; | 12 var numberOfTrackTests = 2; |
11 | 13 |
12 function trackLoaded() | 14 function trackLoaded() |
13 { | 15 { |
14 numberOfTracksLoaded++; | 16 numberOfTracksLoaded++; |
15 if (numberOfTracksLoaded == numberOfTrackTests) { | 17 if (numberOfTracksLoaded == numberOfTrackTests) { |
16 testTrack(0); | 18 testTrack(0); |
17 testTrackError(1); | 19 testTrackError(1); |
18 } | 20 } |
19 } | 21 } |
20 | 22 |
21 function testTrack(i) | 23 function testTrack(i) |
22 { | 24 { |
23 findMediaElement(); | 25 findMediaElement(); |
24 testExpected("video.textTracks[" + i + "].cues.length", "3"); | 26 testExpected("video.textTracks[" + i + "].cues.length", "3"); |
25 | 27 |
26 // Note: Timestamps are handled as ProcessingInstructions, but b
ecause ProcessingInstructions | 28 // Note: Timestamps are handled as ProcessingInstructions, but b
ecause ProcessingInstructions |
27 // are used in XML and not HTML, they are ignored here. | 29 // are used in XML and not HTML, they are ignored here. |
28 // This should later be tested with oncuechange events. | 30 // This should later be tested with oncuechange events. |
29 var fragment = document.createDocumentFragment(); | 31 var fragment = document.createDocumentFragment(); |
30 fragment.appendChild(document.createTextNode("This cue is painte
d on.")); | 32 fragment.appendChild(document.createTextNode("This cue is painte
d on.")); |
31 | 33 |
32 testExpected("video.textTracks[" + i + "].cues[0].getCueAsHTML()
.textContent", fragment.textContent); | 34 testExpected("video.textTracks[" + i + "].cues[0].getCueAsHTML()
.textContent", fragment.textContent); |
33 | 35 |
34 fragment = document.createDocumentFragment(); | 36 fragment = document.createDocumentFragment(); |
35 fragment.appendChild(document.createTextNode("I said Bear is com
ing!!!!")); | 37 fragment.appendChild(document.createTextNode("I said Bear is com
ing!!!!")); |
36 | 38 |
37 testExpected("video.textTracks[" + i + "].cues[1].getCueAsHTML()
.textContent", fragment.textContent); | 39 testExpected("video.textTracks[" + i + "].cues[1].getCueAsHTML()
.textContent", fragment.textContent); |
38 | 40 |
39 fragment = document.createDocumentFragment(); | 41 fragment = document.createDocumentFragment(); |
40 fragment.appendChild(document.createTextNode("I said Bear is com
ing now!!!!")); | 42 fragment.appendChild(document.createTextNode("I said Bear is com
ing now!!!!")); |
41 | 43 |
42 testExpected("video.textTracks[" + i + "].cues[2].getCueAsHTML()
.textContent", fragment.textContent); | 44 testExpected("video.textTracks[" + i + "].cues[2].getCueAsHTML()
.textContent", fragment.textContent); |
43 | 45 |
44 allTestsEnded(); | 46 allTestsEnded(); |
45 } | 47 } |
46 | 48 |
47 function testTrackError(i) | 49 function testTrackError(i) |
48 { | 50 { |
49 findMediaElement(); | 51 findMediaElement(); |
50 testExpected("video.textTracks[" + i + "].cues.length", "3"); | 52 testExpected("video.textTracks[" + i + "].cues.length", "3"); |
51 | 53 |
52 var fragment = document.createDocumentFragment(); | 54 var fragment = document.createDocumentFragment(); |
53 fragment.appendChild(document.createTextNode("This cue is painte
d on.\nBut since the last two timestamps are out of order, they are ignored.")); | 55 fragment.appendChild(document.createTextNode("This cue is painte
d on.\nBut since the last two timestamps are out of order, they are ignored.")); |
54 | 56 |
55 testExpected("video.textTracks[" + i + "].cues[0].getCueAsHTML()
.textContent", fragment.textContent); | 57 testExpected("video.textTracks[" + i + "].cues[0].getCueAsHTML()
.textContent", fragment.textContent); |
56 | 58 |
57 fragment = document.createDocumentFragment(); | 59 fragment = document.createDocumentFragment(); |
58 fragment.appendChild(document.createTextNode("I said Bear is com
ing!!!!\nAll of these timestamps are before the start of the cue, so get ignored
.")); | 60 fragment.appendChild(document.createTextNode("I said Bear is com
ing!!!!\nAll of these timestamps are before the start of the cue, so get ignored
.")); |
59 | 61 |
60 testExpected("video.textTracks[" + i + "].cues[1].getCueAsHTML()
.textContent", fragment.textContent); | 62 testExpected("video.textTracks[" + i + "].cues[1].getCueAsHTML()
.textContent", fragment.textContent); |
61 | 63 |
62 fragment = document.createDocumentFragment(); | 64 fragment = document.createDocumentFragment(); |
63 fragment.appendChild(document.createTextNode("I said Bear is com
ing now!!!!\nAll of these timestamps are after the end of the cue, so get ignore
d.")); | 65 fragment.appendChild(document.createTextNode("I said Bear is com
ing now!!!!\nAll of these timestamps are after the end of the cue, so get ignore
d.")); |
64 | 66 |
65 testExpected("video.textTracks[" + i + "].cues[2].getCueAsHTML()
.textContent", fragment.textContent); | 67 testExpected("video.textTracks[" + i + "].cues[2].getCueAsHTML()
.textContent", fragment.textContent); |
66 | 68 |
67 allTestsEnded(); | 69 allTestsEnded(); |
68 } | 70 } |
69 </script> | 71 </script> |
70 </head> | 72 </head> |
71 <body onload="enableAllTextTracks()"> | 73 <body onload="enableAllTextTracks()"> |
72 <p>Tests cues with <timestamps> tags.</p> | 74 <p>Tests cues with <timestamps> tags.</p> |
73 <video> | 75 <video> |
74 <track src="captions-webvtt/tc024-timestamp.vtt" onload="trackLoaded
()"> | 76 <track src="captions-webvtt/tc024-timestamp.vtt" onload="trackLoaded
()"> |
75 <track src="captions-webvtt/tc024-timestamp-bad.vtt" onload="trackLo
aded()"> | 77 <track src="captions-webvtt/tc024-timestamp-bad.vtt" onload="trackLo
aded()"> |
76 </video> | 78 </video> |
77 </body> | 79 </body> |
78 </html> | 80 </html> |
OLD | NEW |