|
1 <!doctype html> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=941315 |
|
5 --> |
|
6 <head> |
|
7 <meta charset="utf-8"> |
|
8 <title>Test invalid values cause the model to be updated (bug 941315)</title> |
|
9 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
11 </head> |
|
12 <body> |
|
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=941315">Mozilla Bug 941315</a> |
|
14 <p id="display"></p> |
|
15 <div id="content" style="display: none"> |
|
16 <svg width="100%" height="1" onload="this.pauseAnimations()"> |
|
17 <rect> |
|
18 <animate id="a" dur="100s"/> |
|
19 <animate id="b" dur="5s" begin="a.end"/> |
|
20 </rect> |
|
21 <circle cx="-100" cy="20" r="15" fill="blue" id="circle"/> |
|
22 </svg> |
|
23 </div> |
|
24 <pre id="test"> |
|
25 <script class="testbody" type="text/javascript"> |
|
26 var a = $('a'), |
|
27 b = $('b'); |
|
28 |
|
29 // Animation doesn't start until onload |
|
30 SimpleTest.waitForExplicitFinish(); |
|
31 window.addEventListener("load", runTests, false); |
|
32 |
|
33 // Make testing getStartTime easier |
|
34 SVGAnimationElement.prototype.safeGetStartTime = function() { |
|
35 try { |
|
36 return this.getStartTime(); |
|
37 } catch(e) { |
|
38 if (e.name == "InvalidStateError" && |
|
39 e.code == DOMException.INVALID_STATE_ERR) { |
|
40 return 'none'; |
|
41 } else { |
|
42 ok(false, "Unexpected exception: " + e); |
|
43 return null; |
|
44 } |
|
45 } |
|
46 }; |
|
47 |
|
48 function runTests() { |
|
49 [testSimpleDuration, testMin, testMax, testRepeatDur, testRepeatCount] |
|
50 .forEach(function(test) { |
|
51 ise(b.getStartTime(), 100, "initial state before running " + test.name); |
|
52 test(); |
|
53 ise(b.getStartTime(), 100, "final state after running " + test.name); |
|
54 }); |
|
55 SimpleTest.finish(); |
|
56 } |
|
57 |
|
58 function testSimpleDuration() { |
|
59 // Verify a valid value updates as expected |
|
60 a.setAttribute("dur", "50s"); |
|
61 ise(b.safeGetStartTime(), 50, "valid simple duration"); |
|
62 |
|
63 // Check an invalid value also causes the model to be updated |
|
64 a.setAttribute("dur", "abc"); // -> indefinite |
|
65 ise(b.safeGetStartTime(), "none", "invalid simple duration"); |
|
66 |
|
67 // Restore state |
|
68 a.setAttribute("dur", "100s"); |
|
69 } |
|
70 |
|
71 function testMin() { |
|
72 a.setAttribute("min", "200s"); |
|
73 ise(b.safeGetStartTime(), 200, "valid min duration"); |
|
74 |
|
75 a.setAttribute("min", "abc"); // -> indefinite |
|
76 ise(b.safeGetStartTime(), 100, "invalid min duration"); |
|
77 |
|
78 a.removeAttribute("min"); |
|
79 } |
|
80 |
|
81 function testMax() { |
|
82 a.setAttribute("max", "50s"); |
|
83 ise(b.safeGetStartTime(), 50, "valid max duration"); |
|
84 |
|
85 a.setAttribute("max", "abc"); // -> indefinite |
|
86 ise(b.safeGetStartTime(), 100, "invalid max duration"); |
|
87 |
|
88 a.removeAttribute("max"); |
|
89 } |
|
90 |
|
91 function testRepeatDur() { |
|
92 a.setAttribute("repeatDur", "200s"); |
|
93 ise(b.safeGetStartTime(), 200, "valid repeatDur duration"); |
|
94 |
|
95 a.setAttribute("repeatDur", "abc"); // -> indefinite |
|
96 ise(b.safeGetStartTime(), 100, "invalid repeatDur duration"); |
|
97 |
|
98 a.removeAttribute("repeatDur"); |
|
99 } |
|
100 |
|
101 function testRepeatCount() { |
|
102 a.setAttribute("repeatCount", "2"); |
|
103 ise(b.safeGetStartTime(), 200, "valid repeatCount duration"); |
|
104 |
|
105 a.setAttribute("repeatCount", "abc"); // -> indefinite |
|
106 ise(b.safeGetStartTime(), 100, "invalid repeatCount duration"); |
|
107 |
|
108 a.removeAttribute("repeatCount"); |
|
109 } |
|
110 </script> |
|
111 </pre> |
|
112 </body> |
|
113 </html> |