2009-01-19 01:10:53 -08:00
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
|
|
<head>
|
|
|
|
<title>Test for getStartTime Behavior </title>
|
|
|
|
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
2010-03-10 12:33:37 -08:00
|
|
|
<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="120px" height="120px"
|
|
|
|
onload="this.pauseAnimations()">
|
2009-01-19 01:10:53 -08:00
|
|
|
<circle cx="20" cy="20" r="15" fill="blue">
|
|
|
|
<animate attributeName="cx" attributeType="XML"
|
|
|
|
from="20" to="100" begin="indefinite" dur="1s" id="anim"/>
|
|
|
|
</circle>
|
|
|
|
</svg>
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
<![CDATA[
|
|
|
|
/** Test for getStartTime Behavior **/
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
function main() {
|
2010-03-10 12:33:37 -08:00
|
|
|
var svg = document.getElementById("svg");
|
|
|
|
ok(svg.animationsPaused(), "should be paused by <svg> load handler");
|
|
|
|
is(svg.getCurrentTime(), 0, "should be paused at 0 in <svg> load handler");
|
2009-10-30 15:15:14 -07:00
|
|
|
|
2010-03-10 12:33:37 -08:00
|
|
|
var anim = document.getElementById("anim");
|
2009-01-19 01:10:53 -08:00
|
|
|
// indefinite
|
2009-10-12 16:14:08 -07:00
|
|
|
var exceptionCaught = false;
|
|
|
|
try {
|
|
|
|
anim.getStartTime();
|
|
|
|
} catch(e) {
|
|
|
|
exceptionCaught = true;
|
|
|
|
is(e.code, DOMException.INVALID_STATE_ERR,
|
|
|
|
"Unexpected exception code from getStartTime.");
|
|
|
|
}
|
|
|
|
ok(exceptionCaught, "No exception thrown for indefinite start time.");
|
2009-01-19 01:10:53 -08:00
|
|
|
|
|
|
|
// 1s
|
|
|
|
anim.setAttribute("begin", "1s");
|
|
|
|
is(anim.getStartTime(), 1, "Unexpected start time with begin=1s");
|
|
|
|
|
|
|
|
// We have to be careful here when choosing a negative time that we choose
|
|
|
|
// a time that will create an interval that reaches past t=0 as SMIL has
|
|
|
|
// special rules for throwing away intervals that end before t=0
|
|
|
|
anim.setAttribute("begin", "-0.5s");
|
|
|
|
is(anim.getStartTime(), -0.5, "Unexpected start time with begin=-0.5s");
|
|
|
|
|
2010-01-12 12:00:49 -08:00
|
|
|
// Once the animation has begun, the begin time is fixed so we need to end the
|
|
|
|
// element (or advance the timeline) to override the previous start time
|
|
|
|
anim.endElement();
|
|
|
|
|
|
|
|
// However, now we have an end instance, and the SMIL model dictates that if
|
|
|
|
// we have end instances and no end event conditions and all end instances are
|
|
|
|
// before our next begin, there's no valid interval. To overcome this we add
|
|
|
|
// an indefinite end.
|
|
|
|
anim.setAttribute("end", "indefinite");
|
|
|
|
|
2009-01-19 01:10:53 -08:00
|
|
|
// Now test over the lifetime of the animation when there are multiple
|
|
|
|
// intervals
|
|
|
|
anim.setAttribute("begin", "1s; 3s");
|
2009-01-21 17:00:27 -08:00
|
|
|
is(anim.getStartTime(), 1, "Unexpected start time before first interval");
|
|
|
|
|
2009-01-19 01:10:53 -08:00
|
|
|
svg.setCurrentTime(1);
|
2009-01-21 17:00:27 -08:00
|
|
|
is(anim.getStartTime(), 1,
|
|
|
|
"Unexpected start time at start of first interval");
|
2009-01-19 01:10:53 -08:00
|
|
|
|
|
|
|
svg.setCurrentTime(1.5);
|
2009-01-21 17:00:27 -08:00
|
|
|
is(anim.getStartTime(), 1, "Unexpected start time during first interval");
|
2009-01-19 01:10:53 -08:00
|
|
|
|
|
|
|
svg.setCurrentTime(2);
|
2009-10-12 16:14:08 -07:00
|
|
|
is(anim.getStartTime(), 3, "Unexpected start time after first interval");
|
2009-01-19 01:10:53 -08:00
|
|
|
|
|
|
|
svg.setCurrentTime(3);
|
2009-01-21 17:00:27 -08:00
|
|
|
is(anim.getStartTime(), 3, "Unexpected start time during second interval");
|
2009-01-19 01:10:53 -08:00
|
|
|
|
|
|
|
svg.setCurrentTime(4);
|
2009-10-12 16:14:08 -07:00
|
|
|
exceptionCaught = false;
|
|
|
|
try {
|
|
|
|
anim.getStartTime();
|
|
|
|
} catch(e) {
|
|
|
|
exceptionCaught = true;
|
|
|
|
is(e.code, DOMException.INVALID_STATE_ERR,
|
|
|
|
"Unexpected exception code from getStartTime.");
|
|
|
|
}
|
|
|
|
ok(exceptionCaught, "No exception thrown for in postactive state.");
|
2009-01-19 01:10:53 -08:00
|
|
|
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
window.addEventListener("load", main, false);
|
|
|
|
]]>
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|