Html程序  |  38行  |  1.13 KB

<html manifest="fail-on-update.php">
<body>
<div id=result></div>
<script>
function log(message)
{
    document.getElementById("result").innerHTML += message + "<br>";
}

function test()
{
    log("cached")
    log("status=" + applicationCache.status);
    applicationCache.onnoupdate = null;

    // Associated to 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.");
    parent.postMessage("frameDone", "*");
}

applicationCache.onupdateready = function() { log("updateready"); alert("Unexpected onupdateready event in frame") }
applicationCache.onerror = function() { log("error"); alert("Unexpected error event in frame") }
applicationCache.onnoupdate = function() { log("noupdate"); alert("Unexpected noupdate event in frame") }
applicationCache.onobsolete = function() { log("obsolete"); alert("Unexpected obsolete event in frame") }

applicationCache.oncached = test;

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