<!DOCTYPE html>
<!-- Test for WK84657 - Test passes if the SVG animation does not crash and "PASS" is printed. -->
<html>
<head>
<script>
    function crash() {
        var useRectElement = document.getElementById('useRect');
        useRectElement.setAttributeNS("http://www.w3.org/1999/xlink", "href", "#rect");
    }
    function startTest() {
        if (window.testRunner) {
            testRunner.waitUntilDone();
            testRunner.dumpAsText();
        }
        var svgElement = document.getElementById('svg');
        window.setTimeout(function() {
            crash();
            window.setTimeout(function() {
                svgElement.setCurrentTime(100);
                document.write("PASS");
                if (window.testRunner)
                    testRunner.notifyDone();
            }, 20); // This needs to be at least 20 to ensure an animation cycle runs.
        }, 1);
    }
</script>
</head>
<body onload="startTest()">
<svg id="svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <defs>
        <rect id="rect" x="100px" y="100px" width="100px" height="100px" fill="green">
            <animate attributeName="x" from="100" to="0" begin="0s" dur="5s" repeatCount="1"/>
        </rect>
    </defs>
    <use x="100px" y="100px" xlink:href="#rect"/>
    <use id="useRect" x="100px" y="200px"/>
</svg>
</body>
</html>
