tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

track-cue-mutable.html (4774B)


      1 <!DOCTYPE html>
      2 <title>Modifying attributes of a VTTCue</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <video>
      6    <track id="captions" src="resources/captions.vtt" kind="captions" default>
      7    <script>
      8        async_test(function(t) {
      9            var track = document.querySelector("track");
     10 
     11            track.onload = t.step_func_done(function() {
     12                var cues = track.track.cues;
     13 
     14                // Test initial values.
     15                textCue = cues.getCueById("1");
     16 
     17                assert_equals(textCue.startTime, 0);
     18                assert_equals(textCue.endTime, 1.0);
     19                assert_equals(textCue.pauseOnExit, false);
     20                assert_equals(textCue.vertical, "");
     21                assert_equals(textCue.snapToLines, true);
     22                assert_equals(textCue.line, "auto");
     23                assert_equals(textCue.position, "auto");
     24                assert_equals(textCue.size, 100);
     25                assert_equals(textCue.align, "center");
     26 
     27                // Modify cue values.
     28                textCue.startTime = 1.1;
     29                assert_equals(textCue.startTime, 1.1);
     30 
     31                textCue.endTime = 3.9;
     32                assert_equals(textCue.endTime, 3.9);
     33 
     34                textCue.pauseOnExit = true;
     35                assert_equals(textCue.pauseOnExit, true);
     36 
     37                // http://dev.w3.org/html5/webvtt/#dfn-dom-vttcue-vertical
     38                // On setting, the text track cue writing direction must be
     39                // set to the value given in the first cell of the row in
     40                // the table above whose second cell is a case-sensitive
     41                // match for the new value.
     42                textCue.vertical = "RL";
     43                assert_equals(textCue.vertical, "");
     44                textCue.vertical = "rl";
     45                assert_equals(textCue.vertical, "rl");
     46 
     47                textCue.snapToLines = false;
     48                assert_equals(textCue.snapToLines, false);
     49 
     50                // http://dev.w3.org/html5/webvtt/#dfn-vttcue-line
     51                // On setting, the text track cue line position must be set
     52                // to the new value; if the new value is the string "auto",
     53                // then it must be interpreted as the special value auto.
     54                assert_equals(textCue.line, "auto");
     55                assert_throws_js(TypeError, function() { textCue.line = "gazonk"; });
     56                assert_equals(textCue.line, "auto");
     57                textCue.line = 42;
     58                assert_equals(textCue.line, 42);
     59                textCue.line = -2;
     60                assert_equals(textCue.line, -2);
     61                textCue.line = 102;
     62                assert_equals(textCue.line, 102);
     63                textCue.snapToLines = true;
     64                textCue.line = -2;
     65                assert_equals(textCue.line, -2);
     66                textCue.line = 102;
     67                assert_equals(textCue.line, 102);
     68 
     69                // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-line
     70                // On setting, if the new value is negative or greater than 100,
     71                // then throw an IndexSizeError exception.
     72                // Otherwise, set the text track cue text position to the new value.
     73                assert_throws_dom("IndexSizeError", function() { textCue.position = -200; });
     74                assert_throws_dom("IndexSizeError", function() { textCue.position = 110; });
     75                textCue.position = 11;
     76                assert_equals(textCue.position, 11);
     77 
     78                // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-size
     79                // On setting, if the new value is negative or greater than 100,
     80                // then throw an IndexSizeError exception.
     81                // Otherwise, set the text track cue size to the new value.
     82                assert_throws_dom("IndexSizeError", function() { textCue.size = -200 });
     83                assert_throws_dom("IndexSizeError", function() { textCue.size = 110 });
     84                textCue.size = 57;
     85                assert_equals(textCue.size, 57);
     86 
     87                // http://dev.w3.org/html5/webvtt/#dfn-dom-vttcue-align
     88                // On setting, the text track cue text alignment must be
     89                // set to the value given in the first cell of the row
     90                // in the table above whose second cell is a case-sensitive
     91                // match for the new value.
     92                textCue.align = "End";
     93                assert_equals(textCue.align, "center");
     94                textCue.align = "end";
     95                assert_equals(textCue.align, "end");
     96            });
     97        });
     98    </script>
     99 </video>