<!DOCTYPE HTML>
<html>
    <head>
        <!--
        Test for WK89846: Animations should be rewindable even with existing fill=freeze animations.
        If this test passes, only the word "PASS" will be visible.
        -->
        <script src="../../resources/js-test-pre.js"></script>
    </head>
    <body>
        <svg id="svg" width="500" height="500">
            <rect x="0" y="0" width="100" height="100" fill="red"/>
            <rect id="rect" x="0" y="0" width="100" height="100" fill="blue">
                <set attributeName="x" to="100" begin="4s" fill="freeze"></set>
                <set attributeName="x" to="200" begin="1s" dur="1s" fill="freeze">
            </rect>
        </svg>
        <script>
            if (window.testRunner) {
                testRunner.waitUntilDone();
                testRunner.dumpAsText();
            }

            var svg = document.getElementById('svg');
            var rect = document.getElementById('rect');
            svg.pauseAnimations();
            svg.setCurrentTime(100);

            setTimeout(function() {
                svg.setCurrentTime(0);
                if (rect.x.animVal.value != 0)
                    document.body.innerHTML = "FAIL: rect.x.animVal.value was " + rect.x.animVal.value + ", expected 0";
                else
                    document.body.innerHTML = "PASS";

                if (window.testRunner)
                    testRunner.notifyDone();
            }, 1);
        </script>
    </body>
</html>
