tor-browser

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

DOMMatrix-attributes.html (2422B)


      1 <!DOCTYPE html>
      2 <title>Geometry Interfaces: DOMMatrix attributes</title>
      3 <link rel="help" href="https://drafts.fxtf.org/geometry/#dommatrix-attributes">
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script>
      7 const initial = {
      8    a: 1, b: 0, c: 0, d: 1, e: 0, f: 0,
      9    m11: 1, m12: 0, m13: 0, m14: 0,
     10    m21: 0, m22: 1, m23: 0, m24: 0,
     11    m31: 0, m32: 0, m33: 1, m34: 0,
     12    m41: 0, m42: 0, m43: 0, m44: 1,
     13 };
     14 
     15 // Attributes that always preserve is2D.
     16 ["a", "b", "c", "d", "e", "f",
     17 "m11", "m12", "m21", "m22", "m41", "m42" ].forEach(attribute => {
     18    test(() => {
     19        let m = new DOMMatrix();
     20        assert_true(m.is2D);
     21        assert_equals(m[attribute], initial[attribute]);
     22        m[attribute] = 42;
     23        assert_true(m.is2D);
     24        assert_equals(m[attribute], 42);
     25    }, `DOMMatrix.${attribute}`);
     26 });
     27 
     28 // Attributes that clear is2D for values other than 0 or -0.
     29 ["m13", "m14", "m23", "m24", "m31", "m32", "m34", "m43" ].forEach(attribute => {
     30    test(() => {
     31        let m = new DOMMatrix();
     32        assert_true(m.is2D);
     33        assert_equals(m[attribute], initial[attribute]);
     34        m[attribute] = 0;
     35        assert_true(m.is2D, "0 preserves is2D");
     36        assert_equals(m[attribute], 0);
     37        m[attribute] = -0;
     38        assert_true(m.is2D, "-0 preserves is2D");
     39        assert_equals(m[attribute], -0);
     40        m[attribute] = 42;
     41        assert_false(m.is2D, "a value other than 0 or -0 clears is2D");
     42        assert_equals(m[attribute], 42);
     43        m[attribute] = 0;
     44        assert_false(m.is2D, "is2D can never be set to true after having been set to false");
     45        assert_equals(m[attribute], 0);
     46    }, `DOMMatrix.${attribute}`);
     47 });
     48 
     49 // Attributes that clear is2D for values other than 1.
     50 ["m33", "m44" ].forEach(attribute => {
     51    test(() => {
     52        let m = new DOMMatrix();
     53        assert_true(m.is2D);
     54        assert_equals(m[attribute], initial[attribute]);
     55        m[attribute] = 1;
     56        assert_true(m.is2D, "1 preserves is2D");
     57        assert_equals(m[attribute], 1);
     58        m[attribute] = 42;
     59        assert_false(m.is2D, "a value other than 1 clears is2D");
     60        assert_equals(m[attribute], 42);
     61        m[attribute] = 1;
     62        assert_false(m.is2D, "is2D can never be set to true after having been set to false");
     63        assert_equals(m[attribute], 1);
     64    }, `DOMMatrix.${attribute}`);
     65 });
     66 </script>