dom/smil/test/test_smilGetSimpleDuration.xhtml

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/smil/test/test_smilGetSimpleDuration.xhtml	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,86 @@
     1.4 +<html xmlns="http://www.w3.org/1999/xhtml">
     1.5 +<head>
     1.6 +  <title>Test for getSimpleDuration Behavior </title>
     1.7 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.8 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     1.9 +</head>
    1.10 +<body>
    1.11 +<p id="display"></p>
    1.12 +<div id="content" style="display: none">
    1.13 +<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="120px" height="120px">
    1.14 +  <circle cx="20" cy="20" r="15" fill="blue">
    1.15 +    <animate attributeName="cx" attributeType="XML" 
    1.16 +      from="20" to="100" begin="1s" id="anim"/>
    1.17 +  </circle>
    1.18 +</svg>
    1.19 +</div>
    1.20 +<pre id="test">
    1.21 +<script class="testbody" type="text/javascript">
    1.22 +<![CDATA[
    1.23 +/** Test for getSimpleDuration Behavior  **/
    1.24 +
    1.25 +/* Global Variables */
    1.26 +var svg = document.getElementById("svg");
    1.27 +
    1.28 +SimpleTest.waitForExplicitFinish();
    1.29 +
    1.30 +function main() {
    1.31 +  var anim = document.getElementById("anim");
    1.32 +
    1.33 +  /* Check initial state */
    1.34 +  checkForException(anim, "dur not set");
    1.35 +
    1.36 +  /* Check basic operation */
    1.37 +  anim.setAttribute("dur", "1s");
    1.38 +  is(anim.getSimpleDuration(), 1);
    1.39 +  anim.setAttribute("dur", "1.5s");
    1.40 +  is(anim.getSimpleDuration(), 1.5);
    1.41 +
    1.42 +  /* Check exceptional states */
    1.43 +  anim.setAttribute("dur", "0s");
    1.44 +  checkForException(anim, "dur=0s");
    1.45 +  anim.setAttribute("dur", "-1s");
    1.46 +  checkForException(anim, "dur=-1s");
    1.47 +  anim.setAttribute("dur", "indefinite");
    1.48 +  checkForException(anim, "dur=indefinite");
    1.49 +  anim.setAttribute("dur", "media");
    1.50 +  checkForException(anim, "dur=media");
    1.51 +  anim.setAttribute("dur", "abc");
    1.52 +  checkForException(anim, "dur=abc");
    1.53 +  anim.removeAttribute("dur");
    1.54 +  checkForException(anim, "dur not set");
    1.55 +
    1.56 +  /* Check range/syntax */
    1.57 +  anim.setAttribute("dur", "100ms");
    1.58 +  millisecondCompare(anim.getSimpleDuration(), 0.1);
    1.59 +  anim.setAttribute("dur", "24h");
    1.60 +  is(anim.getSimpleDuration(), 60 * 60 * 24);
    1.61 +
    1.62 +  SimpleTest.finish();
    1.63 +}
    1.64 +
    1.65 +function millisecondCompare(a, b) {
    1.66 +  is(Math.round(a * 1000), Math.round(b * 1000));
    1.67 +}
    1.68 +
    1.69 +function checkForException(anim, descr) {
    1.70 +  var gotException = false;
    1.71 +  try {
    1.72 +    var dur = anim.getSimpleDuration();
    1.73 +  } catch(e) {
    1.74 +    is (e.name, "NotSupportedError",
    1.75 +        "Wrong exception from getSimpleDuration");
    1.76 +    is (e.code, DOMException.NOT_SUPPORTED_ERR,
    1.77 +        "Wrong exception from getSimpleDuration");
    1.78 +    gotException = true;
    1.79 +  }
    1.80 +  ok(gotException,
    1.81 +     "Exception not thrown for indefinite simple duration when " + descr);
    1.82 +}
    1.83 +
    1.84 +window.addEventListener("load", main, false);
    1.85 +]]>
    1.86 +</script>
    1.87 +</pre>
    1.88 +</body>
    1.89 +</html>

mercurial