<html>
<head>
<script type="text/javascript">
var p5result = "FAIL";

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

    document.getElementById("p5").innerHTML = p5result;
    
    document.getElementById("s1").src = "resources/script-set-src-p1fail.js";
    document.getElementById("s2").src = "resources/script-set-src-p2fail.js";
    document.getElementById("s5").src = "resources/script-set-src-p5fail.js";
    document.getElementById("s3").src = "resources/script-set-src-p3pass.js";
    document.getElementById("s6").setAttribute("src", "resources/script-set-src-p6pass.js");
    
    var e1 = document.createElement( "script" );
    e1.type  = "text/javascript";
    e1.src = "resources/script-set-src-p7pass.js";
    document.getElementsByTagName("head")[0].appendChild(e1);

    var e2 = document.createElement( "script" );
    e2.type  = "text/javascript";
    document.getElementsByTagName("head")[0].appendChild(e2);
    e2.src = "resources/script-set-src-p8pass.js";
    
    var e3 = document.createElement( "script" );
    e3.type  = "text/javascript";
    e3.setAttribute("onload", "if (window.testRunner) setTimeout('testRunner.notifyDone()', 100)"); 
    e3.src = "resources/script-set-src-p9failBefore.js";
    e3.src = "resources/script-set-src-p9pass.js";
    document.getElementsByTagName("head")[0].appendChild(e3);
    e3.src = "resources/script-set-src-p9failAfter.js";
    
}
</script>
<script type="text/javascript" id="s1">
// Parser-created. Has text so it should not load upon setting src.
</script>
<script type="text/javascript" id="s2" src="resources/thisShouldNotExist.null"></script>
<script type="text/javascript" id="s5" src="resources/script-set-src-p5pass.js"></script>
<script type="text/javascript" id="s3"></script>
<!-- s4 was a self-closing script tag, however that is covered by fast/parser/script-tag-with-trailing-slash.html -->
<script type="text/javascript" id="s6"></script>
</head>
<body onload="test();">
<p>Parser-created script elements:</p>
<p>Already containing text: <span id="p1">PASS</span></p>
<p>Already specifying missing source: <span id="p2">PASS</span></p>
<p>Already specifying valid source: <span id="p5">FAIL</span></p>
<p>No text and no source: <span id="p3">FAIL</span></p>
<p>Using setAttribute: <span id="p6">FAIL</span></p>
<hr>
<p>Dynamically-inserted script elements:</p>
<p>Set before insertion: <span id="p7">FAIL</span></p>
<p>Set after insertion: <span id="p8">FAIL</span></p>
<p>Set twice before and once after insertion: <span id="p9">FAIL</span></p>
</body>
