<!DOCTYPE html>
<html>
    <!-- Test for wkbug.com/88144 - Crash in SVGDocumentExtensions::removeAllElementReferencesForTarget. -->
    <head>
        <script>
            if (window.testRunner)
                testRunner.dumpAsText();

            window.onload = function() {
                svg0 = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
                svg0.setAttribute('id', 'svg0');
                document.body.appendChild(svg0);

                document.body.appendChild(document.createTextNode('A'));

                svg1 = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
                svg1.setAttribute('id', 'svg1');
                svg1.appendChild(document.createTextNode('A'));
                document.body.appendChild(svg1);

                document.body.appendChild(document.createTextNode('A'));

                image = document.createElementNS('http://www.w3.org/2000/svg', 'image');
                image.setAttribute('id', 'image');
                svg0.appendChild(image);

                textPath = document.createElementNS('http://www.w3.org/2000/svg', 'textPath');
                textPath.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '#svg1');
                textPath.setAttribute('id', 'textPath');
                image.appendChild(textPath);

                use = document.createElementNS('http://www.w3.org/2000/svg', 'use');
                use.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '#image');
                use.setAttribute('id', 'use');
                svg0.appendChild(use);

                image.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '#svg0');
                document.designMode = 'on';
                window.getSelection().setBaseAndExtent(svg1, 0, svg1, 0);
                document.execCommand('ForwardDelete');

                document.body.offsetTop;
                document.body.innerHTML = "PASS";
            }
        </script>
    </head>
    <body>
    </body>
</html>
