chromium/third_party/blink/web_tests/svg/dom/SVGScriptElement/script-reexecution.svg

<?xml version="1.0"?>
<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xhtml="http://www.w3.org/1999/xhtml" onload="startTest()">
<defs>
<script type="text/javascript">
function pass() {
    var contentElement = document.getElementById(test);

    if (contentElement.textContent == 'PASS') {
        contentElement.textContent = 'FAIL';
    } else if (contentElement.textContent == 'FAIL') {
        contentElement.textContent = 'PASS';
    }
}

function startTest() {
    if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.waitUntilDone();
    }

    test = "p1";
    var e1 = document.createElementNS("http://www.w3.org/2000/svg", "svg:script");
    e1.textContent = pass.toString() + " pass();";
    document.getElementsByTagName("defs")[0].appendChild(e1);
    document.getElementsByTagName("defs")[0].removeChild(e1);

    test = "p2";
    document.getElementsByTagName("defs")[0].appendChild(e1);
    document.getElementsByTagName("defs")[0].removeChild(e1);

    test = "p3";
    message = "PASS";

    e3 = document.createElementNS("http://www.w3.org/2000/svg", "svg:script");
    e3.href.baseVal = "resources/script-reexecution.js";
    document.getElementsByTagName("defs")[0].appendChild(e3);
}

function finish() {
    test = "p4";
    message = "FAIL";

    e3.onload = "";
    document.getElementsByTagName("defs")[0].removeChild(e3);
    document.getElementsByTagName("defs")[0].appendChild(e3);

    if (window.testRunner)
        testRunner.notifyDone();
}
</script>
</defs>
<foreignObject>
<xhtml:p>Created script element, script data passed as text content, appended: <xhtml:span id="p1">FAIL</xhtml:span></xhtml:p>
<xhtml:p>Removed element, readd element, remove again, script shouldn't have executed:<xhtml:span id="p2">PASS</xhtml:span></xhtml:p>
<xhtml:p>Created script element, loading external script content, appended: <xhtml:span id="p3">FAIL</xhtml:span></xhtml:p>
<xhtml:p>Removed element, readd element, script shouldn't have executed: <xhtml:span id="p4">PASS</xhtml:span></xhtml:p>
</foreignObject>
</svg>