tor-browser

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

constructor.html (2508B)


      1 <!doctype html>
      2 <title>VTTRegion()</title>
      3 <link rel="help" href="https://w3c.github.io/webvtt/#dom-vttregion-vttregion">
      4 <script src=/resources/testharness.js></script>
      5 <script src=/resources/testharnessreport.js></script>
      6 <div id=log></div>
      7 <script>
      8 test(function() {
      9    var region = new VTTRegion();
     10    assert_true(region instanceof VTTRegion, "instanceof");
     11 
     12    assert_equals(region.scroll, "");
     13    assert_equals(region.viewportAnchorX, 0);
     14    assert_equals(region.viewportAnchorY, 100);
     15    assert_equals(region.regionAnchorX, 0);
     16    assert_equals(region.regionAnchorY, 100);
     17    assert_equals(region.lines, 3);
     18    assert_equals(region.width, 100);
     19 }, document.title + " initial values");
     20 
     21 test(function() {
     22    var region = new VTTRegion();
     23    region.scroll = "invalid-scroll-value";
     24    assert_equals(region.scroll, "");
     25 
     26    checkValues([-1, 101], "IndexSizeError");
     27    checkValues([-Infinity, Infinity, NaN], TypeError);
     28 
     29    function assert_throws_something(error, func) {
     30        if (typeof error == "string") {
     31            assert_throws_dom(error, func);
     32        } else {
     33            assert_throws_js(error, func);
     34        }
     35    }
     36 
     37    function checkValues(invalidValues, exception) {
     38        for (var value of invalidValues) {
     39            assert_throws_something(exception, function() { region.viewportAnchorX = value; });
     40            assert_equals(region.viewportAnchorX, 0);
     41            assert_throws_something(exception, function() { region.viewportAnchorY = value; });
     42            assert_equals(region.viewportAnchorY, 100);
     43            assert_throws_something(exception, function() { region.regionAnchorX = value; });
     44            assert_equals(region.regionAnchorX, 0);
     45            assert_throws_something(exception, function() { region.regionAnchorY = value; });
     46            assert_equals(region.regionAnchorY, 100);
     47            assert_throws_something(exception, function() { region.width = value; });
     48            assert_equals(region.width, 100);
     49        }
     50    }
     51 
     52    assert_equals(region.lines, 3);
     53 
     54    region.lines = 130;
     55    assert_equals(region.lines, 130);
     56    region.viewportAnchorX = 64;
     57    assert_equals(region.viewportAnchorX, 64);
     58    region.viewportAnchorY = 32;
     59    assert_equals(region.viewportAnchorY, 32);
     60    region.regionAnchorX = 16;
     61    assert_equals(region.regionAnchorX, 16);
     62    region.regionAnchorY = 8;
     63    assert_equals(region.regionAnchorY, 8);
     64    region.width = 42;
     65    assert_equals(region.width, 42);
     66 }, document.title + " mutations");
     67 </script>