summaryrefslogtreecommitdiffstats
path: root/LayoutTests/http/tests/appcache/main-resource-hash.html
blob: 6dbce36b2770925a57e25de72c6a3f0f934cd9a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<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.layoutTestController) {
    layoutTestController.dumpAsText();
    layoutTestController.waitUntilDone();
}

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

function setNetworkEnabled(state)
{
    var req = new XMLHttpRequest;
    req.open("GET", "/resources/network-simulator.php?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.php?path=/appcache/resources/main-resource-hash-frame.html#bar");
        document.body.appendChild(ifr);
    } else {
        log("SUCCESS");
        setNetworkEnabled(true);
        if (window.layoutTestController)
            layoutTestController.notifyDone()
    }
}

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

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

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