Index: third_party/WebKit/LayoutTests/typedcssom/cssTransformValue.html |
diff --git a/third_party/WebKit/LayoutTests/typedcssom/cssTransformValue.html b/third_party/WebKit/LayoutTests/typedcssom/cssTransformValue.html |
index 15e5224ce93c49a2b71603c0437c06cb06a98c37..69119fb2a0f7d5eabde47c9759045d7af1ac4251 100644 |
--- a/third_party/WebKit/LayoutTests/typedcssom/cssTransformValue.html |
+++ b/third_party/WebKit/LayoutTests/typedcssom/cssTransformValue.html |
@@ -3,6 +3,7 @@ |
<script src="../resources/testharnessreport.js"></script> |
<script> |
+var EPSILON = 1e-6; // float epsilon |
test(function() { |
var transformValueObject = new CSSTransformValue(); |
@@ -44,4 +45,37 @@ test(function() { |
assert_equals(newTransformArray[2].constructor.name, CSSScale.name); |
}, "CSSTransformValue can iterate through all its all its transformComponent members"); |
+test(function() { |
+ var transformArray = [new CSSScale(2,2)]; |
+ var transformValue = new CSSTransformValue(transformArray); |
+ |
+ var expectedMatrix = new DOMMatrix(); |
+ expectedMatrix.scaleSelf(2, 2); |
+ |
+ assert_matrix_approx_equals(transformValue.toMatrix(), expectedMatrix); |
+}, "toMatrix() returns DOMMatrix Object - single CSSTransformComponent"); |
+ |
+test(function() { |
+ var transformMatrix = new DOMMatrixReadOnly([1,1,1,1,1,1]); |
+ var transformArray = [new CSSScale(2,2) , new CSSMatrixComponent(transformMatrix), new CSSScale(5,6)]; |
+ var transformValue = new CSSTransformValue(transformArray); |
+ |
+ var expectedMatrix = new DOMMatrix(); |
+ expectedMatrix.scaleSelf(2, 2); |
+ expectedMatrix.multiplySelf(transformMatrix); |
+ expectedMatrix.scaleSelf(5, 6); |
+ |
+ assert_matrix_approx_equals(transformValue.toMatrix(), expectedMatrix); |
+}, "toMatrix() returns DOMMatrix Object - multiple CSSTransformComponent"); |
+ |
+function assert_array_approx_equals(actual, expected) { |
+ for (var i = 0; i < actual.length; i++) { |
+ assert_approx_equals(actual[i], expected[i], EPSILON); |
+ } |
+} |
+ |
+function assert_matrix_approx_equals(actual, expected) { |
+ assert_array_approx_equals(actual.toFloat64Array(), expected.toFloat64Array()); |
+} |
+ |
</script> |