OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Tests entities in the cue text.</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 // TODO(srirama.m): Rewrite the test in a better way. |
| 8 // See https://codereview.chromium.org/2030383002/ for details. |
| 9 check_cues_from_track("captions-webvtt/tc022-entities.vtt", function(track) { |
| 10 var expected = [ |
| 11 { innerHTML: "This cue has an ampersand & character." }, |
| 12 { innerHTML: "This cue has a less than < character." }, |
| 13 { innerHTML: "This cue has a greater than > character." }, |
| 14 { innerHTML: "This cue has a Left-to-Right Mark \u200e." }, |
| 15 { innerHTML: "This cue has a Right-to-Left Mark \u200f." }, |
| 16 { innerHTML: "This cue has a non-breaking space \u00a0." }, |
| 17 { innerHTML: "This & is parsed to the same as &." } |
| 18 ]; |
5 | 19 |
6 <script src=../media-file.js></script> | 20 var cues = track.cues; |
7 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 21 assert_equals(cues.length, expected.length); |
8 (Please avoid writing new tests using video-test.js) --> | 22 for (var i = 0; i < cues.length; i++) |
9 <script src=../video-test.js></script> | 23 assert_equals(cues[i].getCueAsHTML().textContent, expected[i].innerHTML)
; |
10 <script> | 24 }); |
11 | 25 |
12 var numberOfTrackTests = 2; | 26 check_cues_from_track("captions-webvtt/tc022-entities-wrong.vtt", function(track
) { |
| 27 var expected = [ |
| 28 { innerHTML: "This cue has a less than ", }, |
| 29 { innerHTML: "This cue has a greater than > character.\nSince it's not r
elated to a < character,\nit's just interpreted as text.", } |
| 30 ]; |
13 | 31 |
14 function trackLoaded() | 32 var cues = track.cues; |
15 { | 33 assert_equals(cues.length, expected.length); |
16 numberOfTracksLoaded++; | 34 for (var i = 0; i < cues.length; i++) |
17 if (numberOfTracksLoaded == numberOfTrackTests) { | 35 assert_equals(cues[i].getCueAsHTML().textContent, expected[i].innerHTML)
; |
18 testTrack(0); | 36 }); |
19 testTrackError(1); | 37 </script> |
20 } | |
21 } | |
22 | |
23 | |
24 function testTrack(i) | |
25 { | |
26 findMediaElement(); | |
27 var expected = | |
28 { | |
29 length : 7, | |
30 tests: | |
31 [ | |
32 { | |
33 property : "getCueAsHTML().textContent", | |
34 values : ["This cue has an ampersand & character.", | |
35 "This cue has a less than < character.", | |
36 "This cue has a greater than > character."
, | |
37 "This cue has a Left-to-Right Mark \u200e.
", | |
38 "This cue has a Right-to-Left Mark \u200f.
", | |
39 "This cue has a non-breaking space \u00a0.
", | |
40 "This & is parsed to the same as &."], | |
41 }, | |
42 ], | |
43 }; | |
44 testCues(i, expected); | |
45 | |
46 allTestsEnded(); | |
47 } | |
48 | |
49 function testTrackError(i) | |
50 { | |
51 findMediaElement(); | |
52 var expected = | |
53 { | |
54 length : 2, | |
55 tests: | |
56 [ | |
57 { | |
58 property : "getCueAsHTML().textContent", | |
59 values : ["This cue has a less than ", | |
60 "This cue has a greater than > character.\
nSince it's not related to a < character,\nit's just interpreted as text."], | |
61 }, | |
62 ], | |
63 }; | |
64 testCues(i, expected); | |
65 | |
66 allTestsEnded(); | |
67 } | |
68 </script> | |
69 </head> | |
70 <body onload="enableAllTextTracks()"> | |
71 <p>Tests entities in the cue text.</p> | |
72 <video> | |
73 <track src="captions-webvtt/tc022-entities.vtt" onload="trackLoaded(
)"> | |
74 <track src="captions-webvtt/tc022-entities-wrong.vtt" onload="trackL
oaded()"> | |
75 </video> | |
76 </body> | |
77 </html> | |
OLD | NEW |