invalid-elem-1.xhtml (3041B)
1 <?xml version="1.0" encoding="UTF-8" standalone="no" ?> 2 <html xmlns="http://www.w3.org/1999/xhtml" class="reftest-wait"> 3 <head> 4 <title>Valid, invalid, valid</title> 5 <!-- 6 PURPOSE: When manipulating the DOM tree it is quite likely that at some 7 instant the document will be invalid such as during a chain of 8 operations. SVG 1.1, section F.2 states: 9 10 "Because of situations where a block of scripting changes might cause 11 a given SVG document fragment to go into and out of error, error 12 processing shall occur only at times when document presentation (e.g., 13 rendering to the display device) is updated" 14 15 A similar requirement exists regarding unsuspend / suspend redraw. 16 This test checks that behaviour. 17 18 OPERATION: There is a box and a circle. Initially the circle is animated and 19 should move to the right. The animation element is moved to the rectangle. 20 At this point the animation points to an invalid attribute. This attribute 21 is then updated to be valid again. 22 23 EXPECTED RESULTS: The circle is moved and then the rectangle is moved. There 24 should not be any errors reported in the Javascript console or assertions 25 etc. 26 27 After the animation is removed from the circle it should reset (I think). 28 29 Currently this hasn't been implemented (we need to make use of 30 mLastCompositors table in nsSMILAnimationController), so this test is 31 disabled for now. As the code stands now you'll normally get the correct 32 result but under other conditions the circle moves a fraction before the 33 call to pauseAnimations and this effect is not then cleared. 34 --> 35 <script> 36 function moveAnimation() 37 { 38 var svg = document.getElementsByTagName('svg')[0]; 39 svg.pauseAnimations(); 40 svg.setCurrentTime(0.5); 41 doMove(); 42 svg.setCurrentTime(1.0); 43 setTimeout('document.documentElement.removeAttribute("class")', 0); 44 } 45 46 function doMove() 47 { 48 var anim = document.getElementById('animation-to-move'); 49 anim.parentNode.removeChild(anim); 50 var rect = document.getElementById('target'); 51 rect.appendChild(anim); 52 // The animation is now in error 53 anim.setAttribute('attributeName', 'x'); 54 // Now it's fixed 55 } 56 </script> 57 </head> 58 59 <body onload="moveAnimation()"> 60 <svg xmlns="http://www.w3.org/2000/svg" width="200px" height="200px"> 61 <rect x="0" y="0" width="199" height="199" 62 style="fill: none; stroke: black"/> 63 <!-- rect to be animated second --> 64 <rect x="-20" y="80" width="40" height="40" fill="royalblue" 65 stroke="black" stroke-width="1" id="target"/> 66 <!-- circle to be animated first --> 67 <circle cx="0" cy="100" r="15" fill="skyblue" stroke="black" 68 stroke-width="1"> 69 <animate attributeName="cx" from="0" to="200" begin="0s" dur="2s" 70 fill="freeze" id="animation-to-move"/> 71 </circle> 72 </svg> 73 </body> 74 </html>