| Index: third_party/WebKit/LayoutTests/typedcssom/perspectiveTransformComponent.html
|
| diff --git a/third_party/WebKit/LayoutTests/typedcssom/perspectiveTransformComponent.html b/third_party/WebKit/LayoutTests/typedcssom/perspectiveTransformComponent.html
|
| index eac86631917951972ccfb97cf20907b535794f0e..2f5d530754c86753343e9304f9bdb46d8f0d69c2 100644
|
| --- a/third_party/WebKit/LayoutTests/typedcssom/perspectiveTransformComponent.html
|
| +++ b/third_party/WebKit/LayoutTests/typedcssom/perspectiveTransformComponent.html
|
| @@ -3,6 +3,7 @@
|
| <script src="../resources/testharnessreport.js"></script>
|
|
|
| <script>
|
| +var EPSILON = 1e-6; // float epsilon
|
|
|
| test(function() {
|
| var calcLength = new CalcLength({px: 10, percent: 3.2});
|
| @@ -10,20 +11,90 @@ test(function() {
|
| }, "Constructor should throw an error for CalcLengths with a percentage type");
|
|
|
| test(function() {
|
| - var simpleLength = new SimpleLength(10, 'percent');
|
| + var simpleLength = new SimpleLength(10, "percent");
|
| assert_throws(null, function() { new Perspective(simpleLength) });
|
| }, "Constructor should throw an error for SimpleLengths with a percentage type");
|
|
|
| test(function() {
|
| - var simpleLength = new SimpleLength(10, 'px');
|
| + var simpleLength = new SimpleLength(10, "px");
|
| var calcLength = new CalcLength({px: 10, em: 3.2});
|
| var perspectiveTransformSimple = new Perspective(simpleLength);
|
| var perspectiveTransformCalc = new Perspective(calcLength);
|
|
|
| - assert_equals(perspectiveTransformSimple.cssString, 'perspective(10px)');
|
| - assert_equals(perspectiveTransformCalc.cssString,'perspective(calc(3.2em + 10px))');
|
| + assert_equals(perspectiveTransformSimple.cssString, "perspective(10px)");
|
| + assert_equals(perspectiveTransformCalc.cssString,"perspective(calc(3.2em + 10px))");
|
| }, "cssString should return a string of form perspective(<LengthValue.cssString()>)");
|
|
|
| +test(function() {
|
| + var nonRelativeTypes = ["px", "cm", "mm", "in", "pc", "pt"];
|
| + for (var i = 0; i < nonRelativeTypes.length; ++i) {
|
| + var simpleLength = new SimpleLength(1, nonRelativeTypes[i]);
|
| + var perspective = new Perspective(simpleLength);
|
| + perspective.asMatrix();
|
| + }
|
| +}, "asMatrix does not throw an exception for SimpleLength non-relative types");
|
| +
|
| +test(function() {
|
| + var supportedRelativeTypes = ["ch", "em", "ex", "rem", "vw", "vh", "vmin", "vmax"];
|
| + for (var i = 0; i < supportedRelativeTypes.length; ++i) {
|
| + var simpleLength = new SimpleLength(1, supportedRelativeTypes[i]);
|
| + var perspective = new Perspective(simpleLength);
|
| + assert_throws(null, function() { perspective.asMatrix() });
|
| + }
|
| +}, "asMatrix throws an exception for SimpleLength relative types");
|
| +
|
| +test(function() {
|
| + var calcLengths = [
|
| + new CalcLength({px: 10, cm: -2}),
|
| + new CalcLength({mm: -7.0, in: 0.1}),
|
| + new CalcLength({pc: -4, pt: 2, px: 0, cm: 3, mm: 2, in: -4})
|
| + ];
|
| +
|
| + for (var i = 0; i < calcLengths.length; ++i) {
|
| + var perspective = new Perspective(calcLengths[i]);
|
| + perspective.asMatrix();
|
| + }
|
| +}, "asMatrix does not throw an exception for CalcLength non-relative types");
|
| +
|
| +test(function() {
|
| + var calcLengths = [
|
| + new CalcLength({ch: 1}),
|
| + new CalcLength({em: 1}),
|
| + new CalcLength({ex: 1}),
|
| + new CalcLength({rem: 1}),
|
| + new CalcLength({vw: 1}),
|
| + new CalcLength({vh: 1}),
|
| + new CalcLength({vmin: 1}),
|
| + new CalcLength({vmax: 1}),
|
| + new CalcLength({px: 10, ch: -4}),
|
| + new CalcLength({px: 1, em: 0, ex: 0, rem: 0}),
|
| + new CalcLength({px: -2, vw: 2, vh: 0, vmin: 3, vmax: 2})
|
| + ];
|
| +
|
| + for (var i = 0; i < calcLengths.length; ++i) {
|
| + var perspective = new Perspective(calcLengths[i]);
|
| + assert_throws(null, function() { perspective.asMatrix() });
|
| + }
|
| +}, "asMatrix throws an exception for CalcLength relative types");
|
| +
|
| +test(function() {
|
| + var values = [-1, 0, 1, 10.2];
|
| + for (var i = 0; i < values.length; ++i) {
|
| + var perspective = new Perspective(new SimpleLength(values[i], "px"));
|
| + var perspectiveMatrix = perspective.asMatrix();
|
| + var matrixValue = values[i] ? -1 / values[i] : 0;
|
| + var expectedMatrix = new Matrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, matrixValue, 0, 0, 0, 1);
|
| + assert_false(expectedMatrix.is2DComponent());
|
| + for (var attribute in expectedMatrix) {
|
| + if (typeof expectedMatrix[attribute] === "number") {
|
| + assert_approx_equals(perspectiveMatrix[attribute], expectedMatrix[attribute], EPSILON);
|
| + } else {
|
| + assert_equals(perspectiveMatrix[attribute], expectedMatrix[attribute]);
|
| + }
|
| + }
|
| + }
|
| +}, "asMatrix for simple Perspective instances constructs the correct matrix");
|
| +
|
| </script>
|
|
|
| <body>
|
|
|