tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_smilTextZoom.xhtml (3587B)


      1 <html xmlns="http://www.w3.org/1999/xhtml">
      2 <head>
      3  <title>Test for SMIL Animation Behavior with textZoom</title>
      4  <script 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">
     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 
     34  // Bug 1379908: The computed value of stroke-* properties should be
     35  // serialized with px units, but currently Gecko and Servo don't do that
     36  // when animating these values.
     37  if ('stroke-width' == aPropertyName) {
     38    var expectedVal = SMILUtil.stripPx(aExpectedVal);
     39    var unitlessComputedVal = SMILUtil.stripPx(computedVal);
     40    is(unitlessComputedVal, expectedVal, "computed value of " + aPropertyName);
     41    return;
     42  }
     43  is(computedVal, aExpectedVal, "computed value of " + aPropertyName);
     44 }
     45 
     46 function main()
     47 {
     48  // Start out pause
     49  var svg = SMILUtil.getSVGRoot();
     50  ok(svg.animationsPaused(), "should be paused by <svg> load handler");
     51  is(svg.getCurrentTime(), 0, "should be paused at 0 in <svg> load handler");
     52 
     53  // Set text zoom to 2x
     54  var origTextZoom =  SpecialPowers.getTextZoom(window);
     55  SpecialPowers.setTextZoom(window, 2);
     56 
     57  try {
     58    // Verify computed style values at various points during animation.
     59    // * Correct behavior is for the computed values of 'font-size' to be
     60    // the same as their corresponding specified values, since text zoom
     61    // should not affect SVG text elements.
     62    // * I also include tests for an identical animation of the "stroke-width"
     63    // property, which should _not_ be affected by textZoom.
     64    var text = document.getElementsByTagName("text")[0];
     65    var rect = document.getElementsByTagName("rect")[0];
     66 
     67    verifyStyle(text, "font-size",    "5px");
     68    verifyStyle(rect, "stroke-width", "5px");
     69    svg.setCurrentTime(1);
     70    verifyStyle(text, "font-size",    "20px");
     71    verifyStyle(rect, "stroke-width", "20px");
     72    svg.setCurrentTime(1.5);
     73    verifyStyle(text, "font-size",    "30px");
     74    verifyStyle(rect, "stroke-width", "30px");
     75    svg.setCurrentTime(2);
     76    verifyStyle(text, "font-size",    "40px");
     77    verifyStyle(rect, "stroke-width", "40px");
     78    svg.setCurrentTime(3);
     79    verifyStyle(text, "font-size",    "40px");
     80    verifyStyle(rect, "stroke-width", "40px");
     81  } catch (e) {
     82    // If anything goes wrong, make sure we restore textZoom before bubbling
     83    // the exception upwards, so that we don't mess up subsequent tests.
     84    SpecialPowers.setTextZoom(window, origTextZoom);
     85 
     86    throw e;
     87  }
     88 
     89  // We're done! Restore original text-zoom before finishing
     90  SpecialPowers.setTextZoom(window, origTextZoom);
     91  SimpleTest.finish();
     92 }
     93 
     94 window.addEventListener("load", main);
     95 ]]>
     96 </script>
     97 </pre>
     98 </body>
     99 </html>