blob: b3f9f34f10b94d417b3801fff433fe33a1c3e524 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
<!doctype html>
<title>VTTCue.snapToLines</title>
<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttcue-snaptolines">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=common.js></script>
<div id=log></div>
<script>
setup(function(){
window.video = document.createElement('video');
window.t1 = video.addTextTrack('subtitles');
document.body.appendChild(video);
});
test(function(){
var c1 = new VTTCue(0, 1, 'text1');
assert_true('snapToLines' in c1, 'snapToLines is not supported');
assert_true(c1.snapToLines);
c1.line = 101;
c1.snapToLines = false;
assert_false(c1.snapToLines);
c1.snapToLines = true;
assert_true(c1.snapToLines);
c1.line = -1;
c1.snapToLines = false;
assert_false(c1.snapToLines);
c1.snapToLines = true;
assert_true(c1.snapToLines);
c1.line = 0;
c1.snapToLines = false;
assert_false(c1.snapToLines);
}, document.title+', script-created cue');
var t_parsed = async_test(document.title+', parsed cue');
t_parsed.step(function(){
var t = document.createElement('track');
t.onload = this.step_func(function(){
var c1 = t.track.cues[0];
assert_true(c1.snapToLines);
c1.line = 101;
c1.snapToLines = false;
assert_false(c1.snapToLines);
c1.snapToLines = true;
assert_true(c1.snapToLines);
c1.line = -1;
c1.snapToLines = false;
assert_false(c1.snapToLines);
c1.snapToLines = true;
assert_true(c1.snapToLines);
c1.line = 0;
c1.snapToLines = false;
assert_false(c1.snapToLines);
var c2 = t.track.cues[1];
assert_true(c2.snapToLines);
c2.line = 101;
c2.snapToLines = false;
assert_false(c2.snapToLines);
c2.snapToLines = true;
assert_true(c2.snapToLines);
c2.line = -1;
c2.snapToLines = false;
assert_false(c2.snapToLines);
c2.snapToLines = true;
assert_true(c2.snapToLines);
c2.line = 0;
c2.snapToLines = false;
assert_false(c2.snapToLines);
var c3 = t.track.cues[2];
assert_false(c3.snapToLines);
c3.snapToLines = false;
assert_false(c3.snapToLines);
c3.snapToLines = true;
assert_true(c3.snapToLines);
c3.line = 101;
c3.snapToLines = false;
assert_false(c3.snapToLines);
c3.snapToLines = true;
assert_true(c3.snapToLines);
c3.line = -1;
c3.snapToLines = false;
assert_false(c3.snapToLines);
c3.snapToLines = true;
assert_true(c3.snapToLines);
c3.line = 0;
c3.snapToLines = false;
assert_false(c3.snapToLines);
this.done();
});
t.onerror = this.step_func(function() {
assert_unreached('got error event');
});
t.src = make_vtt_track('WEBVTT\n\n00:00:00.000 --> 00:00:00.001\ntest\n\n'+
'00:00:00.000 --> 00:00:00.001 line:0\ntest\n\n'+
'00:00:00.000 --> 00:00:00.001 line:0%\ntest', this);
t.track.mode = 'showing';
video.appendChild(t);
});
</script>
|