| <!DOCTYPE html> |
| <script src="../../resources/js-test-pre.js"></script> |
| <script> |
| description("This test checks that adding an animation to a SVG element does not leak the whole SVGDocument.") |
| |
| function addRect() |
| { |
| var elem = document.createElementNS("http://www.w3.org/2000/svg", "rect"); |
| elem.setAttribute("id", "rect"); |
| elem.setAttribute("x", 50); |
| elem.setAttribute("y", 50); |
| elem.setAttribute("width", 50); |
| elem.setAttribute("height", 50); |
| elem.setAttribute("fill", "blue"); |
| |
| document.getElementById("rootSVG").appendChild(elem); |
| } |
| |
| function applyTransform() |
| { |
| var svgroot = document.getElementById("rootSVG"); |
| var transformList = document.getElementById("rect").transform.baseVal; |
| var rotate = svgroot.createSVGTransform(); |
| rotate.setRotate(15,0,0); |
| transformList.appendItem(rotate); |
| } |
| |
| function removeRect() |
| { |
| document.getElementById("rootSVG").removeChild(document.getElementById("rect")); |
| } |
| |
| function test() |
| { |
| if (!window.internals || !window.GCController) { |
| testFailed("This test requires internals and GCController"); |
| return; |
| } |
| |
| jsTestIsAsync = true; |
| testRunner.dumpAsText(); |
| |
| // One gc() call is not enough and causes flakiness in some platforms. |
| gc(); |
| gc(); |
| var originalLiveElements = internals.numberOfLiveNodes(); |
| |
| addRect(); |
| applyTransform(); |
| removeRect(); |
| |
| requestAnimationFrame(() => { |
| // One gc() call is not enough and causes flakiness in some platforms. |
| gc(); |
| gc(); |
| var delta = internals.numberOfLiveNodes() - originalLiveElements; |
| shouldBeZero(delta.toString()); |
| var successfullyParsed = true; |
| testRunner.notifyDone(); |
| }); |
| } |
| </script> |
| <body onload="test()"> |
| <svg id="rootSVG" width="300" height="300" xmlns="http://www.w3.org/2000/svg" version="1.1"></svg> |
| </body> |