<html>
<body>
<p>Test that the manifest is picked correctly when reloading.</p>
<p>Should say SUCCESS:</p>
<div id=result></div>

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

function log(message)
{
    document.getElementById("result").innerHTML += message + "<br>";
}

var state = 0;
function receivedMessage(message)
{
    log(message);

    if (state == 0) {
        state = 1;
        setTimeout("frames[0].location.reload()", 0);
    } else if (state == 1) {
        state = 2;
        setTimeout("frames[0].test()", 0);
    } else if (state == 2) {
        if (window.testRunner)
            testRunner.notifyDone();
    }
}

window.addEventListener("message", function(e) { receivedMessage(e.data) }, false);

</script>
<iframe src="resources/reload-iframe.html"></iframe>
</body>
</html>
