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
|
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Test conditional processing tests applied to animations</title>
<script 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">
<svg id="svg" width="120px" height="120px"
onload="this.pauseAnimations()">
<circle r="50" fill="blue" id="circle">
<set attributeName="cy" to="100" begin="0s" dur="100s" id="a"/>
<set attributeName="cx" to="100" begin="a.end" dur="100s" id="b"/>
</circle>
</svg>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
function run() {
SpecialPowers.pushPrefEnv({"set": [["intl.accept_languages", "en"]]}, runInternal);
}
function runInternal() {
var svg = document.getElementById("svg"),
a = document.getElementById("a"),
b = document.getElementById("b"),
circle = document.getElementById("circle");
// Check initial state
svg.setCurrentTime(50);
is(a.getStartTime(), 0, "a has resolved start time at start");
is(circle.cy.animVal.value, 100, "a is in effect at start");
is(b.getStartTime(), 100, "b has resolved start time at start");
// Add a failing conditional processing test
a.setAttribute("systemLanguage", "no-such-language");
ok(hasUnresolvedStartTime(a),
"a has unresolved start time with failing conditional processing test");
is(circle.cy.animVal.value, 0,
"a is not in effect with failing conditional processing test");
ok(hasUnresolvedStartTime(b),
"b has unresolved start time with failing conditional processing test on a");
// Remove failing conditional processing test
a.removeAttribute("systemLanguage");
is(a.getStartTime(), 0, "a has resolved start time after removing test");
is(circle.cy.animVal.value, 100, "a is in effect after removing test");
is(b.getStartTime(), 100, "b has resolved start time after removing test on a");
// Add another failing conditional processing test
// According to the spec, if a null string or empty string value is set for
// the 'systemLanguage' attribute, the attribute returns "false".
a.setAttribute("systemLanguage", "");
// Fast forward until |a| would have finished
var endEventsReceived = 0;
a.addEventListener("endEvent", function() { endEventsReceived++; });
svg.setCurrentTime(150);
is(endEventsReceived, 0,
"a does not dispatch end events with failing condition processing test");
is(circle.cx.animVal.value, 0,
"b is not in effect with failing conditional processing test on a");
// Make test pass
a.setAttribute("systemLanguage", "en");
is(circle.cx.animVal.value, 100,
"b is in effect with passing conditional processing test on a");
SimpleTest.finish();
}
function hasUnresolvedStartTime(anim) {
// getStartTime throws INVALID_STATE_ERR when there is no current interval
try {
anim.getStartTime();
return false;
} catch (e) {
return true;
}
}
window.addEventListener("load", run);
</script>
</pre>
</body>
</html>
|