summaryrefslogtreecommitdiffstats
path: root/LayoutTests/http/tests/appcache/manifest-parsing.html
blob: 46a7fddc173da8886ec9430e1fc0acf6cb074730 (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
65
66
<html manifest="resources/manifest-parsing.manifest">
<body>
<p>Test application cache manifest parsing.</p>
<div id=result></div>

<script>
if (window.layoutTestController) {
    layoutTestController.dumpAsText();
    layoutTestController.waitUntilDone();
}

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

function canLoad(url)
{
    try {
        var req = new XMLHttpRequest();
        req.open("GET", url, false);
        req.send();
        return true;
    } catch (e) {
        return false;
    }
}

function test()
{
    var hadError = false;
    
    // Check that section name wasn't misparsed as resource URL.
    if (canLoad("resources/UNKNOWN:")) {
        log("Loaded 'UNKNOWN:'");
        hadError = true;
    }

    // Load a resource that was in UNKNOWN section - in other words, that is not in cache.
    if (canLoad("resources/not-in-cache.txt")) {
        log("Loaded 'not-in-cache.txt'");
        hadError = true;
    }

    // Load resources were specified with tricky whitespace.
    if (!canLoad("resources/empty.txt")) {
        log("Could not load 'empty.txt'");
        hadError = true;
    }
    if (!canLoad("resources/simple.txt")) {
        log("Could not load 'simple.txt'");
        hadError = true;
    }

    log(hadError ? "FAILURE" : "SUCCESS");
    if (window.layoutTestController)
        layoutTestController.notifyDone();
}

applicationCache.onnoupdate = function() { test() }
applicationCache.oncached = function() { test() }

applicationCache.onerror = function() { log("error") }
</script>
</body>
</html>