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