summaryrefslogtreecommitdiffstats
path: root/LayoutTests/http/tests/appcache/fail-on-update.html
blob: b021fcc72ce7d06c251d43945ee5bf8d70f3e37d (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
<html manifest="resources/fail-on-update.php">
<script>
if (window.layoutTestController) {
    layoutTestController.dumpAsText();
    layoutTestController.waitUntilDone();
}

function setManifestDeleted(state)
{
    var req = new XMLHttpRequest;
    req.open("GET", "resources/fail-on-update.php?command=" + (state ? "delete" : "reset"), false);
    req.send(null);
}

function test()
{
    clearTimeout(timeoutId);

    setManifestDeleted(true);
    applicationCache.update();
    window.location = 'data:text/html,<p>SUCCESS: No crash.</p>' + 
        '<script>' +
            'if (window.layoutTestController) layoutTestController.notifyDone();' +
        '</scri' + 'pt>';
}

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

    setManifestDeleted(false);
    location.reload();
}

applicationCache.addEventListener('noupdate', function() { setTimeout(test, 0) }, false);
applicationCache.addEventListener('cached', function() { setTimeout(test, 0) }, false);

// If the manifest script happened to be in a wrong state, reset it.
var timeoutId = setTimeout(resetManifest, 100);

</script>
<p>Test for a particular incorrect assertion failure.</p>

</html>