dom/smil/test/test_smilGetSimpleDuration.xhtml

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 <html xmlns="http://www.w3.org/1999/xhtml">
michael@0 2 <head>
michael@0 3 <title>Test for getSimpleDuration Behavior </title>
michael@0 4 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 5 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 6 </head>
michael@0 7 <body>
michael@0 8 <p id="display"></p>
michael@0 9 <div id="content" style="display: none">
michael@0 10 <svg id="svg" xmlns="http://www.w3.org/2000/svg" width="120px" height="120px">
michael@0 11 <circle cx="20" cy="20" r="15" fill="blue">
michael@0 12 <animate attributeName="cx" attributeType="XML"
michael@0 13 from="20" to="100" begin="1s" id="anim"/>
michael@0 14 </circle>
michael@0 15 </svg>
michael@0 16 </div>
michael@0 17 <pre id="test">
michael@0 18 <script class="testbody" type="text/javascript">
michael@0 19 <![CDATA[
michael@0 20 /** Test for getSimpleDuration Behavior **/
michael@0 21
michael@0 22 /* Global Variables */
michael@0 23 var svg = document.getElementById("svg");
michael@0 24
michael@0 25 SimpleTest.waitForExplicitFinish();
michael@0 26
michael@0 27 function main() {
michael@0 28 var anim = document.getElementById("anim");
michael@0 29
michael@0 30 /* Check initial state */
michael@0 31 checkForException(anim, "dur not set");
michael@0 32
michael@0 33 /* Check basic operation */
michael@0 34 anim.setAttribute("dur", "1s");
michael@0 35 is(anim.getSimpleDuration(), 1);
michael@0 36 anim.setAttribute("dur", "1.5s");
michael@0 37 is(anim.getSimpleDuration(), 1.5);
michael@0 38
michael@0 39 /* Check exceptional states */
michael@0 40 anim.setAttribute("dur", "0s");
michael@0 41 checkForException(anim, "dur=0s");
michael@0 42 anim.setAttribute("dur", "-1s");
michael@0 43 checkForException(anim, "dur=-1s");
michael@0 44 anim.setAttribute("dur", "indefinite");
michael@0 45 checkForException(anim, "dur=indefinite");
michael@0 46 anim.setAttribute("dur", "media");
michael@0 47 checkForException(anim, "dur=media");
michael@0 48 anim.setAttribute("dur", "abc");
michael@0 49 checkForException(anim, "dur=abc");
michael@0 50 anim.removeAttribute("dur");
michael@0 51 checkForException(anim, "dur not set");
michael@0 52
michael@0 53 /* Check range/syntax */
michael@0 54 anim.setAttribute("dur", "100ms");
michael@0 55 millisecondCompare(anim.getSimpleDuration(), 0.1);
michael@0 56 anim.setAttribute("dur", "24h");
michael@0 57 is(anim.getSimpleDuration(), 60 * 60 * 24);
michael@0 58
michael@0 59 SimpleTest.finish();
michael@0 60 }
michael@0 61
michael@0 62 function millisecondCompare(a, b) {
michael@0 63 is(Math.round(a * 1000), Math.round(b * 1000));
michael@0 64 }
michael@0 65
michael@0 66 function checkForException(anim, descr) {
michael@0 67 var gotException = false;
michael@0 68 try {
michael@0 69 var dur = anim.getSimpleDuration();
michael@0 70 } catch(e) {
michael@0 71 is (e.name, "NotSupportedError",
michael@0 72 "Wrong exception from getSimpleDuration");
michael@0 73 is (e.code, DOMException.NOT_SUPPORTED_ERR,
michael@0 74 "Wrong exception from getSimpleDuration");
michael@0 75 gotException = true;
michael@0 76 }
michael@0 77 ok(gotException,
michael@0 78 "Exception not thrown for indefinite simple duration when " + descr);
michael@0 79 }
michael@0 80
michael@0 81 window.addEventListener("load", main, false);
michael@0 82 ]]>
michael@0 83 </script>
michael@0 84 </pre>
michael@0 85 </body>
michael@0 86 </html>

mercurial