<html manifest="resources/manifest-parsing.manifest">
<body>
<p>Test application cache manifest parsing.</p>
<div id=result></div>

<script>
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.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.testRunner)
        testRunner.notifyDone();
}

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

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