1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/base/tests/test_bug435293-skew.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,173 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=435293 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 435293</title> 1.11 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.13 + 1.14 + <style> 1.15 + /* Skewed boxes can get very big. The .pane wrapper prevents them 1.16 + from obscuring the test results. */ 1.17 + .pane { 1.18 + height: 300px; 1.19 + width: 300px; 1.20 + float: left; 1.21 + overflow: auto; 1.22 + border: 1px solid black; 1.23 + } 1.24 + .test { 1.25 + background: green; 1.26 + height: 100px; 1.27 + width: 100px; 1.28 + margin: 100px; 1.29 + } 1.30 + 1.31 + /* Radian units are not used in this test because our CSS 1.32 + implementation stores all dimensional values in single- 1.33 + precision floating point, which makes it impossible to 1.34 + hit mathematically interesting angles with radians. 1.35 + Degrees and grads do not suffer this problem. */ 1.36 + #test1 { 1.37 + -moz-transform: skewx(30deg); 1.38 + } 1.39 + #test2 { 1.40 + -moz-transform: skewy(60deg); 1.41 + } 1.42 + #test3 { 1.43 + -moz-transform: skew(45deg, 45deg); 1.44 + } 1.45 + #test4 { 1.46 + -moz-transform: skew(360deg, 45deg); 1.47 + } 1.48 + #test5 { 1.49 + -moz-transform: skew(45deg, 150grad); 1.50 + } 1.51 + #test6 { 1.52 + -moz-transform: skew(80%, 78px); 1.53 + } 1.54 + #test7 { 1.55 + -moz-transform: skew(2em, 40ex); 1.56 + } 1.57 + #test8 { 1.58 + -moz-transform: skew(-45deg, -465deg); 1.59 + } 1.60 + #test9 { 1.61 + -moz-transform: skew(30deg, 30deg, 30deg); 1.62 + } 1.63 + 1.64 + /* approach the singularity from the negative side */ 1.65 + #test10 { 1.66 + -moz-transform: skew(50grad, 90.001deg); 1.67 + } 1.68 + #test11 { 1.69 + -moz-transform: skew(300grad, 90.001deg); 1.70 + } 1.71 + </style> 1.72 +</head> 1.73 +<body> 1.74 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=435293">Mozilla Bug 435293</a> 1.75 +<p id="display"></p> 1.76 +<div id="content"> 1.77 + <div class="pane"><div id="test1" class="test">test</div></div> 1.78 + <div class="pane"><p id="test2" class="test">test</p></div> 1.79 + <div class="pane"><div id="test3" class="test">test</div></div> 1.80 + <div class="pane"><div id="test4" class="test">test</div></div> 1.81 + <div class="pane"><div id="test5" class="test">test</div></div> 1.82 + <div class="pane"><div id="test6" class="test">test</div></div> 1.83 + <div class="pane"><div id="test7" class="test">test</div></div> 1.84 + <div class="pane"><div id="test8" class="test">test</div></div> 1.85 + <div class="pane"><div id="test9" class="test">test</div></div> 1.86 + <div class="pane"><div id="test10" class="test">test</div></div> 1.87 + <div class="pane"><div id="test11" class="test">test</div></div> 1.88 +</div> 1.89 + 1.90 +<pre id="test"> 1.91 +<script type="application/javascript"> 1.92 +runtests(); 1.93 + 1.94 +function runtests() { 1.95 + // For test 1 we need to handle the contingency that different systems may 1.96 + // round differently. We will parse out the values and compare them 1.97 + // individually. The matrix should be: matrix(1, 0, 0.57735, 1, 0, 0) 1.98 + var style = window.getComputedStyle(document.getElementById("test1"), ""); 1.99 + var tformStyle = style.getPropertyValue("-moz-transform"); 1.100 + var tformValues = tformStyle.substring(tformStyle.indexOf('(') + 1, 1.101 + tformStyle.indexOf(')')).split(','); 1.102 + is((+tformValues[0]), 1, "Test1: skewx: param 0 is 1"); 1.103 + is((+tformValues[1]), 0, "Test1: skewx: param 1 is 0"); 1.104 + ok(verifyRounded(tformValues[2], 0.57735), "Test1: skewx: Rounded param 2 is in bounds"); 1.105 + is((+tformValues[3]), 1, "Test1: skewx: param 3 is 1"); 1.106 + is((+tformValues[4]), 0, "Test1: skewx: param 4 is 0"); 1.107 + is((+tformValues[5]), 0, "Test1: skewx: param 5 is 0"); 1.108 + 1.109 + // Again, handle rounding for test 2, proper matrix should be: 1.110 + // matrix(1, 1.73205, 0, 1, 0, 0) 1.111 + style = window.getComputedStyle(document.getElementById("test2"), ""); 1.112 + tformStyle = style.getPropertyValue("-moz-transform"); 1.113 + tformValues = tformStyle.substring(tformStyle.indexOf('(') + 1, 1.114 + tformStyle.indexOf(')')).split(','); 1.115 + is((+tformValues[0]), 1, "Test2: skewy: param 0 is 1"); 1.116 + ok(verifyRounded(tformValues[1], 1.73205), "Test2: skewy: Rounded param 1 is in bounds"); 1.117 + is((+tformValues[2]), 0, "Test2: skewy: param 2 is 0"); 1.118 + is((+tformValues[3]), 1, "Test2: skewy: param 3 is 1"); 1.119 + is((+tformValues[4]), 0, "Test2: skewy: param 4 is 0"); 1.120 + is((+tformValues[5]), 0, "Test2: skewy: param 5 is 0"); 1.121 + 1.122 + style = window.getComputedStyle(document.getElementById("test3"), ""); 1.123 + is(style.getPropertyValue("-moz-transform"), "matrix(1, 1, 1, 1, 0, 0)", 1.124 + "Test3: Skew proper matrix is applied"); 1.125 + 1.126 + style = window.getComputedStyle(document.getElementById("test4"), ""); 1.127 + is(style.getPropertyValue("-moz-transform"), "matrix(1, 1, 0, 1, 0, 0)", 1.128 + "Test4: Skew angle wrap: proper matrix is applied"); 1.129 + 1.130 + style = window.getComputedStyle(document.getElementById("test5"), ""); 1.131 + is(style.getPropertyValue("-moz-transform"), "matrix(1, -1, 1, 1, 0, 0)", 1.132 + "Test5: Skew mixing deg and grad"); 1.133 + 1.134 + style = window.getComputedStyle(document.getElementById("test6"), ""); 1.135 + is(style.getPropertyValue("-moz-transform"), "none", 1.136 + "Test6: Skew with invalid units"); 1.137 + 1.138 + style = window.getComputedStyle(document.getElementById("test7"), ""); 1.139 + is(style.getPropertyValue("-moz-transform"), "none", 1.140 + "Test7: Skew with more invalid units"); 1.141 + 1.142 + // Test 8: skew with negative degrees, here again we must handle rounding. 1.143 + // The matrix should be: matrix(1, 3.73206, -1, 1, 0, 0) 1.144 + style = window.getComputedStyle(document.getElementById("test8"), ""); 1.145 + tformStyle = style.getPropertyValue("-moz-transform"); 1.146 + tformValues = tformStyle.substring(tformStyle.indexOf('(') + 1, 1.147 + tformStyle.indexOf(')')).split(','); 1.148 + is(tformValues[0], 1, "Test8: Test skew with negative degrees-param 0 is 1"); 1.149 + ok(verifyRounded(tformValues[1], 3.73206), "Test8: Rounded param 1 is in bounds"); 1.150 + is((+tformValues[2]), -1, "Test8: param 2 is -1"); 1.151 + is((+tformValues[3]), 1, "Test8: param 3 is 1"); 1.152 + is((+tformValues[4]), 0, "Test8: param 4 is 0"); 1.153 + is((+tformValues[5]), 0, "Test8: param 5 is 0"); 1.154 + 1.155 + style = window.getComputedStyle(document.getElementById("test9"), ""); 1.156 + is(style.getPropertyValue("-moz-transform"), "none", 1.157 + "Test9: Skew in 3d should be ignored"); 1.158 + 1.159 + style = window.getComputedStyle(document.getElementById("test10"), ""); 1.160 + is(style.getPropertyValue("-moz-transform"), "matrix(1, -10000, 1, 1, 0, 0)", 1.161 + "Test10: Skew with nearly infinite numbers"); 1.162 + 1.163 + style = window.getComputedStyle(document.getElementById("test11"), ""); 1.164 + is(style.getPropertyValue("-moz-transform"), "matrix(1, -10000, 10000, 1, 0, 0)", 1.165 + "Test11: Skew with more infinite numbers"); 1.166 +} 1.167 + 1.168 +// Verifies that aVal is +/- 0.00001 of aTrueVal 1.169 +// Returns true if so, false if not 1.170 +function verifyRounded(aVal, aTrueVal) { 1.171 + return (Math.abs(aVal - aTrueVal).toFixed(5) <= 0.00001); 1.172 +} 1.173 +</script> 1.174 +</pre> 1.175 +</body> 1.176 +</html>