chromium/third_party/blink/web_tests/fast/dom/HTMLScriptElement/script-reexecution.html

<html>
<head>
<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 test() {
    if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.waitUntilDone();
    }

    test = "p1";
    var e1 = document.createElement("script");
    e1.textContent = pass.toString() + " pass();";
    document.getElementsByTagName("head")[0].appendChild(e1);
    document.getElementsByTagName("head")[0].removeChild(e1);

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

    test = "p3";
    e3 = document.createElement("script");
    e3.src = "resources/script-reexecution-pass.js";
    e3.onload = function() { finish(); };
    document.getElementsByTagName("head")[0].appendChild(e3);
}

function finish() {
    test = "p4";

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

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