<!DOCTYPE html>
<html>
<body>
<p>Test that we do not fire the svg load event when the SVGElement is detached.</p>
<p>This test passes if you see no alert.</p>
<script>
if (window.testRunner)
    testRunner.dumpAsText();

const payloads = [
    '<svg xmlns="http://www.w3.org/2000/svg"><g onload=alert("FAIL1")></g></svg>',
    '<svg onload=alert("FAIL2")>'
];

for (let payload of payloads) {
    document.createElement('body').innerHTML = payload;

    document.implementation.createHTMLDocument().write(payload);

    new DOMParser().parseFromString(payload, 'text/html');

    var xhr = new XMLHttpRequest;
    xhr.responseType='document'
    xhr.open('GET', 'data:text/html,', false);
    xhr.send(null);
    xhr.response.body.innerHTML=payload;
}
</script>
</body>
</html>
