OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
3 <head> | 3 <title>Tests that UTF-8 encoded characters are recognized properly and that diff
erent encodings (iconv) are not recognized as a WebVTT file (we do allow it, it
just looks ugly).</title> |
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | 4 <video> |
| 5 <track src="captions-webvtt/tc001-utf8.vtt"> |
| 6 <track src="captions-webvtt/tc001-iso2022jp3.vtt"> |
| 7 </video> |
| 8 <script src="track-helpers.js"></script> |
| 9 <script src="../../resources/testharness.js"></script> |
| 10 <script src="../../resources/testharnessreport.js"></script> |
| 11 <script> |
| 12 async_test(function(t) { |
| 13 var video = document.querySelector("video"); |
| 14 |
| 15 var trackElements = document.querySelectorAll("track"); |
| 16 for (var i = 0; i < video.textTracks.length; i++) |
| 17 trackElements[i].onload = t.step_func(trackLoaded); |
5 | 18 |
6 <script src=../media-file.js></script> | 19 enableAllTextTracks(video.textTracks); |
7 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 | |
8 (Please avoid writing new tests using video-test.js) --> | |
9 <script src=../video-test.js></script> | |
10 <script> | |
11 | 20 |
12 numberOfTrackTests = 2; | 21 var numberOfTracksLoaded = 0; |
| 22 function trackLoaded() { |
| 23 numberOfTracksLoaded++; |
| 24 if (numberOfTracksLoaded != 2) |
| 25 return; |
13 | 26 |
14 function trackLoaded() | 27 testTrack0(); |
| 28 testTrack1(); |
| 29 t.done(); |
| 30 } |
| 31 |
| 32 function testTrack0() { |
| 33 var expected = [ |
15 { | 34 { |
16 numberOfTracksLoaded++; | 35 id : "1", |
17 if (numberOfTracksLoaded == numberOfTrackTests) { | 36 startTime : 0, |
18 testTrack0(); | 37 endTime : 30.5, |
19 testTrack1(); | 38 text : "景気判断" |
20 } | 39 }, |
| 40 { |
| 41 id : "2", |
| 42 startTime : 31, |
| 43 endTime : 1200.5, |
| 44 text : "電力不足" |
21 } | 45 } |
| 46 ]; |
22 | 47 |
23 function testTrack0() | 48 var cues = video.textTracks[0].cues; |
24 { | 49 assert_equals(cues.length, 2); |
25 findMediaElement(); | 50 assert_cues_equal(cues, expected); |
26 var expected = | 51 } |
27 { | |
28 length : 2, | |
29 tests: | |
30 [ | |
31 { | |
32 property : "id", | |
33 values : [1, 2], | |
34 }, | |
35 { | |
36 property : "startTime", | |
37 values : [0.0, 31.0], | |
38 }, | |
39 { | |
40 property : "endTime", | |
41 values : [30.5, 1200.5], | |
42 }, | |
43 { | |
44 property : "text", | |
45 values : ["景気判断", "電力不足"], | |
46 }, | |
47 ], | |
48 }; | |
49 testCues(0, expected); | |
50 | 52 |
51 allTestsEnded(); | 53 function testTrack1() { |
52 } | 54 assert_equals(video.textTracks[1].cues.length, 2); |
53 | 55 } |
54 function testTrack1() | 56 }); |
55 { | 57 </script> |
56 findMediaElement(); | |
57 var expected = | |
58 { | |
59 length : 2, | |
60 tests: | |
61 [], | |
62 }; | |
63 testCues(1, expected); | |
64 | |
65 allTestsEnded(); | |
66 } | |
67 | |
68 </script> | |
69 </head> | |
70 <body onload="enableAllTextTracks()"> | |
71 <p>Tests that UTF-8 encoded characters are recognized properly and that
different encodings (iconv) are not recognized as a WebVTT file (we do allow it,
it just looks ugly).</p> | |
72 <video> | |
73 <track src="captions-webvtt/tc001-utf8.vtt" onload="trackLoaded()"> | |
74 <track src="captions-webvtt/tc001-iso2022jp3.vtt" onload="trackLoade
d()"> | |
75 </video> | |
76 </body> | |
77 </html> | |
OLD | NEW |