OLD | NEW |
| (Empty) |
1 <!doctype html> | |
2 <title>TextTrackCue.snapToLines</title> | |
3 <script src=../../../../../resources/testharness.js></script> | |
4 <script src=../../../../../resources/testharnessreport.js></script> | |
5 <div id=log></div> | |
6 <script> | |
7 setup(function(){ | |
8 window.video = document.createElement('video'); | |
9 window.t1 = video.addTextTrack('subtitles'); | |
10 document.body.appendChild(video); | |
11 }); | |
12 test(function(){ | |
13 var c1 = new TextTrackCue(0, 1, 'text1'); | |
14 assert_true(c1.snapToLines); | |
15 c1.line = 101; | |
16 c1.snapToLines = false; | |
17 assert_false(c1.snapToLines); | |
18 c1.snapToLines = true; | |
19 assert_true(c1.snapToLines); | |
20 c1.line = -1; | |
21 c1.snapToLines = false; | |
22 assert_false(c1.snapToLines); | |
23 c1.snapToLines = true; | |
24 assert_true(c1.snapToLines); | |
25 c1.line = 0; | |
26 c1.snapToLines = false; | |
27 assert_false(c1.snapToLines); | |
28 }, document.title+', script-created cue'); | |
29 | |
30 var t_parsed = async_test(document.title+', parsed cue'); | |
31 t_parsed.step(function(){ | |
32 var t = document.createElement('track'); | |
33 t.onload = this.step_func(function(){ | |
34 var c1 = t.track.cues[0]; | |
35 assert_true(c1.snapToLines); | |
36 c1.line = 101; | |
37 c1.snapToLines = false; | |
38 assert_false(c1.snapToLines); | |
39 c1.snapToLines = true; | |
40 assert_true(c1.snapToLines); | |
41 c1.line = -1; | |
42 c1.snapToLines = false; | |
43 assert_false(c1.snapToLines); | |
44 c1.snapToLines = true; | |
45 assert_true(c1.snapToLines); | |
46 c1.line = 0; | |
47 c1.snapToLines = false; | |
48 assert_false(c1.snapToLines); | |
49 | |
50 var c2 = t.track.cues[1]; | |
51 assert_true(c2.snapToLines); | |
52 c2.line = 101; | |
53 c2.snapToLines = false; | |
54 assert_false(c2.snapToLines); | |
55 c2.snapToLines = true; | |
56 assert_true(c2.snapToLines); | |
57 c2.line = -1; | |
58 c2.snapToLines = false; | |
59 assert_false(c2.snapToLines); | |
60 c2.snapToLines = true; | |
61 assert_true(c2.snapToLines); | |
62 c2.line = 0; | |
63 c2.snapToLines = false; | |
64 assert_false(c2.snapToLines); | |
65 | |
66 var c3 = t.track.cues[2]; | |
67 assert_false(c3.snapToLines); | |
68 c3.snapToLines = false; | |
69 assert_false(c3.snapToLines); | |
70 c3.snapToLines = true; | |
71 assert_true(c3.snapToLines); | |
72 c3.line = 101; | |
73 c3.snapToLines = false; | |
74 assert_false(c3.snapToLines); | |
75 c3.snapToLines = true; | |
76 assert_true(c3.snapToLines); | |
77 c3.line = -1; | |
78 c3.snapToLines = false; | |
79 assert_false(c3.snapToLines); | |
80 c3.snapToLines = true; | |
81 assert_true(c3.snapToLines); | |
82 c3.line = 0; | |
83 c3.snapToLines = false; | |
84 assert_false(c3.snapToLines); | |
85 | |
86 this.done(); | |
87 }); | |
88 t.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:0
0:00.001\ntest\n\n'+ | |
89 '00:00:00.000 --> 00:00:00.001 l
ine:0\ntest\n\n'+ | |
90 '00:00:00.000 --> 00:00:00.001 l
ine:0%\ntest'); | |
91 t.track.mode = 'showing'; | |
92 video.appendChild(t); | |
93 }); | |
94 </script> | |
OLD | NEW |