1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/smil/test/test_smilRepeatTiming.xhtml Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,95 @@ 1.4 +<html xmlns="http://www.w3.org/1999/xhtml"> 1.5 +<!-- 1.6 +https://bugzilla.mozilla.org/show_bug.cgi?id=485157 1.7 +--> 1.8 +<head> 1.9 + <title>Test repeat timing</title> 1.10 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.11 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.12 +</head> 1.13 +<body> 1.14 +<a target="_blank" 1.15 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=485157">Mozilla Bug 1.16 + 485157</a> 1.17 +<p id="display"></p> 1.18 +<div id="content" style="display: none"> 1.19 +<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="100px" height="100px"> 1.20 + <rect width="100" height="100" fill="green"> 1.21 + <set attributeName="width" to="100" dur="20s" repeatCount="5" begin="0s" 1.22 + id="a" onrepeat="startWaiting(evt)"/> 1.23 + <set attributeName="fill" attributeType="CSS" to="green" 1.24 + begin="a.repeat(1)" onbegin="expectedBegin()" dur="20s"/> 1.25 + <set attributeName="x" to="100" 1.26 + begin="a.repeat(2)" onbegin="unexpectedBegin(this)" dur="20s"/> 1.27 + <set attributeName="y" to="100" 1.28 + begin="a.repeat(0)" onbegin="unexpectedBegin(this)" dur="20s"/> 1.29 + <set attributeName="width" to="100" 1.30 + begin="a.repeat(-1)" onbegin="unexpectedBegin(this)" dur="20s"/> 1.31 + <set attributeName="height" to="100" 1.32 + begin="a.repeat(a)" onbegin="unexpectedBegin(this)" dur="20s"/> 1.33 + </rect> 1.34 +</svg> 1.35 +</div> 1.36 +<pre id="test"> 1.37 +<script class="testbody" type="text/javascript"> 1.38 +<![CDATA[ 1.39 +/** Test SMIL repeat timing **/ 1.40 + 1.41 +/* Global Variables */ 1.42 +const gTimeoutDur = 5000; // Time until we give up waiting for events in ms 1.43 +var gSvg = document.getElementById('svg'); 1.44 +var gRect = document.getElementById('circle'); 1.45 +var gTimeoutID; 1.46 +var gGotBegin = false; 1.47 + 1.48 +SimpleTest.waitForExplicitFinish(); 1.49 + 1.50 +function testBegin() 1.51 +{ 1.52 + gSvg.setCurrentTime(19.999); 1.53 +} 1.54 + 1.55 +function startWaiting(evt) 1.56 +{ 1.57 + is(evt.detail, 1, "Unexpected repeat event received: test broken"); 1.58 + if (gGotBegin) 1.59 + return; 1.60 + 1.61 + gTimeoutID = setTimeout(timeoutFail, gTimeoutDur); 1.62 +} 1.63 + 1.64 +function timeoutFail() 1.65 +{ 1.66 + ok(false, "Timed out waiting for begin event"); 1.67 + finish(); 1.68 +} 1.69 + 1.70 +function expectedBegin() 1.71 +{ 1.72 + is(gGotBegin, false, 1.73 + "Got begin event more than once for non-repeating animation"); 1.74 + gGotBegin = true; 1.75 + clearTimeout(gTimeoutID); 1.76 + // Wait a moment before finishing in case there are erroneous events waiting 1.77 + // to be processed. 1.78 + setTimeout(finish, 10); 1.79 +} 1.80 + 1.81 +function unexpectedBegin(elem) 1.82 +{ 1.83 + ok(false, "Got unexpected begin from animation with spec: " + 1.84 + elem.getAttribute('begin')); 1.85 +} 1.86 + 1.87 +function finish() 1.88 +{ 1.89 + gSvg.pauseAnimations(); 1.90 + SimpleTest.finish(); 1.91 +} 1.92 + 1.93 +window.addEventListener("load", testBegin, false); 1.94 +]]> 1.95 +</script> 1.96 +</pre> 1.97 +</body> 1.98 +</html>