1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/smil/test/test_smilInvalidValues.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,113 @@ 1.4 +<!doctype html> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=941315 1.8 +--> 1.9 +<head> 1.10 + <meta charset="utf-8"> 1.11 + <title>Test invalid values cause the model to be updated (bug 941315)</title> 1.12 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.14 +</head> 1.15 +<body> 1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=941315">Mozilla Bug 941315</a> 1.17 +<p id="display"></p> 1.18 +<div id="content" style="display: none"> 1.19 +<svg width="100%" height="1" onload="this.pauseAnimations()"> 1.20 + <rect> 1.21 + <animate id="a" dur="100s"/> 1.22 + <animate id="b" dur="5s" begin="a.end"/> 1.23 + </rect> 1.24 + <circle cx="-100" cy="20" r="15" fill="blue" id="circle"/> 1.25 +</svg> 1.26 +</div> 1.27 +<pre id="test"> 1.28 +<script class="testbody" type="text/javascript"> 1.29 + var a = $('a'), 1.30 + b = $('b'); 1.31 + 1.32 + // Animation doesn't start until onload 1.33 + SimpleTest.waitForExplicitFinish(); 1.34 + window.addEventListener("load", runTests, false); 1.35 + 1.36 + // Make testing getStartTime easier 1.37 + SVGAnimationElement.prototype.safeGetStartTime = function() { 1.38 + try { 1.39 + return this.getStartTime(); 1.40 + } catch(e) { 1.41 + if (e.name == "InvalidStateError" && 1.42 + e.code == DOMException.INVALID_STATE_ERR) { 1.43 + return 'none'; 1.44 + } else { 1.45 + ok(false, "Unexpected exception: " + e); 1.46 + return null; 1.47 + } 1.48 + } 1.49 + }; 1.50 + 1.51 + function runTests() { 1.52 + [testSimpleDuration, testMin, testMax, testRepeatDur, testRepeatCount] 1.53 + .forEach(function(test) { 1.54 + ise(b.getStartTime(), 100, "initial state before running " + test.name); 1.55 + test(); 1.56 + ise(b.getStartTime(), 100, "final state after running " + test.name); 1.57 + }); 1.58 + SimpleTest.finish(); 1.59 + } 1.60 + 1.61 + function testSimpleDuration() { 1.62 + // Verify a valid value updates as expected 1.63 + a.setAttribute("dur", "50s"); 1.64 + ise(b.safeGetStartTime(), 50, "valid simple duration"); 1.65 + 1.66 + // Check an invalid value also causes the model to be updated 1.67 + a.setAttribute("dur", "abc"); // -> indefinite 1.68 + ise(b.safeGetStartTime(), "none", "invalid simple duration"); 1.69 + 1.70 + // Restore state 1.71 + a.setAttribute("dur", "100s"); 1.72 + } 1.73 + 1.74 + function testMin() { 1.75 + a.setAttribute("min", "200s"); 1.76 + ise(b.safeGetStartTime(), 200, "valid min duration"); 1.77 + 1.78 + a.setAttribute("min", "abc"); // -> indefinite 1.79 + ise(b.safeGetStartTime(), 100, "invalid min duration"); 1.80 + 1.81 + a.removeAttribute("min"); 1.82 + } 1.83 + 1.84 + function testMax() { 1.85 + a.setAttribute("max", "50s"); 1.86 + ise(b.safeGetStartTime(), 50, "valid max duration"); 1.87 + 1.88 + a.setAttribute("max", "abc"); // -> indefinite 1.89 + ise(b.safeGetStartTime(), 100, "invalid max duration"); 1.90 + 1.91 + a.removeAttribute("max"); 1.92 + } 1.93 + 1.94 + function testRepeatDur() { 1.95 + a.setAttribute("repeatDur", "200s"); 1.96 + ise(b.safeGetStartTime(), 200, "valid repeatDur duration"); 1.97 + 1.98 + a.setAttribute("repeatDur", "abc"); // -> indefinite 1.99 + ise(b.safeGetStartTime(), 100, "invalid repeatDur duration"); 1.100 + 1.101 + a.removeAttribute("repeatDur"); 1.102 + } 1.103 + 1.104 + function testRepeatCount() { 1.105 + a.setAttribute("repeatCount", "2"); 1.106 + ise(b.safeGetStartTime(), 200, "valid repeatCount duration"); 1.107 + 1.108 + a.setAttribute("repeatCount", "abc"); // -> indefinite 1.109 + ise(b.safeGetStartTime(), 100, "invalid repeatCount duration"); 1.110 + 1.111 + a.removeAttribute("repeatCount"); 1.112 + } 1.113 +</script> 1.114 +</pre> 1.115 +</body> 1.116 +</html>