Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Side by Side Diff: third_party/WebKit/LayoutTests/typedcssom/cssScale.html

Issue 2942653002: [css-typed-om] remove asMatrix() method in CSSTransformComponent.idl (Closed)
Patch Set: rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
4 4
5 <script> 5 <script>
6 var EPSILON = 1e-6; // float epsilon 6 var EPSILON = 1e-6; // float epsilon
7 var values = [ 7 var values = [
8 {input: new CSSScale(0, 0), x: 0, y: 0, z: 1, is2D: true, 8 {input: new CSSScale(0, 0), x: 0, y: 0, z: 1, is2D: true,
9 cssText: "scale(0, 0)"}, 9 cssText: "scale(0, 0)"},
10 {input: new CSSScale(1, 2), x: 1, y: 2, z: 1, is2D: true, 10 {input: new CSSScale(1, 2), x: 1, y: 2, z: 1, is2D: true,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 assert_throws(new TypeError(), () => { new CSSScale(undefined, undefined, 0); }); 67 assert_throws(new TypeError(), () => { new CSSScale(undefined, undefined, 0); });
68 assert_throws(new TypeError(), () => { new CSSScale(NaN, undefined, 0); }); 68 assert_throws(new TypeError(), () => { new CSSScale(NaN, undefined, 0); });
69 assert_throws(new TypeError(), () => { new CSSScale(NaN, 0, NaN); }); 69 assert_throws(new TypeError(), () => { new CSSScale(NaN, 0, NaN); });
70 assert_throws(new TypeError(), () => { new CSSScale(0, "hello", "world"); }); 70 assert_throws(new TypeError(), () => { new CSSScale(0, "hello", "world"); });
71 assert_throws(new TypeError(), () => { new CSSScale(0, {}, {}); }); 71 assert_throws(new TypeError(), () => { new CSSScale(0, {}, {}); });
72 assert_throws(new TypeError(), () => { new CSSScale({}, {}, {}); }); 72 assert_throws(new TypeError(), () => { new CSSScale({}, {}, {}); });
73 assert_throws(new TypeError(), () => { new CSSScale(NaN, NaN, NaN); }); 73 assert_throws(new TypeError(), () => { new CSSScale(NaN, NaN, NaN); });
74 }, "Test that invalid input throws an exception."); 74 }, "Test that invalid input throws an exception.");
75 75
76 test(function() { 76 test(function() {
77 for (var i = 0; i < values.length; ++i) {
78 var input = values[i].input;
79 var inputAsMatrix = input.asMatrix();
80 assert_equals(inputAsMatrix.is2D(), input.is2D());
81
82 var expectedMatrix = input.is2D() ? new CSSMatrixComponent(new DOMMatrixRead Only([input.x, 0, 0, input.y, 0, 0])) :
83 new CSSMatrixComponent(new DOMMatrixReadOnly([input.x, 0, 0, 0, 0, input .y, 0, 0, 0, 0, input.z, 0, 0, 0, 0, 1]));
84 for (var attribute in expectedMatrix) {
85 if (attribute == "matrix") {
86 assert_matrix_approx_equals(inputAsMatrix[attribute], expectedMatrix[att ribute]);
87 } else {
88 assert_equals(inputAsMatrix[attribute], expectedMatrix[attribute]);
89 }
90 }
91 }
92 }, "Test that asMatrix is constructed correctly for CSSScale.");
93
94 test(function() {
95 var actual = new CSSScale(0, 0, 0); 77 var actual = new CSSScale(0, 0, 0);
96 actual.x = 1; 78 actual.x = 1;
97 actual.y = 2; 79 actual.y = 2;
98 actual.z = 3; 80 actual.z = 3;
99 assert_equals(actual.x, 1); 81 assert_equals(actual.x, 1);
100 assert_equals(actual.y, 2); 82 assert_equals(actual.y, 2);
101 assert_equals(actual.z, 3); 83 assert_equals(actual.z, 3);
102 }, "Test that x, y, z are mutable attributes."); 84 }, "Test that x, y, z are mutable attributes.");
103 85
104 function assert_array_approx_equals(actual, expected) { 86 function assert_array_approx_equals(actual, expected) {
105 for (var i = 0; i < actual.length; i++) { 87 for (var i = 0; i < actual.length; i++) {
106 assert_approx_equals(actual[i], expected[i], EPSILON); 88 assert_approx_equals(actual[i], expected[i], EPSILON);
107 } 89 }
108 } 90 }
109 91
110 function assert_matrix_approx_equals(actual, expected) { 92 function assert_matrix_approx_equals(actual, expected) {
111 assert_array_approx_equals(actual.toFloat64Array(), expected.toFloat64Array()) ; 93 assert_array_approx_equals(actual.toFloat64Array(), expected.toFloat64Array()) ;
112 } 94 }
113 </script> 95 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698