<!DOCTYPE html>
<html>
<head>
<style>
svg {
    height: 128px;
    width: 128px;
}
</style>
</head>
<body>
<!-- This tests that we don't cause an assertion failure when implicitly removing a <use> (by removing its parent), with the same id as other elements, that is referenced by a later <use> in a different SVG subtree. -->
<svg id="svg1">
    <defs>
        <rect id="bad" x="0" y="0" width="128" height="128" fill="red"></rect>
    </defs>
    <use id="A" xlink:href="#bad"></use>
    <use id="A" xlink:href="#bad"></use>
</svg>
<svg>
    <defs>
        <rect id="good" x="0" y="0" width="128" height="128" fill="green"></rect>
        <use id="A" xlink:href="#good"></use> <!-- [1] -->
    </defs>
    <use xlink:href="#A"></use> <!-- [2] -->
</svg>
<script>
var svg = document.getElementById("svg1");
document.body.removeChild(svg); // [2] will depend on [1]
</script>
</body>
</html>
