Wed, 31 Dec 2014 06:09:35 +0100
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 getStartTime 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 | onload="this.pauseAnimations()"> |
michael@0 | 12 | <circle cx="20" cy="20" r="15" fill="blue"> |
michael@0 | 13 | <animate attributeName="cx" attributeType="XML" |
michael@0 | 14 | from="20" to="100" begin="indefinite" dur="1s" id="anim"/> |
michael@0 | 15 | </circle> |
michael@0 | 16 | </svg> |
michael@0 | 17 | </div> |
michael@0 | 18 | <pre id="test"> |
michael@0 | 19 | <script class="testbody" type="text/javascript"> |
michael@0 | 20 | <![CDATA[ |
michael@0 | 21 | /** Test for getStartTime Behavior **/ |
michael@0 | 22 | |
michael@0 | 23 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 24 | |
michael@0 | 25 | function main() { |
michael@0 | 26 | var svg = document.getElementById("svg"); |
michael@0 | 27 | ok(svg.animationsPaused(), "should be paused by <svg> load handler"); |
michael@0 | 28 | is(svg.getCurrentTime(), 0, "should be paused at 0 in <svg> load handler"); |
michael@0 | 29 | |
michael@0 | 30 | var anim = document.getElementById("anim"); |
michael@0 | 31 | // indefinite |
michael@0 | 32 | var exceptionCaught = false; |
michael@0 | 33 | try { |
michael@0 | 34 | anim.getStartTime(); |
michael@0 | 35 | } catch(e) { |
michael@0 | 36 | exceptionCaught = true; |
michael@0 | 37 | is(e.name, "InvalidStateError", |
michael@0 | 38 | "Unexpected exception from getStartTime."); |
michael@0 | 39 | is(e.code, DOMException.INVALID_STATE_ERR, |
michael@0 | 40 | "Unexpected exception code from getStartTime."); |
michael@0 | 41 | } |
michael@0 | 42 | ok(exceptionCaught, "No exception thrown for indefinite start time."); |
michael@0 | 43 | |
michael@0 | 44 | // 1s |
michael@0 | 45 | anim.setAttribute("begin", "1s"); |
michael@0 | 46 | is(anim.getStartTime(), 1, "Unexpected start time with begin=1s"); |
michael@0 | 47 | |
michael@0 | 48 | // We have to be careful here when choosing a negative time that we choose |
michael@0 | 49 | // a time that will create an interval that reaches past t=0 as SMIL has |
michael@0 | 50 | // special rules for throwing away intervals that end before t=0 |
michael@0 | 51 | anim.setAttribute("begin", "-0.5s"); |
michael@0 | 52 | is(anim.getStartTime(), -0.5, "Unexpected start time with begin=-0.5s"); |
michael@0 | 53 | |
michael@0 | 54 | // Once the animation has begun, the begin time is fixed so we need to end the |
michael@0 | 55 | // element (or advance the timeline) to override the previous start time |
michael@0 | 56 | anim.endElement(); |
michael@0 | 57 | |
michael@0 | 58 | // However, now we have an end instance, and the SMIL model dictates that if |
michael@0 | 59 | // we have end instances and no end event conditions and all end instances are |
michael@0 | 60 | // before our next begin, there's no valid interval. To overcome this we add |
michael@0 | 61 | // an indefinite end. |
michael@0 | 62 | anim.setAttribute("end", "indefinite"); |
michael@0 | 63 | |
michael@0 | 64 | // Now test over the lifetime of the animation when there are multiple |
michael@0 | 65 | // intervals |
michael@0 | 66 | anim.setAttribute("begin", "1s; 3s"); |
michael@0 | 67 | is(anim.getStartTime(), 1, "Unexpected start time before first interval"); |
michael@0 | 68 | |
michael@0 | 69 | svg.setCurrentTime(1); |
michael@0 | 70 | is(anim.getStartTime(), 1, |
michael@0 | 71 | "Unexpected start time at start of first interval"); |
michael@0 | 72 | |
michael@0 | 73 | svg.setCurrentTime(1.5); |
michael@0 | 74 | is(anim.getStartTime(), 1, "Unexpected start time during first interval"); |
michael@0 | 75 | |
michael@0 | 76 | svg.setCurrentTime(2); |
michael@0 | 77 | is(anim.getStartTime(), 3, "Unexpected start time after first interval"); |
michael@0 | 78 | |
michael@0 | 79 | svg.setCurrentTime(3); |
michael@0 | 80 | is(anim.getStartTime(), 3, "Unexpected start time during second interval"); |
michael@0 | 81 | |
michael@0 | 82 | svg.setCurrentTime(4); |
michael@0 | 83 | exceptionCaught = false; |
michael@0 | 84 | try { |
michael@0 | 85 | anim.getStartTime(); |
michael@0 | 86 | } catch(e) { |
michael@0 | 87 | exceptionCaught = true; |
michael@0 | 88 | is(e.name, "InvalidStateError", |
michael@0 | 89 | "Unexpected exception from getStartTime."); |
michael@0 | 90 | is(e.code, DOMException.INVALID_STATE_ERR, |
michael@0 | 91 | "Unexpected exception code from getStartTime."); |
michael@0 | 92 | } |
michael@0 | 93 | ok(exceptionCaught, "No exception thrown for in postactive state."); |
michael@0 | 94 | |
michael@0 | 95 | SimpleTest.finish(); |
michael@0 | 96 | } |
michael@0 | 97 | |
michael@0 | 98 | window.addEventListener("load", main, false); |
michael@0 | 99 | ]]> |
michael@0 | 100 | </script> |
michael@0 | 101 | </pre> |
michael@0 | 102 | </body> |
michael@0 | 103 | </html> |