summaryrefslogtreecommitdiffstats
path: root/LayoutTests/http/tests/appcache/main-resource-redirect.html
blob: 3ede636a59ab34d63357c161815bb61e44b56d38 (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
<html manifest="resources/main-resource-redirect.manifest">
<body>
<p>Test that application cache is consulted again after a redirect response.</p>
<div id="result">Testing...</div>
<script>
if (window.layoutTestController) {
    layoutTestController.waitUntilDone();
    layoutTestController.dumpAsText();
}

function setNetworkEnabled(state)
{
    var req = new XMLHttpRequest;
    req.open("GET", "/resources/network-simulator.php?command=" + (state ? "connect" : "disconnect"), false);
    req.send("");
}

function test()
{
    applicationCache.oncached = null;
    applicationCache.onnoupdate = null;
    setNetworkEnabled(false);
    var ifr = document.createElement("iframe");
    ifr.setAttribute("src", "resources/main-resource-redirect-frame.php");
    document.body.appendChild(ifr);
}

function done()
{
    if (window.layoutTestController)
        layoutTestController.notifyDone();
    setNetworkEnabled(true);
}

applicationCache.oncached=test;
applicationCache.onnoupdate=test;
applicationCache.onerror = function() { setNetworkEnabled(true); window.location.reload(); }
</script>
</body>