dom/smil/test/test_smilTextZoom.xhtml

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <html xmlns="http://www.w3.org/1999/xhtml">
michael@0 2 <head>
michael@0 3 <title>Test for SMIL Animation Behavior with textZoom</title>
michael@0 4 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 5 <script type="text/javascript" src="smilTestUtils.js"></script>
michael@0 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 7 </head>
michael@0 8 <body>
michael@0 9 <p id="display"></p>
michael@0 10 <div id="content" style="display: none">
michael@0 11 <svg xmlns="http://www.w3.org/2000/svg" width="300px" height="200px"
michael@0 12 onload="this.pauseAnimations()">
michael@0 13 <text y="100px" x="0px" style="font-size: 5px">
michael@0 14 abc
michael@0 15 <animate attributeName="font-size" attributeType="CSS" fill="freeze"
michael@0 16 from="20px" to="40px" begin="1s" dur="1s"/>
michael@0 17 </text>
michael@0 18 <rect y="100px" x="50px" style="stroke-width: 5px">
michael@0 19 <animate attributeName="stroke-width" attributeType="CSS" fill="freeze"
michael@0 20 from="20px" to="40px" begin="1s" dur="1s"/>
michael@0 21 </rect>
michael@0 22 </svg>
michael@0 23 </div>
michael@0 24 <pre id="test">
michael@0 25 <script class="testbody" type="text/javascript">
michael@0 26 <![CDATA[
michael@0 27 SimpleTest.waitForExplicitFinish();
michael@0 28
michael@0 29 // Helper function
michael@0 30 function verifyStyle(aNode, aPropertyName, aExpectedVal)
michael@0 31 {
michael@0 32 var computedVal = SMILUtil.getComputedStyleSimple(aNode, aPropertyName);
michael@0 33 is(computedVal, aExpectedVal, "computed value of " + aPropertyName);
michael@0 34 }
michael@0 35
michael@0 36 function main()
michael@0 37 {
michael@0 38 // Start out pause
michael@0 39 var svg = SMILUtil.getSVGRoot();
michael@0 40 ok(svg.animationsPaused(), "should be paused by <svg> load handler");
michael@0 41 is(svg.getCurrentTime(), 0, "should be paused at 0 in <svg> load handler");
michael@0 42
michael@0 43 // Set text zoom to 2x
michael@0 44 var origTextZoom = SpecialPowers.getTextZoom(window);
michael@0 45 SpecialPowers.setTextZoom(window, 2);
michael@0 46
michael@0 47 try {
michael@0 48 // Verify computed style values at various points during animation.
michael@0 49 // * Correct behavior is for the computed values of 'font-size' to be
michael@0 50 // the same as their corresponding specified values, since text zoom
michael@0 51 // should not affect SVG text elements.
michael@0 52 // * I also include tests for an identical animation of the "stroke-width"
michael@0 53 // property, which should _not_ be affected by textZoom.
michael@0 54 var text = document.getElementsByTagName("text")[0];
michael@0 55 var rect = document.getElementsByTagName("rect")[0];
michael@0 56
michael@0 57 verifyStyle(text, "font-size", "5px");
michael@0 58 verifyStyle(rect, "stroke-width", "5px");
michael@0 59 svg.setCurrentTime(1);
michael@0 60 verifyStyle(text, "font-size", "20px");
michael@0 61 verifyStyle(rect, "stroke-width", "20px");
michael@0 62 svg.setCurrentTime(1.5);
michael@0 63 verifyStyle(text, "font-size", "30px");
michael@0 64 verifyStyle(rect, "stroke-width", "30px");
michael@0 65 svg.setCurrentTime(2);
michael@0 66 verifyStyle(text, "font-size", "40px");
michael@0 67 verifyStyle(rect, "stroke-width", "40px");
michael@0 68 svg.setCurrentTime(3);
michael@0 69 verifyStyle(text, "font-size", "40px");
michael@0 70 verifyStyle(rect, "stroke-width", "40px");
michael@0 71 } catch (e) {
michael@0 72 // If anything goes wrong, make sure we restore textZoom before bubbling
michael@0 73 // the exception upwards, so that we don't mess up subsequent tests.
michael@0 74 SpecialPowers.setTextZoom(window, origTextZoom);
michael@0 75
michael@0 76 throw e;
michael@0 77 }
michael@0 78
michael@0 79 // We're done! Restore original text-zoom before finishing
michael@0 80 SpecialPowers.setTextZoom(window, origTextZoom);
michael@0 81 SimpleTest.finish();
michael@0 82 }
michael@0 83
michael@0 84 window.addEventListener("load", main, false);
michael@0 85 ]]>
michael@0 86 </script>
michael@0 87 </pre>
michael@0 88 </body>
michael@0 89 </html>

mercurial