summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/track-cue-mutable.html
blob: 26a6b84f8a251676e4bcd9a927f849bd16bb8a07 (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
<!DOCTYPE html>
<title>Modifying attributes of a VTTCue</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
    <track id="captions" src="resources/captions.vtt" kind="captions" default>
    <script>
        async_test(function(t) {
            var track = document.querySelector("track");

            track.onload = t.step_func_done(function() {
                var cues = track.track.cues;

                // Test initial values.
                textCue = cues.getCueById("1");

                assert_equals(textCue.startTime, 0);
                assert_equals(textCue.endTime, 1.0);
                assert_equals(textCue.pauseOnExit, false);
                assert_equals(textCue.vertical, "");
                assert_equals(textCue.snapToLines, true);
                assert_equals(textCue.line, "auto");
                assert_equals(textCue.position, "auto");
                assert_equals(textCue.size, 100);
                assert_equals(textCue.align, "center");

                // Modify cue values.
                textCue.startTime = 1.1;
                assert_equals(textCue.startTime, 1.1);

                textCue.endTime = 3.9;
                assert_equals(textCue.endTime, 3.9);

                textCue.pauseOnExit = true;
                assert_equals(textCue.pauseOnExit, true);

                // http://dev.w3.org/html5/webvtt/#dfn-dom-vttcue-vertical
                // On setting, the text track cue writing direction must be
                // set to the value given in the first cell of the row in
                // the table above whose second cell is a case-sensitive
                // match for the new value.
                textCue.vertical = "RL";
                assert_equals(textCue.vertical, "");
                textCue.vertical = "rl";
                assert_equals(textCue.vertical, "rl");

                textCue.snapToLines = false;
                assert_equals(textCue.snapToLines, false);

                // http://dev.w3.org/html5/webvtt/#dfn-vttcue-line
                // 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 interpreted as the special value auto.
                assert_equals(textCue.line, "auto");
                assert_throws_js(TypeError, function() { textCue.line = "gazonk"; });
                assert_equals(textCue.line, "auto");
                textCue.line = 42;
                assert_equals(textCue.line, 42);
                textCue.line = -2;
                assert_equals(textCue.line, -2);
                textCue.line = 102;
                assert_equals(textCue.line, 102);
                textCue.snapToLines = true;
                textCue.line = -2;
                assert_equals(textCue.line, -2);
                textCue.line = 102;
                assert_equals(textCue.line, 102);

                // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-line
                // 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.
                assert_throws_dom("IndexSizeError", function() { textCue.position = -200; });
                assert_throws_dom("IndexSizeError", function() { textCue.position = 110; });
                textCue.position = 11;
                assert_equals(textCue.position, 11);

                // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-size
                // 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.
                assert_throws_dom("IndexSizeError", function() { textCue.size = -200 });
                assert_throws_dom("IndexSizeError", function() { textCue.size = 110 });
                textCue.size = 57;
                assert_equals(textCue.size, 57);

                // http://dev.w3.org/html5/webvtt/#dfn-dom-vttcue-align
                // On setting, the text track cue text alignment must be
                // set to the value given in the first cell of the row
                // in the table above whose second cell is a case-sensitive
                // match for the new value.
                textCue.align = "End";
                assert_equals(textCue.align, "center");
                textCue.align = "end";
                assert_equals(textCue.align, "end");
            });
        });
    </script>
</video>