summaryrefslogtreecommitdiffstats
path: root/dom/smil/test/test_smilRepeatTiming.xhtml
blob: 74a9c17afe863f945d64ebd3e53a434fded3e8d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=485157
-->
<head>
  <title>Test repeat timing</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank"
  href="https://bugzilla.mozilla.org/show_bug.cgi?id=485157">Mozilla Bug
  485157</a>
<p id="display"></p>
<div id="content" style="display: none">
<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="100px" height="100px">
  <rect width="100" height="100" fill="green">
    <set attributeName="width" to="100" dur="20s" repeatCount="5" begin="0s"
      id="a" onrepeat="startWaiting(evt)"/>
    <set attributeName="fill" attributeType="CSS" to="green"
      begin="a.repeat(1)" onbegin="expectedBegin()" dur="20s"/>
    <set attributeName="x" to="100"
      begin="a.repeat(2)" onbegin="unexpectedBegin(this)" dur="20s"/>
    <set attributeName="y" to="100"
      begin="a.repeat(0)" onbegin="unexpectedBegin(this)" dur="20s"/>
    <set attributeName="width" to="100"
      begin="a.repeat(-1)" onbegin="unexpectedBegin(this)" dur="20s"/>
    <set attributeName="height" to="100"
      begin="a.repeat(a)" onbegin="unexpectedBegin(this)" dur="20s"/>
  </rect>
</svg>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
<![CDATA[
/** Test SMIL repeat timing **/

/* Global Variables */
const gTimeoutDur = 5000; // Time until we give up waiting for events in ms
var gSvg  = document.getElementById('svg');
var gRect = document.getElementById('circle');
var gTimeoutID;
var gGotBegin = false;

SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");

function testBegin()
{
  gSvg.setCurrentTime(19.999);
}

function startWaiting(evt)
{
  is(evt.detail, 1, "Unexpected repeat event received: test broken");
  if (gGotBegin)
    return;

  gTimeoutID = setTimeout(timeoutFail, gTimeoutDur);
}

function timeoutFail()
{
  ok(false, "Timed out waiting for begin event");
  finish();
}

function expectedBegin()
{
  is(gGotBegin, false,
     "Got begin event more than once for non-repeating animation");
  gGotBegin = true;
  clearTimeout(gTimeoutID);
  // Wait a moment before finishing in case there are erroneous events waiting
  // to be processed.
  setTimeout(finish, 10);
}

function unexpectedBegin(elem)
{
  ok(false, "Got unexpected begin from animation with spec: " +
            elem.getAttribute('begin'));
}

function finish()
{
  gSvg.pauseAnimations();
  SimpleTest.finish();
}

window.addEventListener("load", testBegin, false);
]]>
</script>
</pre>
</body>
</html>