Index: third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-setMatrixValue.html |
diff --git a/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-setMatrixValue.html b/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-setMatrixValue.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..504e01136d49ab6ac7ba459ceca8651d566f4826 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-setMatrixValue.html |
@@ -0,0 +1,226 @@ |
+<!DOCTYPE HTML> |
+<script src="../../resources/testharness.js"></script> |
+<script src="../../resources/testharnessreport.js"></script> |
+<script src="./resources/geometry-interfaces-test-helpers.js"></script> |
+<script> |
+ |
+test(() => { |
+ var actualMatrix1 = new DOMMatrix([1, 2, 3, 4, 5, 6]); |
+ var actualMatrix2 = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); |
+ var expectedMatrix = new DOMMatrix(); |
+ actualMatrix1.setMatrixValue(""); |
+ assert_true(actualMatrix1.is2D); |
+ assert_matrix_almost_equals(actualMatrix1, expectedMatrix); |
+ actualMatrix2.setMatrixValue(""); |
+ assert_true(actualMatrix2.is2D); |
+ assert_matrix_almost_equals(actualMatrix2, expectedMatrix); |
+}, "DOMMatrix setMatrix(EmptyString)"); |
+ |
+test(() => { |
+ var actualMatrix1 = new DOMMatrix([1, 2, 3, 4, 5, 6]); |
+ var actualMatrix2 = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); |
+ var expectedMatrix1 = new DOMMatrix([1, 2, 3, 4, 5, 6]); |
+ var expectedMatrix2 = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); |
+ actualMatrix1.setMatrixValue("none"); |
+ assert_true(actualMatrix1.is2D); |
+ assert_matrix_almost_equals(actualMatrix1, expectedMatrix1); |
+ actualMatrix2.setMatrixValue("none"); |
+ assert_false(actualMatrix2.is2D); |
Timothy Loh
2016/10/25 04:48:01
I would've expected that setting none makes the ma
Hwanseung Lee
2016/10/26 14:51:43
i fixed a code.
result matrix becoming the identit
|
+ assert_matrix_almost_equals(actualMatrix2, expectedMatrix2); |
+}, "DOMMatrix setMatrix('none')"); |
+ |
+test(() => { |
+ var matrix = new DOMMatrix(); |
+ var expectedMatrix = new DOMMatrix(); |
+ matrix.setMatrixValue("matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)"); |
+ assert_true(matrix.is2D); |
+ expectedMatrix.multiplySelf(new DOMMatrix([1.0, 2.0, 3.0, 4.0, 5.0, 6.0])) |
+ assert_matrix_almost_equals(matrix, expectedMatrix); |
+}, "DOMMatrix setMatrix('matrix')"); |
+ |
+test(() => { |
+ var matrix = new DOMMatrix(); |
+ var expectedMatrix = new DOMMatrix(); |
+ matrix.setMatrixValue("translate(44px, 55px)"); |
+ assert_true(matrix.is2D); |
+ expectedMatrix.translateSelf(44, 55) |
+ assert_matrix_almost_equals(matrix, expectedMatrix); |
+}, "DOMMatrix setMatrix('translate')"); |
+ |
+test(() => { |
+ var matrix = new DOMMatrix(); |
+ var expectedMatrix = new DOMMatrix(); |
+ matrix.setMatrixValue("translateX(35px)"); |
+ assert_true(matrix.is2D); |
+ expectedMatrix.translateSelf(35, 0) |
+ assert_matrix_almost_equals(matrix, expectedMatrix); |
+}, "DOMMatrix setMatrix('translateX')"); |
+ |
+test(() => { |
+ var matrix = new DOMMatrix(); |
+ var expectedMatrix = new DOMMatrix(); |
+ matrix.setMatrixValue("translateY(77px)"); |
+ assert_true(matrix.is2D); |
+ expectedMatrix.translateSelf(0, 77) |
+ assert_matrix_almost_equals(matrix, expectedMatrix); |
+}, "DOMMatrix setMatrix('translateY')"); |
+ |
+test(() => { |
+ var matrix = new DOMMatrix(); |
+ var expectedMatrix = new DOMMatrix(); |
+ matrix.setMatrixValue("scale(2, 2)"); |
+ assert_true(matrix.is2D); |
+ expectedMatrix.scaleSelf(2, 2); |
+ assert_matrix_almost_equals(matrix, expectedMatrix); |
+}, "DOMMatrix setMatrix('scale')"); |
+ |
+test(() => { |
+ var matrix = new DOMMatrix(); |
+ var expectedMatrix = new DOMMatrix(); |
+ matrix.setMatrixValue("scaleX(2)"); |
+ assert_true(matrix.is2D); |
+ expectedMatrix.scaleSelf(2, 1); |
+ assert_matrix_almost_equals(matrix, expectedMatrix); |
+}, "DOMMatrix setMatrix('scaleX')"); |
+ |
+test(() => { |
+ var matrix = new DOMMatrix(); |
+ var expectedMatrix = new DOMMatrix(); |
+ matrix.setMatrixValue("scaleY(2)"); |
+ assert_true(matrix.is2D); |
+ expectedMatrix.scaleSelf(1, 2); |
+ assert_matrix_almost_equals(matrix, expectedMatrix); |
+}, "DOMMatrix setMatrix('scaleY')"); |
+ |
+test(() => { |
+ var matrix = new DOMMatrix(); |
+ var expectedMatrix = new DOMMatrix(); |
+ matrix.setMatrixValue("rotate(90deg)"); |
+ assert_true(matrix.is2D); |
+ expectedMatrix.rotateAxisAngleSelf(0, 0, 1, 90); |
+ assert_matrix_almost_equals(matrix, expectedMatrix); |
+}, "DOMMatrix setMatrix('rotate')"); |
+ |
+test(() => { |
+ var matrix = new DOMMatrix(); |
+ var expectedMatrix = new DOMMatrix(); |
+ matrix.setMatrixValue("skewX(30deg)"); |
+ assert_true(matrix.is2D); |
+ expectedMatrix.skewXSelf(30); |
+ assert_matrix_almost_equals(matrix, expectedMatrix); |
+}, "DOMMatrix setMatrix('skewX')"); |
+ |
+test(() => { |
+ var matrix = new DOMMatrix(); |
+ var expectedMatrix = new DOMMatrix(); |
+ matrix.setMatrixValue("skewY(40deg)"); |
+ assert_true(matrix.is2D); |
+ expectedMatrix.skewYSelf(40); |
+ assert_matrix_almost_equals(matrix, expectedMatrix); |
+}, "DOMMatrix setMatrix('skewY')"); |
+ |
+test(() => { |
+ var matrix = new DOMMatrix(); |
+ var expectedMatrix = new DOMMatrix(); |
+ matrix.setMatrixValue("matrix3d(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0)"); |
+ assert_false(matrix.is2D); |
+ expectedMatrix.multiplySelf(new DOMMatrix([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0])) |
+ assert_matrix_almost_equals(matrix, expectedMatrix); |
+}, "DOMMatrix setMatrix(matrix3d)"); |
+ |
+test(() => { |
+ var matrix = new DOMMatrix(); |
+ var expectedMatrix = new DOMMatrix(); |
+ matrix.setMatrixValue("translate3d(10px, 20px, 30px)"); |
+ assert_false(matrix.is2D); |
+ expectedMatrix.translateSelf(10, 20, 30) |
+ assert_matrix_almost_equals(matrix, expectedMatrix); |
+}, "DOMMatrix setMatrix(translate3d)"); |
+ |
+test(() => { |
+ var matrix = new DOMMatrix(); |
+ var expectedMatrix = new DOMMatrix(); |
+ matrix.setMatrixValue("translateZ(88px)"); |
+ assert_false(matrix.is2D); |
+ expectedMatrix.translateSelf(0, 0, 88) |
+ assert_matrix_almost_equals(matrix, expectedMatrix); |
+}, "DOMMatrix setMatrix('translateY')"); |
+ |
+test(() => { |
+ var matrix = new DOMMatrix(); |
+ var expectedMatrix = new DOMMatrix(); |
+ matrix.setMatrixValue("matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0) translate(44px, 55px) skewX(30deg)"); |
+ assert_true(matrix.is2D); |
+ expectedMatrix.multiplySelf(new DOMMatrix([1.0, 2.0, 3.0, 4.0, 5.0, 6.0])) |
+ expectedMatrix.translateSelf(44, 55) |
+ expectedMatrix.skewXSelf(30); |
+ assert_matrix_almost_equals(matrix, expectedMatrix); |
+}, "DOMMatrix setMatrix(multiple value)"); |
+ |
+// TODO(hs1217.lee) : calc() function take only absolute unit. should be pass this test. |
+// but calc() function is not supported not yet. |
+// refer to hasRelativeLengths() in TransformBuilder.cpp |
+// test(() => { |
+// var matrix = new DOMMatrix(); |
+// var expectedMatrix = new DOMMatrix(); |
+// matrix.setMatrixValue("translateX(calc(10px + 1px))"); |
+// assert_true(matrix.is2D); |
+// expectedMatrix.translateSelf(11, 0) |
+// assert_matrix_almost_equals(matrix, expectedMatrix); |
+// }, "DOMMatrix setMatrix(multiple value)"); |
+ |
+test(() => { |
+ |
+ var matrix = new DOMMatrix(); |
Timothy Loh
2016/10/25 04:48:01
You should initialise the values in this matrix an
Hwanseung Lee
2016/10/26 14:51:43
Done.
|
+ |
+ assert_throws(new SyntaxError(), () => { |
+ matrix.setMatrixValue("initial"); |
+ }, "CSS-wide keywords are disallowed."); |
+ |
+ assert_throws(new SyntaxError(), () => { |
+ matrix.setMatrixValue("notExistFunction()"); |
+ }, "can't parse not exist function."); |
+ |
+ assert_throws(new SyntaxError(), () => { |
+ matrix.setMatrixValue("translateY(50%)"); |
+ }, "Can't parse without absolute unit."); |
+ |
+ assert_throws(new SyntaxError(), () => { |
+ matrix.setMatrixValue("translateX(1.2em)"); |
+ }, "Can't parse without absolute unit."); |
+ |
+ assert_throws(new SyntaxError(), () => { |
+ matrix.setMatrixValue("translateX(10ex)"); |
+ }, "Can't parse without absolute unit."); |
+ |
+ assert_throws(new SyntaxError(), () => { |
+ matrix.setMatrixValue("translateX(10ch)"); |
+ }, "Can't parse without absolute unit."); |
+ |
+ assert_throws(new SyntaxError(), () => { |
+ matrix.setMatrixValue("translateX(10rem)"); |
+ }, "Can't parse without absolute unit."); |
+ |
+ assert_throws(new SyntaxError(), () => { |
+ matrix.setMatrixValue("translateX(10vw)"); |
+ }, "Can't parse without absolute unit."); |
+ |
+ assert_throws(new SyntaxError(), () => { |
+ matrix.setMatrixValue("translateX(10vh)"); |
+ }, "Can't parse without absolute unit."); |
+ |
+ assert_throws(new SyntaxError(), () => { |
+ matrix.setMatrixValue("translateX(10vmin)"); |
+ }, "Can't parse without absolute unit."); |
+ |
+ assert_throws(new SyntaxError(), () => { |
+ matrix.setMatrixValue("translateX(10vmax)"); |
+ }, "Can't parse without absolute unit."); |
+ |
+ assert_throws(new SyntaxError(), () => { |
+ matrix.setMatrixValue("translateX(calc(10px + 1em))"); |
+ }, "Can't parse without absolute unit."); |
+ |
+}, "DOMMatrix.setMatrix(): Exception test."); |
+ |
+</script> |