Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=435293 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 435293</title> |
michael@0 | 8 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 10 | |
michael@0 | 11 | <style> |
michael@0 | 12 | /* Skewed boxes can get very big. The .pane wrapper prevents them |
michael@0 | 13 | from obscuring the test results. */ |
michael@0 | 14 | .pane { |
michael@0 | 15 | height: 300px; |
michael@0 | 16 | width: 300px; |
michael@0 | 17 | float: left; |
michael@0 | 18 | overflow: auto; |
michael@0 | 19 | border: 1px solid black; |
michael@0 | 20 | } |
michael@0 | 21 | .test { |
michael@0 | 22 | background: green; |
michael@0 | 23 | height: 100px; |
michael@0 | 24 | width: 100px; |
michael@0 | 25 | margin: 100px; |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | /* Radian units are not used in this test because our CSS |
michael@0 | 29 | implementation stores all dimensional values in single- |
michael@0 | 30 | precision floating point, which makes it impossible to |
michael@0 | 31 | hit mathematically interesting angles with radians. |
michael@0 | 32 | Degrees and grads do not suffer this problem. */ |
michael@0 | 33 | #test1 { |
michael@0 | 34 | -moz-transform: skewx(30deg); |
michael@0 | 35 | } |
michael@0 | 36 | #test2 { |
michael@0 | 37 | -moz-transform: skewy(60deg); |
michael@0 | 38 | } |
michael@0 | 39 | #test3 { |
michael@0 | 40 | -moz-transform: skew(45deg, 45deg); |
michael@0 | 41 | } |
michael@0 | 42 | #test4 { |
michael@0 | 43 | -moz-transform: skew(360deg, 45deg); |
michael@0 | 44 | } |
michael@0 | 45 | #test5 { |
michael@0 | 46 | -moz-transform: skew(45deg, 150grad); |
michael@0 | 47 | } |
michael@0 | 48 | #test6 { |
michael@0 | 49 | -moz-transform: skew(80%, 78px); |
michael@0 | 50 | } |
michael@0 | 51 | #test7 { |
michael@0 | 52 | -moz-transform: skew(2em, 40ex); |
michael@0 | 53 | } |
michael@0 | 54 | #test8 { |
michael@0 | 55 | -moz-transform: skew(-45deg, -465deg); |
michael@0 | 56 | } |
michael@0 | 57 | #test9 { |
michael@0 | 58 | -moz-transform: skew(30deg, 30deg, 30deg); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | /* approach the singularity from the negative side */ |
michael@0 | 62 | #test10 { |
michael@0 | 63 | -moz-transform: skew(50grad, 90.001deg); |
michael@0 | 64 | } |
michael@0 | 65 | #test11 { |
michael@0 | 66 | -moz-transform: skew(300grad, 90.001deg); |
michael@0 | 67 | } |
michael@0 | 68 | </style> |
michael@0 | 69 | </head> |
michael@0 | 70 | <body> |
michael@0 | 71 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=435293">Mozilla Bug 435293</a> |
michael@0 | 72 | <p id="display"></p> |
michael@0 | 73 | <div id="content"> |
michael@0 | 74 | <div class="pane"><div id="test1" class="test">test</div></div> |
michael@0 | 75 | <div class="pane"><p id="test2" class="test">test</p></div> |
michael@0 | 76 | <div class="pane"><div id="test3" class="test">test</div></div> |
michael@0 | 77 | <div class="pane"><div id="test4" class="test">test</div></div> |
michael@0 | 78 | <div class="pane"><div id="test5" class="test">test</div></div> |
michael@0 | 79 | <div class="pane"><div id="test6" class="test">test</div></div> |
michael@0 | 80 | <div class="pane"><div id="test7" class="test">test</div></div> |
michael@0 | 81 | <div class="pane"><div id="test8" class="test">test</div></div> |
michael@0 | 82 | <div class="pane"><div id="test9" class="test">test</div></div> |
michael@0 | 83 | <div class="pane"><div id="test10" class="test">test</div></div> |
michael@0 | 84 | <div class="pane"><div id="test11" class="test">test</div></div> |
michael@0 | 85 | </div> |
michael@0 | 86 | |
michael@0 | 87 | <pre id="test"> |
michael@0 | 88 | <script type="application/javascript"> |
michael@0 | 89 | runtests(); |
michael@0 | 90 | |
michael@0 | 91 | function runtests() { |
michael@0 | 92 | // For test 1 we need to handle the contingency that different systems may |
michael@0 | 93 | // round differently. We will parse out the values and compare them |
michael@0 | 94 | // individually. The matrix should be: matrix(1, 0, 0.57735, 1, 0, 0) |
michael@0 | 95 | var style = window.getComputedStyle(document.getElementById("test1"), ""); |
michael@0 | 96 | var tformStyle = style.getPropertyValue("-moz-transform"); |
michael@0 | 97 | var tformValues = tformStyle.substring(tformStyle.indexOf('(') + 1, |
michael@0 | 98 | tformStyle.indexOf(')')).split(','); |
michael@0 | 99 | is((+tformValues[0]), 1, "Test1: skewx: param 0 is 1"); |
michael@0 | 100 | is((+tformValues[1]), 0, "Test1: skewx: param 1 is 0"); |
michael@0 | 101 | ok(verifyRounded(tformValues[2], 0.57735), "Test1: skewx: Rounded param 2 is in bounds"); |
michael@0 | 102 | is((+tformValues[3]), 1, "Test1: skewx: param 3 is 1"); |
michael@0 | 103 | is((+tformValues[4]), 0, "Test1: skewx: param 4 is 0"); |
michael@0 | 104 | is((+tformValues[5]), 0, "Test1: skewx: param 5 is 0"); |
michael@0 | 105 | |
michael@0 | 106 | // Again, handle rounding for test 2, proper matrix should be: |
michael@0 | 107 | // matrix(1, 1.73205, 0, 1, 0, 0) |
michael@0 | 108 | style = window.getComputedStyle(document.getElementById("test2"), ""); |
michael@0 | 109 | tformStyle = style.getPropertyValue("-moz-transform"); |
michael@0 | 110 | tformValues = tformStyle.substring(tformStyle.indexOf('(') + 1, |
michael@0 | 111 | tformStyle.indexOf(')')).split(','); |
michael@0 | 112 | is((+tformValues[0]), 1, "Test2: skewy: param 0 is 1"); |
michael@0 | 113 | ok(verifyRounded(tformValues[1], 1.73205), "Test2: skewy: Rounded param 1 is in bounds"); |
michael@0 | 114 | is((+tformValues[2]), 0, "Test2: skewy: param 2 is 0"); |
michael@0 | 115 | is((+tformValues[3]), 1, "Test2: skewy: param 3 is 1"); |
michael@0 | 116 | is((+tformValues[4]), 0, "Test2: skewy: param 4 is 0"); |
michael@0 | 117 | is((+tformValues[5]), 0, "Test2: skewy: param 5 is 0"); |
michael@0 | 118 | |
michael@0 | 119 | style = window.getComputedStyle(document.getElementById("test3"), ""); |
michael@0 | 120 | is(style.getPropertyValue("-moz-transform"), "matrix(1, 1, 1, 1, 0, 0)", |
michael@0 | 121 | "Test3: Skew proper matrix is applied"); |
michael@0 | 122 | |
michael@0 | 123 | style = window.getComputedStyle(document.getElementById("test4"), ""); |
michael@0 | 124 | is(style.getPropertyValue("-moz-transform"), "matrix(1, 1, 0, 1, 0, 0)", |
michael@0 | 125 | "Test4: Skew angle wrap: proper matrix is applied"); |
michael@0 | 126 | |
michael@0 | 127 | style = window.getComputedStyle(document.getElementById("test5"), ""); |
michael@0 | 128 | is(style.getPropertyValue("-moz-transform"), "matrix(1, -1, 1, 1, 0, 0)", |
michael@0 | 129 | "Test5: Skew mixing deg and grad"); |
michael@0 | 130 | |
michael@0 | 131 | style = window.getComputedStyle(document.getElementById("test6"), ""); |
michael@0 | 132 | is(style.getPropertyValue("-moz-transform"), "none", |
michael@0 | 133 | "Test6: Skew with invalid units"); |
michael@0 | 134 | |
michael@0 | 135 | style = window.getComputedStyle(document.getElementById("test7"), ""); |
michael@0 | 136 | is(style.getPropertyValue("-moz-transform"), "none", |
michael@0 | 137 | "Test7: Skew with more invalid units"); |
michael@0 | 138 | |
michael@0 | 139 | // Test 8: skew with negative degrees, here again we must handle rounding. |
michael@0 | 140 | // The matrix should be: matrix(1, 3.73206, -1, 1, 0, 0) |
michael@0 | 141 | style = window.getComputedStyle(document.getElementById("test8"), ""); |
michael@0 | 142 | tformStyle = style.getPropertyValue("-moz-transform"); |
michael@0 | 143 | tformValues = tformStyle.substring(tformStyle.indexOf('(') + 1, |
michael@0 | 144 | tformStyle.indexOf(')')).split(','); |
michael@0 | 145 | is(tformValues[0], 1, "Test8: Test skew with negative degrees-param 0 is 1"); |
michael@0 | 146 | ok(verifyRounded(tformValues[1], 3.73206), "Test8: Rounded param 1 is in bounds"); |
michael@0 | 147 | is((+tformValues[2]), -1, "Test8: param 2 is -1"); |
michael@0 | 148 | is((+tformValues[3]), 1, "Test8: param 3 is 1"); |
michael@0 | 149 | is((+tformValues[4]), 0, "Test8: param 4 is 0"); |
michael@0 | 150 | is((+tformValues[5]), 0, "Test8: param 5 is 0"); |
michael@0 | 151 | |
michael@0 | 152 | style = window.getComputedStyle(document.getElementById("test9"), ""); |
michael@0 | 153 | is(style.getPropertyValue("-moz-transform"), "none", |
michael@0 | 154 | "Test9: Skew in 3d should be ignored"); |
michael@0 | 155 | |
michael@0 | 156 | style = window.getComputedStyle(document.getElementById("test10"), ""); |
michael@0 | 157 | is(style.getPropertyValue("-moz-transform"), "matrix(1, -10000, 1, 1, 0, 0)", |
michael@0 | 158 | "Test10: Skew with nearly infinite numbers"); |
michael@0 | 159 | |
michael@0 | 160 | style = window.getComputedStyle(document.getElementById("test11"), ""); |
michael@0 | 161 | is(style.getPropertyValue("-moz-transform"), "matrix(1, -10000, 10000, 1, 0, 0)", |
michael@0 | 162 | "Test11: Skew with more infinite numbers"); |
michael@0 | 163 | } |
michael@0 | 164 | |
michael@0 | 165 | // Verifies that aVal is +/- 0.00001 of aTrueVal |
michael@0 | 166 | // Returns true if so, false if not |
michael@0 | 167 | function verifyRounded(aVal, aTrueVal) { |
michael@0 | 168 | return (Math.abs(aVal - aTrueVal).toFixed(5) <= 0.00001); |
michael@0 | 169 | } |
michael@0 | 170 | </script> |
michael@0 | 171 | </pre> |
michael@0 | 172 | </body> |
michael@0 | 173 | </html> |