OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <title>VTTCue.line</title> | 2 <title>VTTCue.line</title> |
3 <script src=../../../../../resources/testharness.js></script> | 3 <script src=../../../../../resources/testharness.js></script> |
4 <script src=../../../../../resources/testharnessreport.js></script> | 4 <script src=../../../../../resources/testharnessreport.js></script> |
5 <div id=log></div> | 5 <div id=log></div> |
6 <script> | 6 <script> |
7 test(function(){ | 7 test(function(){ |
8 var video = document.createElement('video'); | 8 var video = document.createElement('video'); |
9 document.body.appendChild(video); | 9 document.body.appendChild(video); |
10 var c1 = new VTTCue(0, 1, 'text1'); | 10 var c1 = new VTTCue(0, 1, 'text1'); |
11 assert_equals(c1.line, -1); | 11 assert_equals(c1.line, 'auto'); |
12 var track = document.createElement('track'); | 12 var track = document.createElement('track'); |
13 var t = track.track; | 13 var t = track.track; |
14 t.addCue(c1); | 14 t.addCue(c1); |
15 assert_equals(c1.line, -1); | 15 assert_equals(c1.line, 'auto'); |
16 video.appendChild(track); | 16 video.appendChild(track); |
17 assert_equals(c1.line, -1); | 17 assert_equals(c1.line, 'auto'); |
18 t.mode = 'showing'; | 18 t.mode = 'showing'; |
19 assert_equals(c1.line, -1); | 19 assert_equals(c1.line, 'auto'); |
20 var c2 = new VTTCue(0, 1, 'text2'); | 20 var c2 = new VTTCue(0, 1, 'text2'); |
21 var track2 = document.createElement('track'); | 21 var track2 = document.createElement('track'); |
22 var t2 = track2.track; | 22 var t2 = track2.track; |
23 t2.addCue(c2); | 23 t2.addCue(c2); |
24 assert_equals(c2.line, -1); | 24 assert_equals(c2.line, 'auto'); |
25 video.appendChild(track2); | 25 video.appendChild(track2); |
26 t2.mode = 'showing'; | 26 t2.mode = 'showing'; |
27 assert_equals(c2.line, -2); | 27 assert_equals(c2.line, 'auto'); |
28 assert_equals(c1.line, -1); | 28 assert_equals(c1.line, 'auto'); |
29 c1.line = -5; | 29 c1.line = -5; |
30 assert_equals(c1.line, -5); | 30 assert_equals(c1.line, -5); |
31 assert_equals(c2.line, -2); | 31 assert_equals(c2.line, 'auto'); |
32 c1.line = 0; | 32 c1.line = 0; |
33 c1.snapToLines = false; | 33 c1.snapToLines = false; |
34 assert_equals(c1.line, 0); | 34 assert_equals(c1.line, 0); |
35 assert_equals(c2.line, -2); | 35 assert_equals(c2.line, 'auto'); |
| 36 assert_throws(new TypeError, function() { c1.line = 'auto\0'; }); |
| 37 assert_throws(new TypeError, function() { c1.line = NaN; }); |
| 38 assert_throws(new TypeError, function() { c1.line = Infinity; }); |
| 39 assert_equals(c1.line, 0); |
| 40 c1.line = -1; |
| 41 assert_equals(c1.line, -1); |
36 }, document.title+', script-created cue'); | 42 }, document.title+', script-created cue'); |
37 | 43 |
38 var t_parsed = async_test(document.title+', parsed cue'); | 44 var t_parsed = async_test(document.title+', parsed cue'); |
39 t_parsed.step(function(){ | 45 t_parsed.step(function(){ |
40 var video = document.createElement('video'); | 46 var video = document.createElement('video'); |
41 document.body.appendChild(video); | 47 document.body.appendChild(video); |
42 var t = document.createElement('track'); | 48 var t = document.createElement('track'); |
43 t.onload = this.step_func(function(){ | 49 t.onload = this.step_func(function(){ |
44 var c1 = t.track.cues[0]; | 50 var c1 = t.track.cues[0]; |
45 var c2 = t.track.cues[1]; | 51 var c2 = t.track.cues[1]; |
46 var c3 = t.track.cues[2]; | 52 var c3 = t.track.cues[2]; |
47 assert_equals(c1.line, -1); | 53 assert_equals(c1.line, 'auto'); |
48 assert_equals(c2.line, 0); | 54 assert_equals(c2.line, 0); |
49 assert_equals(c3.line, 0); | 55 assert_equals(c3.line, 0); |
50 | 56 |
51 this.done(); | 57 this.done(); |
52 }); | 58 }); |
53 t.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:0
0:00.001\ntest\n\n'+ | 59 t.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:0
0:00.001\ntest\n\n'+ |
54 '00:00:00.000 --> 00:00:00.001 l
ine:0\ntest\n\n'+ | 60 '00:00:00.000 --> 00:00:00.001 l
ine:0\ntest\n\n'+ |
55 '00:00:00.000 --> 00:00:00.001 l
ine:0%\ntest'); | 61 '00:00:00.000 --> 00:00:00.001 l
ine:0%\ntest'); |
56 t.track.mode = 'showing'; | 62 t.track.mode = 'showing'; |
57 video.appendChild(t); | 63 video.appendChild(t); |
58 }); | 64 }); |
59 </script> | 65 </script> |
OLD | NEW |