<html>
<script>
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

t = 0;
    
function runTest(f) {
    var result = document.getElementById('result');
    
    switch (t++) {
        case 0:
            if (f.contentWindow.ranScript != true) {
                result.innerHTML = 'FAILURE - did not run script first time'

                if (window.testRunner)
                    testRunner.notifyDone();
                return;
            }
            f.contentWindow.location.href='about:blank';
            break;
        case 1:
            if (f.contentWindow.ranScript != undefined) {
                result.innerHTML = 'FAILURE - ranScript variable is not undefined'

                if (window.testRunner)
                    testRunner.notifyDone();
                return;                
            }
            f.contentWindow.location.href='resources/cached-scripts-subframe.html';
            break;
        case 2:
            if (f.contentWindow.ranScript != true)
                result.innerHTML = 'FAILURE - did not run script second time';
            else
                result.innerHTML = 'SUCCESS';

            if (window.testRunner)
                testRunner.notifyDone();
                
            break;
    }
}
</script>
<div>This tests that when script that calls document.write to write out two new script tags while being parsed causes both scripts to be executed, even if the first one is cached.</div>
<div id="result">FAILURE</div>
<iframe src="resources/cached-scripts-subframe.html" onload="runTest(this)"> 
</iframe>
</html>
