OLD | NEW |
1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Geometry Interfaces: DOMMatrixReadOnly</title> | 4 <title>Geometry Interfaces: DOMMatrixReadOnly</title> |
5 <script src="../../resources/testharness.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
6 <script src="../../resources/testharnessreport.js"></script> | 6 <script src="../../resources/testharnessreport.js"></script> |
7 </head> | 7 </head> |
8 <body> | 8 <body> |
9 <script> | 9 <script> |
10 test(function() { | 10 test(function() { |
(...skipping 22 matching lines...) Expand all Loading... |
33 assert_equals(matrix3d.m32, 10.1); | 33 assert_equals(matrix3d.m32, 10.1); |
34 assert_equals(matrix3d.m33, 11); | 34 assert_equals(matrix3d.m33, 11); |
35 assert_equals(matrix3d.m34, 12); | 35 assert_equals(matrix3d.m34, 12); |
36 assert_equals(matrix3d.m41, 13); | 36 assert_equals(matrix3d.m41, 13); |
37 assert_equals(matrix3d.m42, 14); | 37 assert_equals(matrix3d.m42, 14); |
38 assert_equals(matrix3d.m43, 15); | 38 assert_equals(matrix3d.m43, 15); |
39 assert_equals(matrix3d.m44, 16.6); | 39 assert_equals(matrix3d.m44, 16.6); |
40 }, "DOMMatrixReadOnly constructor - 3D matrix"); | 40 }, "DOMMatrixReadOnly constructor - 3D matrix"); |
41 | 41 |
42 test(function() { | 42 test(function() { |
| 43 var float32Array = new Float32Array([1, 2, 3, 3, 2, 1]); |
| 44 var matrix2d = DOMMatrixReadOnly.fromFloat32Array(float32Array); |
| 45 assert_true(matrix2d.is2D); |
| 46 assert_equals(matrix2d.a, 1); |
| 47 assert_equals(matrix2d.b, 2); |
| 48 assert_equals(matrix2d.c, 3); |
| 49 assert_equals(matrix2d.d, 3); |
| 50 assert_equals(matrix2d.e, 2); |
| 51 assert_equals(matrix2d.f, 1); |
| 52 }, "DOMMatrixReadOnly fromFloat32Array - 2D matrix"); |
| 53 |
| 54 test(function() { |
| 55 var float64Array = new Float64Array([1, 2, 3, 3.1, 2, 1]); |
| 56 var matrix2d = DOMMatrixReadOnly.fromFloat64Array(float64Array); |
| 57 assert_true(matrix2d.is2D); |
| 58 assert_equals(matrix2d.a, 1); |
| 59 assert_equals(matrix2d.b, 2); |
| 60 assert_equals(matrix2d.c, 3); |
| 61 assert_equals(matrix2d.d, 3.1); |
| 62 assert_equals(matrix2d.e, 2); |
| 63 assert_equals(matrix2d.f, 1); |
| 64 }, "DOMMatrixReadOnly fromFloat64Array - 2D matrix"); |
| 65 |
| 66 test(function() { |
| 67 var float32Array = new Float32Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16]); |
| 68 var matrix3d = DOMMatrixReadOnly.fromFloat32Array(float32Array); |
| 69 assert_false(matrix3d.is2D); |
| 70 assert_equals(matrix3d.m11, 1); |
| 71 assert_equals(matrix3d.m12, 2); |
| 72 assert_equals(matrix3d.m13, 3); |
| 73 assert_equals(matrix3d.m14, 4); |
| 74 assert_equals(matrix3d.m21, 5); |
| 75 assert_equals(matrix3d.m22, 6); |
| 76 assert_equals(matrix3d.m23, 7); |
| 77 assert_equals(matrix3d.m24, 8); |
| 78 assert_equals(matrix3d.m31, 9); |
| 79 assert_equals(matrix3d.m32, 10); |
| 80 assert_equals(matrix3d.m33, 11); |
| 81 assert_equals(matrix3d.m34, 12); |
| 82 assert_equals(matrix3d.m41, 13); |
| 83 assert_equals(matrix3d.m42, 14); |
| 84 assert_equals(matrix3d.m43, 15); |
| 85 assert_equals(matrix3d.m44, 16); |
| 86 }, "DOMMatrixReadOnly fromFloat32Array - 3D matrix"); |
| 87 |
| 88 test(function() { |
| 89 var float64Array = new Float64Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12
, 13, 14, 15, 16.6]); |
| 90 var matrix3d = DOMMatrixReadOnly.fromFloat64Array(float64Array); |
| 91 assert_false(matrix3d.is2D); |
| 92 assert_equals(matrix3d.m11, 1); |
| 93 assert_equals(matrix3d.m12, 2); |
| 94 assert_equals(matrix3d.m13, 3); |
| 95 assert_equals(matrix3d.m14, 4); |
| 96 assert_equals(matrix3d.m21, 5); |
| 97 assert_equals(matrix3d.m22, 6); |
| 98 assert_equals(matrix3d.m23, 7); |
| 99 assert_equals(matrix3d.m24, 8); |
| 100 assert_equals(matrix3d.m31, 9); |
| 101 assert_equals(matrix3d.m32, 10.1); |
| 102 assert_equals(matrix3d.m33, 11); |
| 103 assert_equals(matrix3d.m34, 12); |
| 104 assert_equals(matrix3d.m41, 13); |
| 105 assert_equals(matrix3d.m42, 14); |
| 106 assert_equals(matrix3d.m43, 15); |
| 107 assert_equals(matrix3d.m44, 16.6); |
| 108 }, "DOMMatrixReadOnly fromFloat64Array - 3D matrix"); |
| 109 |
| 110 test(function() { |
43 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 3.1, 2, 1]); | 111 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 3.1, 2, 1]); |
44 assert_true(matrix2d.is2D); | 112 assert_true(matrix2d.is2D); |
45 assert_equals(matrix2d.toString(), "matrix(1, 2, 3, 3.1, 2, 1)"); | 113 assert_equals(matrix2d.toString(), "matrix(1, 2, 3, 3.1, 2, 1)"); |
46 }, "DOMMatrixReadOnly toString() - 2D matrix"); | 114 }, "DOMMatrixReadOnly toString() - 2D matrix"); |
47 | 115 |
48 test(function() { | 116 test(function() { |
49 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 1
2, 13, 14, 15, 16.6]); | 117 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 1
2, 13, 14, 15, 16.6]); |
50 assert_false(matrix3d.is2D); | 118 assert_false(matrix3d.is2D); |
51 assert_equals(matrix3d.toString(), "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1
, 11, 12, 13, 14, 15, 16.6)"); | 119 assert_equals(matrix3d.toString(), "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1
, 11, 12, 13, 14, 15, 16.6)"); |
52 }, "DOMMatrixReadOnly toString() - 3D matrix"); | 120 }, "DOMMatrixReadOnly toString() - 3D matrix"); |
53 | 121 |
54 test(function() { | 122 test(function() { |
55 assert_throws(new TypeError(), function() { new DOMMatrixReadOnly(1, 2, 3, 4
, 5, 6); }, | 123 assert_throws(new TypeError(), function() { new DOMMatrixReadOnly(1, 2, 3, 4
, 5, 6); }, |
56 "DOMMatrixReadOnly constructor only accepts 1 argument"); | 124 "DOMMatrixReadOnly constructor only accepts 1 argument"); |
57 assert_throws(new TypeError(), function() { new DOMMatrixReadOnly("myString"
); }, | 125 assert_throws(new TypeError(), function() { new DOMMatrixReadOnly("myString"
); }, |
58 "DOMMatrixReadOnly constructor only accepts 1 number sequence"); | 126 "DOMMatrixReadOnly constructor only accepts 1 number sequence"); |
59 assert_throws(new TypeError(), function() { new DOMMatrixReadOnly([1, 2, 3])
; }, | 127 assert_throws(new TypeError(), function() { new DOMMatrixReadOnly([1, 2, 3])
; }, |
60 "DOMMatrixReadOnly constructor only accepts 1 number sequence with 6
or 16 elements."); | 128 "DOMMatrixReadOnly constructor only accepts 1 number sequence with 6
or 16 elements."); |
| 129 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat32Arr
ay(new Float32Array(15)); }, |
| 130 "DOMMatrixReadOnly constructor only accepts 1 number sequence with 6
or 16 elements."); |
| 131 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat64Arr
ay(new Float64Array(15)); }, |
| 132 "DOMMatrixReadOnly constructor only accepts 1 number sequence with 6
or 16 elements."); |
61 }, "DOMMatrixReadOnly constructor - invalid arguments"); | 133 }, "DOMMatrixReadOnly constructor - invalid arguments"); |
62 </script> | 134 </script> |
63 </body> | 135 </body> |
64 </html> | 136 </html> |
OLD | NEW |