Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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');
29 // Animation doesn't start until onload
30 SimpleTest.waitForExplicitFinish();
31 window.addEventListener("load", runTests, false);
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 };
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 }
58 function testSimpleDuration() {
59 // Verify a valid value updates as expected
60 a.setAttribute("dur", "50s");
61 ise(b.safeGetStartTime(), 50, "valid simple duration");
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");
67 // Restore state
68 a.setAttribute("dur", "100s");
69 }
71 function testMin() {
72 a.setAttribute("min", "200s");
73 ise(b.safeGetStartTime(), 200, "valid min duration");
75 a.setAttribute("min", "abc"); // -> indefinite
76 ise(b.safeGetStartTime(), 100, "invalid min duration");
78 a.removeAttribute("min");
79 }
81 function testMax() {
82 a.setAttribute("max", "50s");
83 ise(b.safeGetStartTime(), 50, "valid max duration");
85 a.setAttribute("max", "abc"); // -> indefinite
86 ise(b.safeGetStartTime(), 100, "invalid max duration");
88 a.removeAttribute("max");
89 }
91 function testRepeatDur() {
92 a.setAttribute("repeatDur", "200s");
93 ise(b.safeGetStartTime(), 200, "valid repeatDur duration");
95 a.setAttribute("repeatDur", "abc"); // -> indefinite
96 ise(b.safeGetStartTime(), 100, "invalid repeatDur duration");
98 a.removeAttribute("repeatDur");
99 }
101 function testRepeatCount() {
102 a.setAttribute("repeatCount", "2");
103 ise(b.safeGetStartTime(), 200, "valid repeatCount duration");
105 a.setAttribute("repeatCount", "abc"); // -> indefinite
106 ise(b.safeGetStartTime(), 100, "invalid repeatCount duration");
108 a.removeAttribute("repeatCount");
109 }
110 </script>
111 </pre>
112 </body>
113 </html>