| <!DOCTYPE html> | |
| <title>Geometry Interfaces: DOMMatrix attributes</title> | |
| <link rel="help" href="https://drafts.fxtf.org/geometry/#dommatrix-attributes"> | |
| <script src="/resources/testharness.js"></script> | |
| <script src="/resources/testharnessreport.js"></script> | |
| <script> | |
| const initial = { | |
| a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, | |
| m11: 1, m12: 0, m13: 0, m14: 0, | |
| m21: 0, m22: 1, m23: 0, m24: 0, | |
| m31: 0, m32: 0, m33: 1, m34: 0, | |
| m41: 0, m42: 0, m43: 0, m44: 1, | |
| }; | |
| // Attributes that always preserve is2D. | |
| ["a", "b", "c", "d", "e", "f", | |
| "m11", "m12", "m21", "m22", "m41", "m42" ].forEach(attribute => { | |
| test(() => { | |
| let m = new DOMMatrix(); | |
| assert_true(m.is2D); | |
| assert_equals(m[attribute], initial[attribute]); | |
| m[attribute] = 42; | |
| assert_true(m.is2D); | |
| assert_equals(m[attribute], 42); | |
| }, `DOMMatrix.${attribute}`); | |
| }); | |
| // Attributes that clear is2D for values other than 0 or -0. | |
| ["m13", "m14", "m23", "m24", "m31", "m32", "m34", "m43" ].forEach(attribute => { | |
| test(() => { | |
| let m = new DOMMatrix(); | |
| assert_true(m.is2D); | |
| assert_equals(m[attribute], initial[attribute]); | |
| m[attribute] = 0; | |
| assert_true(m.is2D, "0 preserves is2D"); | |
| assert_equals(m[attribute], 0); | |
| m[attribute] = -0; | |
| assert_true(m.is2D, "-0 preserves is2D"); | |
| assert_equals(m[attribute], -0); | |
| m[attribute] = 42; | |
| assert_false(m.is2D, "a value other than 0 or -0 clears is2D"); | |
| assert_equals(m[attribute], 42); | |
| m[attribute] = 0; | |
| assert_false(m.is2D, "is2D can never be set to true after having been set to false"); | |
| assert_equals(m[attribute], 0); | |
| }, `DOMMatrix.${attribute}`); | |
| }); | |
| // Attributes that clear is2D for values other than 1. | |
| ["m33", "m44" ].forEach(attribute => { | |
| test(() => { | |
| let m = new DOMMatrix(); | |
| assert_true(m.is2D); | |
| assert_equals(m[attribute], initial[attribute]); | |
| m[attribute] = 1; | |
| assert_true(m.is2D, "1 preserves is2D"); | |
| assert_equals(m[attribute], 1); | |
| m[attribute] = 42; | |
| assert_false(m.is2D, "a value other than 1 clears is2D"); | |
| assert_equals(m[attribute], 42); | |
| m[attribute] = 1; | |
| assert_false(m.is2D, "is2D can never be set to true after having been set to false"); | |
| assert_equals(m[attribute], 1); | |
| }, `DOMMatrix.${attribute}`); | |
| }); | |
| </script> |