summaryrefslogtreecommitdiffstats
path: root/LayoutTests/http/tests/appcache/resources/remove-cache-frame.html
blob: 30e85535da61f2765ecf1bc5056472184206b71f (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
52
53
54
55
56
57
58
59
60
61
62
63
64
<html manifest="fail-on-update.php">
<body>
<div id=result></div>
<script>
function log(message)
{
    document.getElementById("result").innerHTML += message + "<br>";
}

function onObsolete()
{
    log("obsolete")
    log("status=" + applicationCache.status + " (expected 5)");
    applicationCache.onobsolete = function() { log("obsolete") }
    applicationCache.onupdateready = function() { log("updateready") }
    applicationCache.onnoupdate = function() { log("noupdate") }
    applicationCache.onnoupdate = function() { log("error") }

    // We still have a cache, so loading should fail
    try {
        var req = new XMLHttpRequest;
        req.open("GET", "empty.txt", false);
        req.send(null);
        alert("FAIL: XMLHttpRequest for an uncached resource didn't raise an exception");
    } catch (ex) {
    }
    log("There should be no messages below.");
}

function onError()
{
    if (applicationCache.status != applicationCache.UNCACHED && applicationCache.status != applicationCache.OBSOLETE) {
        timeoutId = setTimeout(onNoManifest, 100);
        return;
    }

    log("error");
    applicationCache.onobsolete = function() { log("obsolete") }
    applicationCache.onupdateready = function() { log("updateready") }
    applicationCache.onnoupdate = function() { log("noupdate") }
    applicationCache.onnoupdate = function() { log("error") }

    // Ensure that we are not associated with a cache.
    try {
        var req = new XMLHttpRequest;
        req.open("GET", "empty.txt", false);
        req.send(null);
    } catch (ex) {
        alert("FAIL: XMLHttpRequest raised an exception, " + ex);
    }
    log("There should be no messages below.");
    parent.postMessage("frameDone - timeout", "*");
}

applicationCache.onupdateready = function() { log("updateready"); alert("Unexpected updateready event in frame") }
applicationCache.onnoupdate = function() { log("noupdate") }
applicationCache.oncached = function() { log("cached"); alert("Unexpected cached event in frame") }

applicationCache.onobsolete = onObsolete;
applicationCache.onerror = onError;

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