1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/smil/test/test_smilTextZoom.xhtml Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,89 @@ 1.4 +<html xmlns="http://www.w3.org/1999/xhtml"> 1.5 +<head> 1.6 + <title>Test for SMIL Animation Behavior with textZoom</title> 1.7 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.8 + <script type="text/javascript" src="smilTestUtils.js"></script> 1.9 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.10 +</head> 1.11 +<body> 1.12 +<p id="display"></p> 1.13 +<div id="content" style="display: none"> 1.14 + <svg xmlns="http://www.w3.org/2000/svg" width="300px" height="200px" 1.15 + onload="this.pauseAnimations()"> 1.16 + <text y="100px" x="0px" style="font-size: 5px"> 1.17 + abc 1.18 + <animate attributeName="font-size" attributeType="CSS" fill="freeze" 1.19 + from="20px" to="40px" begin="1s" dur="1s"/> 1.20 + </text> 1.21 + <rect y="100px" x="50px" style="stroke-width: 5px"> 1.22 + <animate attributeName="stroke-width" attributeType="CSS" fill="freeze" 1.23 + from="20px" to="40px" begin="1s" dur="1s"/> 1.24 + </rect> 1.25 + </svg> 1.26 +</div> 1.27 +<pre id="test"> 1.28 +<script class="testbody" type="text/javascript"> 1.29 +<![CDATA[ 1.30 +SimpleTest.waitForExplicitFinish(); 1.31 + 1.32 +// Helper function 1.33 +function verifyStyle(aNode, aPropertyName, aExpectedVal) 1.34 +{ 1.35 + var computedVal = SMILUtil.getComputedStyleSimple(aNode, aPropertyName); 1.36 + is(computedVal, aExpectedVal, "computed value of " + aPropertyName); 1.37 +} 1.38 + 1.39 +function main() 1.40 +{ 1.41 + // Start out pause 1.42 + var svg = SMILUtil.getSVGRoot(); 1.43 + ok(svg.animationsPaused(), "should be paused by <svg> load handler"); 1.44 + is(svg.getCurrentTime(), 0, "should be paused at 0 in <svg> load handler"); 1.45 + 1.46 + // Set text zoom to 2x 1.47 + var origTextZoom = SpecialPowers.getTextZoom(window); 1.48 + SpecialPowers.setTextZoom(window, 2); 1.49 + 1.50 + try { 1.51 + // Verify computed style values at various points during animation. 1.52 + // * Correct behavior is for the computed values of 'font-size' to be 1.53 + // the same as their corresponding specified values, since text zoom 1.54 + // should not affect SVG text elements. 1.55 + // * I also include tests for an identical animation of the "stroke-width" 1.56 + // property, which should _not_ be affected by textZoom. 1.57 + var text = document.getElementsByTagName("text")[0]; 1.58 + var rect = document.getElementsByTagName("rect")[0]; 1.59 + 1.60 + verifyStyle(text, "font-size", "5px"); 1.61 + verifyStyle(rect, "stroke-width", "5px"); 1.62 + svg.setCurrentTime(1); 1.63 + verifyStyle(text, "font-size", "20px"); 1.64 + verifyStyle(rect, "stroke-width", "20px"); 1.65 + svg.setCurrentTime(1.5); 1.66 + verifyStyle(text, "font-size", "30px"); 1.67 + verifyStyle(rect, "stroke-width", "30px"); 1.68 + svg.setCurrentTime(2); 1.69 + verifyStyle(text, "font-size", "40px"); 1.70 + verifyStyle(rect, "stroke-width", "40px"); 1.71 + svg.setCurrentTime(3); 1.72 + verifyStyle(text, "font-size", "40px"); 1.73 + verifyStyle(rect, "stroke-width", "40px"); 1.74 + } catch (e) { 1.75 + // If anything goes wrong, make sure we restore textZoom before bubbling 1.76 + // the exception upwards, so that we don't mess up subsequent tests. 1.77 + SpecialPowers.setTextZoom(window, origTextZoom); 1.78 + 1.79 + throw e; 1.80 + } 1.81 + 1.82 + // We're done! Restore original text-zoom before finishing 1.83 + SpecialPowers.setTextZoom(window, origTextZoom); 1.84 + SimpleTest.finish(); 1.85 +} 1.86 + 1.87 +window.addEventListener("load", main, false); 1.88 +]]> 1.89 +</script> 1.90 +</pre> 1.91 +</body> 1.92 +</html>