<html>
<body>
<p>Test that offline applications' main resources are not affected by URL hashes.</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>";
}

function setNetworkEnabled(state)
{
    var req = new XMLHttpRequest;
    req.open("GET", "/resources/network-simulator.py?test=appcache-main-resource-main-resource-hash&command=" + (state ? "connect" : "disconnect"), false);
    req.send("");
}

function frameCreated()
{
    if (stage == 0) {
        stage = 1;
        setNetworkEnabled(false);
        var ifr = document.createElement("iframe");
        ifr.setAttribute("src", "/resources/network-simulator.py?test=appcache-main-resource-main-resource-hash&path=/appcache/resources/main-resource-hash-frame.html#bar");
        document.body.appendChild(ifr);
    } else {
        log("SUCCESS");
        setNetworkEnabled(true);
        if (window.testRunner)
            testRunner.notifyDone()
    }
}

window.addEventListener("message", frameCreated, false);

var stage = 0;
setNetworkEnabled(true);
var ifr = document.createElement("iframe");
ifr.setAttribute("src", "/resources/network-simulator.py?test=appcache-main-resource-main-resource-hash&path=/appcache/resources/main-resource-hash-frame.html#foo");
document.body.appendChild(ifr);

</script>
</body>
</html>
