OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Geometry Interfaces: DOMMatrix</title> | 4 <title>Geometry Interfaces: DOMMatrix</title> |
5 <script src="../../resources/js-test.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
| 6 <script src="../../resources/testharnessreport.js"></script> |
6 </head> | 7 </head> |
7 <body> | 8 <body> |
8 <script> | 9 <script> |
9 | 10 |
10 debug("# DOMMatrix()"); | 11 test(function() { |
11 var matrix = new DOMMatrix(); | 12 var matrix = new DOMMatrix(); |
12 shouldBe("matrix.a", "matrix.m11"); | 13 assert_equals(matrix.m11, 1); |
13 shouldBe("matrix.b", "matrix.m12"); | 14 assert_equals(matrix.m12, 0); |
14 shouldBe("matrix.c", "matrix.m21"); | 15 assert_equals(matrix.m13, 0); |
15 shouldBe("matrix.d", "matrix.m22"); | 16 assert_equals(matrix.m14, 0); |
16 shouldBe("matrix.e", "matrix.m41"); | 17 assert_equals(matrix.m21, 0); |
17 shouldBe("matrix.f", "matrix.m42"); | 18 assert_equals(matrix.m22, 1); |
18 shouldBe("matrix.m11", "1"); | 19 assert_equals(matrix.m23, 0); |
19 shouldBe("matrix.m12", "0"); | 20 assert_equals(matrix.m24, 0); |
20 shouldBe("matrix.m13", "0"); | 21 assert_equals(matrix.m31, 0); |
21 shouldBe("matrix.m14", "0"); | 22 assert_equals(matrix.m32, 0); |
22 shouldBe("matrix.m21", "0"); | 23 assert_equals(matrix.m33, 1); |
23 shouldBe("matrix.m22", "1"); | 24 assert_equals(matrix.m34, 0); |
24 shouldBe("matrix.m23", "0"); | 25 assert_equals(matrix.m41, 0); |
25 shouldBe("matrix.m24", "0"); | 26 assert_equals(matrix.m42, 0); |
26 shouldBe("matrix.m31", "0"); | 27 assert_equals(matrix.m43, 0); |
27 shouldBe("matrix.m32", "0"); | 28 assert_equals(matrix.m44, 1); |
28 shouldBe("matrix.m33", "1"); | 29 assert_true(matrix.is2D); |
29 shouldBe("matrix.m34", "0"); | 30 assert_true(matrix.isIdentity); |
30 shouldBe("matrix.m41", "0"); | 31 }, "DOMMatrix() constructor"); |
31 shouldBe("matrix.m42", "0"); | |
32 shouldBe("matrix.m43", "0"); | |
33 shouldBe("matrix.m44", "1"); | |
34 shouldBeTrue("matrix.is2D"); | |
35 shouldBeTrue("matrix.isIdentity"); | |
36 debug(""); | |
37 | 32 |
38 debug("# DOMMatrix set attributes"); | 33 test(function() { |
39 matrix.a = 10; | 34 var other = new DOMMatrix(); |
40 matrix.b = 20; | 35 other.m11 = 10; |
41 matrix.m24 = 2; | 36 other.m12 = 20; |
42 matrix.m33 = 3; | 37 other.m24 = 2; |
43 matrix.m42 = 3; | 38 other.m33 = 3; |
44 matrix.m44 = 9; | 39 other.m42 = 3; |
45 shouldBe("matrix.a", "matrix.m11"); | 40 other.m44 = 9; |
46 shouldBe("matrix.b", "matrix.m12"); | |
47 shouldBe("matrix.c", "matrix.m21"); | |
48 shouldBe("matrix.d", "matrix.m22"); | |
49 shouldBe("matrix.e", "matrix.m41"); | |
50 shouldBe("matrix.f", "matrix.m42"); | |
51 shouldBe("matrix.m11", "10"); | |
52 shouldBe("matrix.m12", "20"); | |
53 shouldBe("matrix.m13", "0"); | |
54 shouldBe("matrix.m14", "0"); | |
55 shouldBe("matrix.m21", "0"); | |
56 shouldBe("matrix.m22", "1"); | |
57 shouldBe("matrix.m23", "0"); | |
58 shouldBe("matrix.m24", "2"); | |
59 shouldBe("matrix.m31", "0"); | |
60 shouldBe("matrix.m32", "0"); | |
61 shouldBe("matrix.m33", "3"); | |
62 shouldBe("matrix.m34", "0"); | |
63 shouldBe("matrix.m41", "0"); | |
64 shouldBe("matrix.m42", "3"); | |
65 shouldBe("matrix.m43", "0"); | |
66 shouldBe("matrix.m44", "9"); | |
67 shouldBeFalse("matrix.is2D"); | |
68 shouldBeFalse("matrix.isIdentity"); | |
69 debug(""); | |
70 | 41 |
71 debug("# DOMMatrix(other)"); | 42 var matrix = new DOMMatrix(other); |
72 var other = matrix; | 43 assert_equals(matrix.m11, 10); |
73 matrix = new DOMMatrix(other); | 44 assert_equals(matrix.m12, 20); |
74 shouldBe("matrix.a", "matrix.m11"); | 45 assert_equals(matrix.m13, 0); |
75 shouldBe("matrix.b", "matrix.m12"); | 46 assert_equals(matrix.m14, 0); |
76 shouldBe("matrix.c", "matrix.m21"); | 47 assert_equals(matrix.m21, 0); |
77 shouldBe("matrix.d", "matrix.m22"); | 48 assert_equals(matrix.m22, 1); |
78 shouldBe("matrix.e", "matrix.m41"); | 49 assert_equals(matrix.m23, 0); |
79 shouldBe("matrix.f", "matrix.m42"); | 50 assert_equals(matrix.m24, 2); |
80 shouldBe("matrix.m11", "10"); | 51 assert_equals(matrix.m31, 0); |
81 shouldBe("matrix.m12", "20"); | 52 assert_equals(matrix.m32, 0); |
82 shouldBe("matrix.m13", "0"); | 53 assert_equals(matrix.m33, 3); |
83 shouldBe("matrix.m14", "0"); | 54 assert_equals(matrix.m34, 0); |
84 shouldBe("matrix.m21", "0"); | 55 assert_equals(matrix.m41, 0); |
85 shouldBe("matrix.m22", "1"); | 56 assert_equals(matrix.m42, 3); |
86 shouldBe("matrix.m23", "0"); | 57 assert_equals(matrix.m43, 0); |
87 shouldBe("matrix.m24", "2"); | 58 assert_equals(matrix.m44, 9); |
88 shouldBe("matrix.m31", "0"); | 59 assert_false(matrix.is2D); |
89 shouldBe("matrix.m32", "0"); | 60 assert_false(matrix.isIdentity); |
90 shouldBe("matrix.m33", "3"); | 61 }, "DOMMatrix(other) constructor"); |
91 shouldBe("matrix.m34", "0"); | |
92 shouldBe("matrix.m41", "0"); | |
93 shouldBe("matrix.m42", "3"); | |
94 shouldBe("matrix.m43", "0"); | |
95 shouldBe("matrix.m44", "9"); | |
96 shouldBeFalse("matrix.is2D"); | |
97 shouldBeFalse("matrix.isIdentity"); | |
98 debug(""); | |
99 | 62 |
100 debug("# DOMMatrix.is2D can never be set to 'true' when it was set to 'false' be
fore calling setMatrixValue()."); | 63 test(function() { |
101 matrix = new DOMMatrix(); | 64 var matrix = new DOMMatrix(); |
102 shouldBeTrue("matrix.is2D"); | 65 matrix.a = 10; |
103 shouldBeTrue("matrix.isIdentity"); | 66 matrix.b = 20; |
104 matrix.m31 = 1; | 67 matrix.m24 = 2; |
105 matrix.m33 = 0; | 68 matrix.m33 = 3; |
106 shouldBeFalse("matrix.is2D"); | 69 matrix.m42 = 3; |
107 shouldBeFalse("matrix.isIdentity"); | 70 matrix.m44 = 9; |
108 matrix.m31 = 0; | 71 assert_equals(matrix.a, matrix.m11); |
109 matrix.m33 = 1; | 72 assert_equals(matrix.b, matrix.m12); |
110 shouldBeFalse("matrix.is2D"); | 73 assert_equals(matrix.c, matrix.m21); |
111 shouldBeTrue("matrix.isIdentity"); | 74 assert_equals(matrix.d, matrix.m22); |
112 debug(""); | 75 assert_equals(matrix.e, matrix.m41); |
| 76 assert_equals(matrix.f, matrix.m42); |
| 77 assert_equals(matrix.m11, 10); |
| 78 assert_equals(matrix.m12, 20); |
| 79 assert_equals(matrix.m13, 0); |
| 80 assert_equals(matrix.m14, 0); |
| 81 assert_equals(matrix.m21, 0); |
| 82 assert_equals(matrix.m22, 1); |
| 83 assert_equals(matrix.m23, 0); |
| 84 assert_equals(matrix.m24, 2); |
| 85 assert_equals(matrix.m31, 0); |
| 86 assert_equals(matrix.m32, 0); |
| 87 assert_equals(matrix.m33, 3); |
| 88 assert_equals(matrix.m34, 0); |
| 89 assert_equals(matrix.m41, 0); |
| 90 assert_equals(matrix.m42, 3); |
| 91 assert_equals(matrix.m43, 0); |
| 92 assert_equals(matrix.m44, 9); |
| 93 assert_false(matrix.is2D); |
| 94 assert_false(matrix.isIdentity); |
| 95 }, "DOMMatrix attributes"); |
| 96 |
| 97 test(function() { |
| 98 var matrix = new DOMMatrix(); |
| 99 assert_true(matrix.is2D); |
| 100 assert_true(matrix.isIdentity); |
| 101 matrix.m31 = 1; |
| 102 matrix.m33 = 0; |
| 103 assert_false(matrix.is2D); |
| 104 assert_false(matrix.isIdentity); |
| 105 matrix.m31 = 0; |
| 106 matrix.m33 = 1; |
| 107 assert_false(matrix.is2D); |
| 108 assert_true(matrix.isIdentity); |
| 109 }, "DOMMatrix.is2D can never be set to 'true' when it was set to 'false' before
calling setMatrixValue()."); |
113 | 110 |
114 </script> | 111 </script> |
115 </body> | 112 </body> |
116 </html> | 113 </html> |
OLD | NEW |