tor-browser

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

DOMPoint-002.html (8862B)


      1 <!DOCTYPE html>
      2 <html><head>
      3    <title>Geometry Interfaces: DOMPoint and DOMPointReadOnly interface tests</title>
      4    <link href="mailto:hs1217.lee@samsung.com" rel="author" title="Hwanseung Lee">
      5    <link href="https://drafts.fxtf.org/geometry-1/#DOMPoint" rel="help">
      6    <script src="/resources/testharness.js"></script>
      7    <script src="/resources/testharnessreport.js"></script>
      8 </head>
      9 <body>
     10    <p>Test DOMPoint and DOMPointReadOnly interfaces</p>
     11    <div id="log"></div>
     12    <script>
     13        function getMatrixTransform(matrix, point) {
     14            var x = point.x * matrix.m11 + point.y * matrix.m21 + point.z * matrix.m31 + point.w * matrix.m41;
     15            var y = point.x * matrix.m12 + point.y * matrix.m22 + point.z * matrix.m32 + point.w * matrix.m42;
     16            var w = point.x * matrix.m13 + point.y * matrix.m23 + point.z * matrix.m33 + point.w * matrix.m43;
     17            var z = point.x * matrix.m14 + point.y * matrix.m24 + point.z * matrix.m34 + point.w * matrix.m44;
     18            return new DOMPoint(x, y, w, z)
     19        }
     20 
     21        test(function() {
     22            checkDOMPoint(new DOMPoint(), {x:0, y:0, z:0, w:1});
     23        },'test DOMPoint Constructor no args');
     24        test(function() {
     25            checkDOMPoint(new DOMPoint(1), {x:1, y:0, z:0, w:1});
     26        },'test DOMPoint Constructor one args');
     27        test(function() {
     28            checkDOMPoint(new DOMPoint(1, 2), {x:1, y:2, z:0, w:1});
     29        },'test DOMPoint Constructor two args');
     30        test(function() {
     31            checkDOMPoint(new DOMPoint(1, 2, 3), {x:1, y:2, z:3, w:1});
     32        },'test DOMPoint Constructor three args');
     33        test(function() {
     34            checkDOMPoint(new DOMPoint(1, 2, 3, 4), {x:1, y:2, z:3, w:4});
     35        },'test DOMPoint Constructor four args');
     36        test(function() {
     37            checkDOMPoint(new DOMPoint(1, 2, 3, 4, 5), {x:1, y:2, z:3, w:4});
     38        },'test DOMPoint Constructor more then four args');
     39        test(function() {
     40            checkDOMPoint(new DOMPoint(1, undefined), {x:1, y:0, z:0, w:1});
     41        },'test DOMPoint Constructor with undefined');
     42        test(function() {
     43            checkDOMPoint(new DOMPoint("a", "b"), {x:NaN, y:NaN, z:0, w:1});
     44        },'test DOMPoint Constructor with string');
     45        test(function() {
     46            checkDOMPoint(new DOMPoint({}), {x:NaN, y:0, z:0, w:1});
     47        },'test DOMPoint Constructor with empty object');
     48        test(function() {
     49            checkDOMPoint(DOMPoint.fromPoint({}), {x:0, y:0, z:0, w:1});
     50        },'test DOMPoint fromPoint with empty object');
     51        test(function() {
     52            checkDOMPoint(DOMPoint.fromPoint({x:1}), {x:1, y:0, z:0, w:1});
     53        },'test DOMPoint fromPoint with x');
     54        test(function() {
     55            checkDOMPoint(DOMPoint.fromPoint({x:1, y:2}), {x:1, y:2, z:0, w:1});
     56        },'test DOMPoint fromPoint with x, y');
     57        test(function() {
     58            checkDOMPoint(DOMPoint.fromPoint({x:1, y:2, z:3}), {x:1, y:2, z:3, w:1});
     59        },'test DOMPoint fromPoint with x, y, z');
     60        test(function() {
     61            checkDOMPoint(DOMPoint.fromPoint({x:1, y:2, z:3, w:4}), {x:1, y:2, z:3, w:4});
     62        },'test DOMPoint fromPoint with x, y, z, w');
     63        test(function() {
     64            checkDOMPoint(DOMPoint.fromPoint({x:1, y:2, z:3, w:4, v:5}), {x:1, y:2, z:3, w:4});
     65        },'test DOMPoint fromPoint with x, y, z, w, v');
     66        test(function() {
     67            checkDOMPoint(DOMPoint.fromPoint({x:1, z:3}), {x:1, y:0, z:3, w:1});
     68        },'test DOMPoint fromPoint with x, z');
     69        test(function() {
     70            checkDOMPoint(DOMPoint.fromPoint({x:1, y: undefined, z:3}), {x:1, y:0, z:3, w:1});
     71        },'test DOMPoint fromPoint with undefined value');
     72        test(function() {
     73            var point = new DOMPoint(5, 4);
     74            var matrix = new DOMMatrix([2, 0, 0, 2, 10, 10]);
     75            var result = point.matrixTransform(matrix);
     76            var expected = getMatrixTransform(matrix, point);
     77            checkDOMPoint(result, expected);
     78        },'test DOMPoint matrixTransform');
     79        test(function() {
     80            var point = new DOMPoint(42, 84);
     81            assert_throws_js(TypeError, function() {
     82              point.matrixTransform({ is2D: true, m33: 1.0000001 });
     83            });
     84        },'test DOMPoint matrixTransform with inconsistent input');
     85        test(function() {
     86            var p = new DOMPoint(0, 0, 0, 1);
     87            p.x = undefined;
     88            p.y = undefined;
     89            p.z = undefined;
     90            p.w = undefined;
     91            checkDOMPoint(p, {x:NaN, y:NaN, z:NaN, w:NaN});
     92        },'test DOMPoint Attributes undefined');
     93        test(function() {
     94            var p = new DOMPoint(0, 0, 0, 1);
     95            p.x = NaN;
     96            p.y = Number.POSITIVE_INFINITY;
     97            p.z = Number.NEGATIVE_INFINITY;
     98            p.w = Infinity;
     99            checkDOMPoint(p, {x:NaN, y:Infinity, z:-Infinity, w:Infinity});
    100        },'test DOMPoint Attributes NaN Infinity');
    101        test(function() {
    102            checkDOMPoint(new DOMPointReadOnly(), {x:0, y:0, z:0, w:1});
    103        },'test DOMPointReadOnly Constructor no args');
    104        test(function() {
    105            checkDOMPoint(new DOMPointReadOnly(1), {x:1, y:0, z:0, w:1});
    106        },'test DOMPointReadOnly Constructor one args');
    107        test(function() {
    108            checkDOMPoint(new DOMPointReadOnly(1, 2), {x:1, y:2, z:0, w:1});
    109        },'test DOMPointReadOnly Constructor two args');
    110        test(function() {
    111            checkDOMPoint(new DOMPointReadOnly(1, 2, 3), {x:1, y:2, z:3, w:1});
    112        },'test DOMPointReadOnly Constructor three args');
    113        test(function() {
    114            checkDOMPoint(new DOMPointReadOnly(1, 2, 3, 4), {x:1, y:2, z:3, w:4});
    115        },'test DOMPointReadOnly Constructor four args');
    116        test(function() {
    117            checkDOMPoint(new DOMPointReadOnly(1, 2, 3, 4, 5), {x:1, y:2, z:3, w:4});
    118        },'test DOMPointReadOnly Constructor more then four args');
    119        test(function() {
    120            checkDOMPoint(new DOMPointReadOnly(1, undefined), {x:1, y:0, z:0, w:1});
    121        },'test DOMPointReadOnly Constructor with undefined');
    122        test(function() {
    123            checkDOMPoint(new DOMPointReadOnly("a", "b"), {x:NaN, y:NaN, z:0, w:1});
    124        },'test DOMPointReadOnly Constructor with string');
    125        test(function() {
    126            checkDOMPoint(new DOMPointReadOnly({}), {x:NaN, y:0, z:0, w:1});
    127        },'test DOMPointReadOnly Constructor with object');
    128        test(function() {
    129            checkDOMPoint(DOMPointReadOnly.fromPoint({}), {x:0, y:0, z:0, w:1});
    130        },'test DOMPointReadOnly fromPoint with empty object');
    131        test(function() {
    132            checkDOMPoint(DOMPointReadOnly.fromPoint({x:1}), {x:1, y:0, z:0, w:1});
    133        },'test DOMPointReadOnly fromPoint with x');
    134        test(function() {
    135            checkDOMPoint(DOMPointReadOnly.fromPoint({x:1, y:2}), {x:1, y:2, z:0, w:1});
    136        },'test DOMPointReadOnly fromPoint with x, y');
    137        test(function() {
    138            checkDOMPoint(DOMPointReadOnly.fromPoint({x:1, y:2, z:3}), {x:1, y:2, z:3, w:1});
    139        },'test DOMPointReadOnly fromPoint with x, y, z');
    140        test(function() {
    141            checkDOMPoint(DOMPointReadOnly.fromPoint({x:1, y:2, z:3, w:4}), {x:1, y:2, z:3, w:4});
    142        },'test DOMPointReadOnly fromPoint with x, y, z, w');
    143        test(function() {
    144            checkDOMPoint(DOMPointReadOnly.fromPoint({x:1, y:2, z:3, w:4, v:5}), {x:1, y:2, z:3, w:4});
    145        },'test DOMPointReadOnly fromPoint with x, y, z, w, v');
    146        test(function() {
    147            checkDOMPoint(DOMPointReadOnly.fromPoint({x:1, z:3}), {x:1, y:0, z:3, w:1});
    148        },'test DOMPointReadOnly fromPoint with x, z');
    149        test(function() {
    150            checkDOMPoint(DOMPointReadOnly.fromPoint({x:1, y: undefined, z:3}), {x:1, y:0, z:3, w:1});
    151        },'test DOMPointReadOnly fromPoint with undefined value');
    152        test(function() {
    153            var point = new DOMPointReadOnly(5, 4);
    154            var matrix = new DOMMatrix([1, 2, 3, 4, 5, 6]);
    155            var result = point.matrixTransform(matrix);
    156            var expected = getMatrixTransform(matrix, point);
    157            checkDOMPoint(result, expected);
    158        },'test DOMPointReadOnly matrixTransform');
    159        test(function() {
    160            var p = new DOMPointReadOnly(0, 0, 0, 1);
    161            p.x = undefined;
    162            p.y = undefined;
    163            p.z = undefined;
    164            p.w = undefined;
    165            checkDOMPoint(p, {x:0, y:0, z:0, w:1});
    166        },'test DOMPointReadOnly Attributes undefined');
    167 
    168        function checkDOMPoint(p, exp) {
    169            assert_equals(p.x, exp.x, "x is not matched");
    170            assert_equals(p.y, exp.y, "y is not matched");
    171            assert_equals(p.z, exp.z, "z is not matched");
    172            assert_equals(p.w, exp.w, "w is not matched");
    173        }
    174    </script>
    175 
    176 
    177 </body></html>