OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Tests modifying attributes of a VTTCue</title> |
3 <head> | 3 <script src="../../resources/testharness.js"></script> |
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | 4 <script src="../../resources/testharnessreport.js"></script> |
| 5 <video> |
| 6 <track id="captions" src="captions-webvtt/captions.vtt" kind="captions" defa
ult> |
| 7 </video> |
| 8 <script> |
| 9 async_test(function(t) { |
| 10 var track = document.querySelector("track"); |
5 | 11 |
6 <script src=../media-file.js></script> | 12 track.onload = t.step_func_done(function() { |
7 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 | 13 var cues = track.track.cues; |
8 (Please avoid writing new tests using video-test.js) --> | |
9 <script src=../video-test.js></script> | |
10 <script> | |
11 | 14 |
12 var cues; | 15 // Test initial values. |
| 16 textCue = cues.getCueById("1"); |
13 | 17 |
14 function logSpecURL(url, description) | 18 assert_equals(textCue.startTime, 0); |
15 { | 19 assert_equals(textCue.endTime, 1.0); |
16 consoleWrite("<br><i>" + description + "</i>"); | 20 assert_equals(textCue.pauseOnExit, false); |
17 consoleWrite("<a href=" + url + ">" + url + "<" + "/a>"); | 21 assert_equals(textCue.vertical, ""); |
18 } | 22 assert_equals(textCue.snapToLines, true); |
| 23 assert_equals(textCue.line, "auto"); |
| 24 assert_equals(textCue.position, "auto"); |
| 25 assert_equals(textCue.size, 100); |
| 26 assert_equals(textCue.align, "middle"); |
19 | 27 |
20 function trackLoaded() | 28 // Modify cue values. |
21 { | 29 textCue.startTime = 1.1; |
22 track = document.getElementById('captions'); | 30 assert_equals(textCue.startTime, 1.1); |
23 cues = track.track.cues; | |
24 | 31 |
25 consoleWrite("** Test initial values."); | 32 textCue.endTime = 3.9; |
26 run("textCue = cues.getCueById('1')"); | 33 assert_equals(textCue.endTime, 3.9); |
27 | 34 |
28 testExpected("textCue.startTime", 0); | 35 textCue.pauseOnExit = true; |
29 testExpected("textCue.endTime", 1.0); | 36 assert_equals(textCue.pauseOnExit, true); |
30 testExpected("textCue.pauseOnExit", false); | |
31 testExpected("textCue.vertical", ""); | |
32 testExpected("textCue.snapToLines", true); | |
33 testExpected("textCue.line", "auto"); | |
34 testExpected("textCue.position", "auto"); | |
35 testExpected("textCue.size", 100); | |
36 testExpected("textCue.align", "middle"); | |
37 | 37 |
38 consoleWrite("<br>** Modify cue values."); | 38 // http://dev.w3.org/html5/webvtt/#dfn-dom-vttcue-vertical |
| 39 // On setting, the text track cue writing direction must be set to the v
alue given in the first cell |
| 40 // of the row in the table above whose second cell is a case-sensitive m
atch for the new value. |
| 41 textCue.vertical = "RL"; |
| 42 assert_equals(textCue.vertical, ""); |
| 43 textCue.vertical = "rl"; |
| 44 assert_equals(textCue.vertical, "rl"); |
39 | 45 |
40 run("textCue.startTime = 1.1"); | 46 textCue.snapToLines = false; |
41 testExpected("textCue.startTime", 1.1); | 47 assert_equals(textCue.snapToLines, false); |
42 | 48 |
43 consoleWrite(""); | 49 // http://dev.w3.org/html5/webvtt/#dfn-vttcue-line |
44 run("textCue.endTime = 3.9"); | 50 // On setting, the text track cue line position must be set to the new v
alue; |
45 testExpected("textCue.endTime", 3.9); | 51 // if the new value is the string "auto", then it must be interpreted as
the special value auto. |
| 52 assert_equals(textCue.line, "auto"); |
| 53 assert_throws(new TypeError, function() { textCue.line = "gazonk"; }); |
| 54 assert_equals(textCue.line, "auto"); |
| 55 textCue.line = 42; |
| 56 assert_equals(textCue.line, 42); |
| 57 textCue.line = -2; |
| 58 assert_equals(textCue.line, -2); |
| 59 textCue.line = 102; |
| 60 assert_equals(textCue.line, 102); |
| 61 textCue.snapToLines = true; |
| 62 textCue.line = -2; |
| 63 assert_equals(textCue.line, -2); |
| 64 textCue.line = 102; |
| 65 assert_equals(textCue.line, 102); |
46 | 66 |
47 consoleWrite(""); | 67 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video
-element.html#dom-texttrackcue-line |
48 run("textCue.pauseOnExit = true"); | 68 // On setting, if the new value is negative or greater than 100, then th
row an IndexSizeError exception. |
49 testExpected("textCue.pauseOnExit", true); | 69 // Otherwise, set the text track cue text position to the new value. |
| 70 assert_throws("IndexSizeError", function() { textCue.position = -200; })
; |
| 71 assert_throws("IndexSizeError", function() { textCue.position = 110; }); |
| 72 textCue.position = 11; |
| 73 assert_equals(textCue.position, 11); |
50 | 74 |
51 logSpecURL("http://dev.w3.org/html5/webvtt/#dfn-dom-vttcue-verti
cal", | 75 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video
-element.html#dom-texttrackcue-size |
52 "On setting, the text track cue writing direction mus
t be set to the value given in the first cell of the row in the table above whos
e second cell is a case-sensitive match for the new value."); | 76 // On setting, if the new value is negative or greater than 100, then th
row an IndexSizeError exception. |
53 run("textCue.vertical = 'RL'"); | 77 // Otherwise, set the text track cue size to the new value. |
54 testExpected("textCue.vertical", ""); | 78 assert_throws("IndexSizeError", function() { textCue.size = -200 }); |
55 run("textCue.vertical = 'rl'"); | 79 assert_throws("IndexSizeError", function() { textCue.size = 110 }); |
56 testExpected("textCue.vertical", "rl"); | 80 textCue.size = 57; |
| 81 assert_equals(textCue.size, 57); |
57 | 82 |
58 consoleWrite(""); | 83 // http://dev.w3.org/html5/webvtt/#dfn-dom-vttcue-align |
59 run("textCue.snapToLines = false"); | 84 // On setting, the text track cue text alignment must be set to the valu
e given in the first cell |
60 testExpected("textCue.snapToLines", false); | 85 // of the row in the table above whose second cell is a case-sensitive m
atch for the new value. |
61 | 86 textCue.align = "End"; |
62 logSpecURL("http://dev.w3.org/html5/webvtt/#dfn-vttcue-line", | 87 assert_equals(textCue.align, "middle"); |
63 "On setting, the text track cue line position must be
set to the new value; if the new value is the string 'auto', then it must be in
terpreted as the special value auto."); | 88 textCue.align = "end"; |
64 testExpected("textCue.line", "auto"); | 89 assert_equals(textCue.align, "end"); |
65 testException("textCue.line = 'gazonk'", '"TypeError: Failed to
set the \'line\' property on \'VTTCue\': \'gazonk\' is not a valid enum value."'
); | 90 }); |
66 testExpected("textCue.line", "auto"); | 91 }); |
67 run("textCue.line = 42"); | 92 </script> |
68 testExpected("textCue.line", 42); | |
69 run("textCue.line = -2"); | |
70 testExpected("textCue.line", -2); | |
71 run("textCue.line = 102"); | |
72 testExpected("textCue.line", 102); | |
73 run("textCue.snapToLines = true"); | |
74 run("textCue.line = -2"); | |
75 testExpected("textCue.line", -2); | |
76 run("textCue.line = 102"); | |
77 testExpected("textCue.line", 102); | |
78 | |
79 logSpecURL("http://www.whatwg.org/specs/web-apps/current-work/mu
ltipage/the-video-element.html#dom-texttrackcue-line", | |
80 "On setting, if the new value is negative or greater
than 100, then throw an IndexSizeError exception. Otherwise, set the text track
cue text position to the new value."); | |
81 testDOMException("textCue.position = -200", "DOMException.INDEX_
SIZE_ERR"); | |
82 testDOMException("textCue.position = 110", "DOMException.INDEX_S
IZE_ERR"); | |
83 run("textCue.position = 11"); | |
84 testExpected("textCue.position", 11); | |
85 | |
86 logSpecURL("http://www.whatwg.org/specs/web-apps/current-work/mu
ltipage/the-video-element.html#dom-texttrackcue-size", | |
87 "On setting, if the new value is negative or greater
than 100, then throw an IndexSizeError exception. Otherwise, set the text track
cue size to the new value."); | |
88 testDOMException("textCue.size = -200", "DOMException.INDEX_SIZE
_ERR"); | |
89 testDOMException("textCue.size = 110", "DOMException.INDEX_SIZE_
ERR"); | |
90 run("textCue.size = 57"); | |
91 testExpected("textCue.size", 57); | |
92 | |
93 logSpecURL("http://dev.w3.org/html5/webvtt/#dfn-dom-vttcue-align
", | |
94 "On setting, the text track cue text alignment must b
e set to the value given in the first cell of the row in the table above whose s
econd cell is a case-sensitive match for the new value."); | |
95 run("textCue.align = 'End'"); | |
96 testExpected("textCue.align", "middle"); | |
97 run("textCue.align = 'end'"); | |
98 testExpected("textCue.align", "end"); | |
99 | |
100 consoleWrite(""); | |
101 endTest(); | |
102 } | |
103 | |
104 </script> | |
105 </head> | |
106 <body> | |
107 <p>Tests modifying attributes of a VTTCue</p> | |
108 <video controls> | |
109 <track id="captions" src="captions-webvtt/captions.vtt" kind="captio
ns" onload="trackLoaded()" default> | |
110 </video> | |
111 </body> | |
112 </html> | |
OLD | NEW |