Chromium Code Reviews| 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..d5c40ae68edb016e0878b6b31eb2a3d9549d9069 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-setMatrixValue.html |
| @@ -0,0 +1,212 @@ |
| +<!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 matrix = new DOMMatrix(); |
|
Timothy Loh
2016/10/24 04:18:30
I would create two DOMMatrix objects at the start
Hwanseung Lee
2016/10/24 13:23:37
i fixed it follow your comment.
Timothy Loh
2016/10/25 04:48:00
Sorry if I wasn't too clear, what I meant was that
Hwanseung Lee
2016/10/27 16:24:47
actually i don't know your intent correctly.
but i
Timothy Loh
2016/10/28 02:50:04
Something like this is fine, but you need to creat
Hwanseung Lee
2016/10/28 12:17:58
Done.
|
| + var expectedMatrix = new DOMMatrix(); |
| + matrix.setMatrixValue(""); |
| + assert_true(matrix.is2D); |
| + assert_matrix_almost_equals(matrix, expectedMatrix); |
| +}, "DOMMatrix setMatrix(EmptyString)"); |
| + |
| +test(() => { |
| + var matrix = new DOMMatrix(); |
| + var expectedMatrix = new DOMMatrix(); |
| + matrix.setMatrixValue("none"); |
| + assert_true(matrix.is2D); |
| + assert_matrix_almost_equals(matrix, expectedMatrix); |
| +}, "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)"); |
| + |
| +test(() => { |
| + |
| + var matrix = new DOMMatrix(); |
| + |
| + assert_throws(new SyntaxError(), () => { |
| + matrix.setMatrixValue("initial"); |
| + }, "can't parse not exist keyword."); |
|
Timothy Loh
2016/10/24 04:18:30
I would write something like "CSS-wide keywords ar
Hwanseung Lee
2016/10/24 13:23:37
Done.
|
| + |
| + assert_throws(new SyntaxError(), () => { |
| + matrix.setMatrixValue("notExistFunction()"); |
| + }, "can't parse not exist function."); |
| + |
| + assert_throws(new SyntaxError(), () => { |
| + |
|
Timothy Loh
2016/10/24 04:18:30
unintentional blank line?
Hwanseung Lee
2016/10/24 13:23:37
no it is typo.
|
| + 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."); |
| + |
| + // TODO(hs1217.lee) : should be throw exception. |
|
Timothy Loh
2016/10/24 04:18:30
This case shouldn't throw an exception, right? So
Hwanseung Lee
2016/10/24 13:23:37
Yes, Your opinion is right, I'll move it.
|
| + // refer to hasRelativeLengths() in TransformBuilder.cpp |
| + // assert_throws(new SyntaxError(), () => { |
| + // matrix.setMatrixValue("translateX(calc(10px + 1px))"); |
| + // }, "Can't parse without absolute unit."); |
| + |
| +}, "DOMMatrix.setMatrix(): Exception test."); |
| + |
| +</script> |