158 lines
8.5 KiB
HTML
158 lines
8.5 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>2D Transform Tests</title>
|
|
<style type="text/css" media="screen">
|
|
.container {
|
|
height: 100px;
|
|
width: 200px;
|
|
margin: 30px;
|
|
outline: 1px solid black;
|
|
}
|
|
.box {
|
|
height: 100%;
|
|
width: 100%;
|
|
background-color: green;
|
|
-webkit-transform: rotate(90deg);
|
|
}
|
|
#results {
|
|
margin-top: 100px;
|
|
}
|
|
</style>
|
|
<script src="resources/prefixed-transform-test-utils.js" type="text/javascript" charset="utf-8"></script>
|
|
<script type="text/javascript" charset="utf-8">
|
|
if (window.testRunner) {
|
|
testRunner.dumpAsText();
|
|
testRunner.waitUntilDone();
|
|
}
|
|
|
|
var gTests = [
|
|
// nothing
|
|
{ 'transform' : 'none', 'result' : 'none' },
|
|
{ 'transform' : '', 'result' : 'matrix(5.96046e-08, 1, -1, 5.96046e-08, 0, 0)' }, // this cancels the style - revert back to box
|
|
{ 'transform' : 'inherit', 'result' : 'none' }, // parent element doesn't have transform
|
|
|
|
// translate
|
|
{ 'transform' : 'translate(80px, 90px)', 'result' : 'matrix(1, 0, 0, 1, 80, 90)' },
|
|
{ 'transform' : 'translate(100%, 3em)', 'result' : 'matrix(1, 0, 0, 1, 200, 48)' }, // depends on font size
|
|
{ 'transform' : 'translate(50px)', 'result' : 'matrix(1, 0, 0, 1, 50, 0)' },
|
|
{ 'transform' : 'translatex(-20px)', 'result' : 'matrix(1, 0, 0, 1, -20, 0)' },
|
|
{ 'transform' : 'translateX(-20px)', 'result' : 'matrix(1, 0, 0, 1, -20, 0)' },
|
|
{ 'transform' : 'translatey(23px)', 'result' : 'matrix(1, 0, 0, 1, 0, 23)' },
|
|
{ 'transform' : 'translateY(-3em)', 'result' : 'matrix(1, 0, 0, 1, 0, -48)' }, // depends on font size
|
|
|
|
// scale
|
|
{ 'transform' : 'scale(1.2)', 'result' : 'matrix(1.2, 0, 0, 1.2, 0, 0)' },
|
|
{ 'transform' : 'scalex(1.5)', 'result' : 'matrix(1.5, 0, 0, 1, 0, 0)' },
|
|
{ 'transform' : 'scaleX(1.5)', 'result' : 'matrix(1.5, 0, 0, 1, 0, 0)' },
|
|
{ 'transform' : 'scaley(1.5)', 'result' : 'matrix(1, 0, 0, 1.5, 0, 0)' },
|
|
{ 'transform' : 'scaleY(1.5)', 'result' : 'matrix(1, 0, 0, 1.5, 0, 0)' },
|
|
{ 'transform' : 'scale(1.2, 0.8)', 'result' : 'matrix(1.2, 0, 0, 0.8, 0, 0)' },
|
|
{ 'transform' : 'scale(-1.2, -0.8)', 'result' : 'matrix(-1.2, -0, -0, -0.8, 0, 0)' },
|
|
|
|
// skew
|
|
{ 'transform' : 'skew(-0.7rad, 20deg)', 'result' : 'matrix(1, 0.36397, -0.842288, 1, 0, 0)' },
|
|
{ 'transform' : 'skew(12grad)', 'result' : 'matrix(1, 0, 0.19076, 1, 0, 0)' },
|
|
{ 'transform' : 'skewx(12grad)', 'result' : 'matrix(1, 0, 0.19076, 1, 0, 0)' },
|
|
{ 'transform' : 'skewX(12grad)', 'result' : 'matrix(1, 0, 0.19076, 1, 0, 0)' },
|
|
{ 'transform' : 'skewy(-12grad)', 'result' : 'matrix(1, -0.19076, 0, 1, 0, 0)' },
|
|
{ 'transform' : 'skewY(-12grad)', 'result' : 'matrix(1, -0.19076, 0, 1, 0, 0)' },
|
|
{ 'transform' : 'skewx(0.1turn)', 'result' : 'matrix(1, 0, 0.726543, 1, 0, 0)' },
|
|
|
|
// rotate
|
|
{ 'transform' : 'rotate(45deg)', 'result' : 'matrix(0.707107, 0.707107, -0.707107, 0.707107, 0, 0)' },
|
|
{ 'transform' : 'rotate(90deg)', 'result' : 'matrix(-4.37114e-08, 1, -1, -4.37114e-08, 0, 0)' },
|
|
{ 'transform' : 'rotate(-90deg)', 'result' : 'matrix(-4.37114e-08, -1, 1, -4.37114e-08, 0, 0)' },
|
|
{ 'transform' : 'rotate(180deg)', 'result' : 'matrix(-1, -8.74228e-08, 8.74228e-08, -1, 0, 0)' },
|
|
{ 'transform' : 'rotate(1.2rad)', 'result' : 'matrix(0.362358, 0.932039, -0.932039, 0.362358, 0, 0)' },
|
|
{ 'transform' : 'rotate(0.25turn)', 'result' : 'matrix(-4.37114e-08, 1, -1, -4.37114e-08, 0, 0)' },
|
|
{ 'transform' : 'rotate(0.5turn)', 'result' : 'matrix(-1, -8.74228e-08, 8.74228e-08, -1, 0, 0)' },
|
|
{ 'transform' : 'rotate(1.5turn)', 'result' : 'matrix(-1, -8.74228e-08, 8.74228e-08, -1, 0, 0)' },
|
|
|
|
// matrix
|
|
{ 'transform' : 'matrix(1, 0, 0, 1, 0, 0)', 'result' : 'matrix(1, 0, 0, 1, 0, 0)' },
|
|
{ 'transform' : 'matrix(1, -0.19076, 0, 1, 0, 0)', 'result' : 'matrix(1, -0.19076, 0, 1, 0, 0)' },
|
|
{ 'transform' : 'matrix(0.2, 0.3, 0.4, 1.1, 1.2, 1.3)', 'result' : 'matrix(0.2, 0.3, 0.4, 1.1, 1.2, 1.3)' },
|
|
|
|
// invalid syntax
|
|
{ 'transform' : ',rotate(12deg)', 'result' : 'none' }, // has comma
|
|
{ 'transform' : 'rotate(12deg),', 'result' : 'none' }, // has comma
|
|
{ 'transform' : 'rotate(12deg) +', 'result' : 'none' }, // has plus
|
|
{ 'transform' : '(translate(50, 20))', 'result' : 'none' }, // bad syntax
|
|
{ 'transform' : 'eggs(10)', 'result' : 'none' }, // invalid function
|
|
|
|
// invalid translate
|
|
{ 'transform' : 'translate(50, 20)', 'result' : 'none' }, // missing units
|
|
{ 'transform' : 'translate()', 'result' : 'none' }, // no arguments
|
|
{ 'transform' : 'translate(10px, 20px, 30px)', 'result' : 'none' }, // too many arguments
|
|
{ 'transform' : 'translate(10px, 20px, 30px, 40px)', 'result' : 'none' }, // too many arguments
|
|
{ 'transform' : 'translate(10smidgens)', 'result' : 'none' }, // invalid units
|
|
{ 'transform' : 'translate(10px, 10smidgens)', 'result' : 'none' }, // invalid units
|
|
{ 'transform' : 'translateX(10px, 20px)', 'result' : 'none' }, // too many arguments
|
|
{ 'transform' : 'translateX(10px, 20px, 30px)', 'result' : 'none' }, // too many arguments
|
|
{ 'transform' : 'translateX(10smidgens)', 'result' : 'none' }, // invalid units
|
|
{ 'transform' : 'translateX(10px, 10smidgens)', 'result' : 'none' }, // invalid units
|
|
{ 'transform' : 'translateY(10px, 20px)', 'result' : 'none' }, // too many arguments
|
|
{ 'transform' : 'translateY(10px, 20px, 30px)', 'result' : 'none' }, // too many arguments
|
|
{ 'transform' : 'translateY(10smidgens)', 'result' : 'none' }, // invalid units
|
|
{ 'transform' : 'translateY(10px, 10smidgens)', 'result' : 'none' }, // invalid units
|
|
|
|
// invalid scale
|
|
{ 'transform' : 'scale(2px, 2px)', 'result' : 'none' }, // has units
|
|
{ 'transform' : 'scale(2, 2px)', 'result' : 'none' }, // has units
|
|
{ 'transform' : 'scale()', 'result' : 'none' }, // no arguments
|
|
{ 'transform' : 'scale(1, 2, 3)', 'result' : 'none' }, // too many arguments
|
|
{ 'transform' : 'scale(2smidgens)', 'result' : 'none' }, // invalid units
|
|
{ 'transform' : 'scale(2, 2smidgens)', 'result' : 'none' }, // invalid units
|
|
|
|
// invalid rotate
|
|
{ 'transform' : 'rotate(10)', 'result' : 'none' }, // no units
|
|
{ 'transform' : 'rotate()', 'result' : 'none' }, // no arguments
|
|
{ 'transform' : 'rotate(10deg, 20deg)', 'result' : 'none' }, // too many arguments
|
|
{ 'transform' : 'rotate(2turns)', 'result' : 'none' }, // invalid units -- 'turn' not 'turns'
|
|
{ 'transform' : 'rotate(2spins)', 'result' : 'none' }, // invalid units
|
|
{ 'transform' : 'rotate(2, 2spins)', 'result' : 'none' }, // invalid units
|
|
|
|
// invalid skew
|
|
{ 'transform' : 'skew(10)', 'result' : 'none' }, // no units
|
|
{ 'transform' : 'skew()', 'result' : 'none' }, // no arguments
|
|
{ 'transform' : 'skew(10deg, 20deg, 30deg)', 'result' : 'none' }, // too many arguments
|
|
{ 'transform' : 'skew(2bits)', 'result' : 'none' }, // invalid units
|
|
{ 'transform' : 'skew(2, 2bits)', 'result' : 'none' }, // invalid units
|
|
{ 'transform' : 'skewX(10)', 'result' : 'none' }, // no units
|
|
{ 'transform' : 'skewX()', 'result' : 'none' }, // no arguments
|
|
{ 'transform' : 'skewX(10deg, 20deg)', 'result' : 'none' }, // too many arguments
|
|
{ 'transform' : 'skewX(2bits)', 'result' : 'none' }, // invalid units
|
|
{ 'transform' : 'skewY(10)', 'result' : 'none' }, // no units
|
|
{ 'transform' : 'skewY()', 'result' : 'none' }, // no arguments
|
|
{ 'transform' : 'skewY(10deg, 20deg)', 'result' : 'none' }, // too many arguments
|
|
{ 'transform' : 'skewY(2bits)', 'result' : 'none' }, // invalid units
|
|
|
|
// invalid matrix
|
|
{ 'transform' : 'matrix()', 'result' : 'none' }, // no arguments
|
|
{ 'transform' : 'matrix(2, 0, 0, 2)', 'result' : 'none' }, // not enough arguments
|
|
{ 'transform' : 'matrix(0.978148, 0.207912, -0.207912, 0.978148, 50, 20, 666)', 'result' : 'none' }, // too many arguments
|
|
{ 'transform' : 'matrix(1, 0, 0, 1, 20px, 50px)', 'result' : 'none' } // has units
|
|
|
|
];
|
|
|
|
function runTests()
|
|
{
|
|
testTransforms();
|
|
|
|
if (window.testRunner)
|
|
testRunner.notifyDone();
|
|
}
|
|
</script>
|
|
</head>
|
|
<body onload="runTests()">
|
|
|
|
<div class="container">
|
|
<div id="test-box" class="box"></div>
|
|
</div>
|
|
|
|
<div id="results">
|
|
</div>
|
|
</body>
|
|
</html>
|