| <!DOCTYPE html> |
| <html> |
| <body> |
| <script src="../../resources/js-test.js"></script> |
| <div id="testDiv"></div> |
| <script> |
| description("Tests functionality of sin, cos, tan, e and pi"); |
| |
| var element = document.getElementById("testDiv"); |
| |
| function testProperty(propertyName) |
| { |
| |
| function testValue(expression, computedValue) |
| { |
| debug(''); |
| element.style[propertyName] = '999px'; |
| evalAndLog(`element.style["${propertyName}"] = "${expression}"`); |
| var value = Math.round(getComputedStyle(element).getPropertyValue(propertyName).slice(0,-2)); |
| shouldBe(`${value}`, computedValue); |
| } |
| |
| //Test pi |
| testValue('calc(sin(pi/2) * 100px)', '100'); |
| testValue('calc(cos(pi - 3.14159265358979323846) * 100px)', '100'); |
| |
| //Test e |
| testValue('calc(cos(e - 2.7182818284590452354) * 100px)', '100'); |
| |
| //Test units |
| testValue('calc(sin(30deg + 1.0471967rad ) * 100px)', '100'); |
| testValue('calc(cos(30deg - 0.523599rad ) * 100px)', '100'); |
| testValue('calc(sin(3.14159 / 2 + 1 - 1) * 100px)', '100'); |
| testValue('calc(sin(100grad) * 100px)', '100'); |
| testValue('calc(cos(0 / 2 + 1 - 1) * 100px)', '100'); |
| testValue('calc(tan(30deg + 0.261799rad ) * 100px)', '100'); |
| testValue('calc(tan(0.7853975rad ) * 100px)', '100'); |
| testValue('calc(tan(3.14159 / 4 + 1 - 1) * 100px)', '100'); |
| testValue('calc(sin(0.25turn) * 100px)', '100'); |
| |
| //Test nesting |
| testValue('calc(cos(sin(cos(pi) + 1)) * 100px)', '100'); |
| testValue('calc(sin(tan(pi/4)*pi/2) * 100px)', '100'); |
| testValue('calc(sin(tan(pi/4)*pi/2) * 100px)', '100'); |
| testValue('calc(sin(tan(pi/4)*pi/2) * 100px)', '100'); |
| } |
| |
| testProperty("width"); |
| testProperty("min-width"); |
| </script> |
| </body> |
| </html> |
| |
| |