Html程序  |  52行  |  1.35 KB

<html manifest="resources/local-content.manifest">
<body>
<p>Test that documents loaded from application cache don't get access to local resources accidentally.</p>
<p>Should say SUCCESS:</p>
<div id="result"></div>
<script type="text/javascript">
if (window.layoutTestController) {
    layoutTestController.dumpAsText()
    layoutTestController.waitUntilDone();
}

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

function noupdate()
{
    var ifr = document.createElement("iframe");
    ifr.setAttribute("src", "file:///usr/include/stdio.h");
    ifr.onload = frameCreated;
    setTimeout(function() {
        log("SUCCESS");
        if (window.layoutTestController)
            layoutTestController.notifyDone();
        }, 300);
        
    document.body.appendChild(ifr);
}

function frameCreated()
{
    log("FAILURE: A local resource was opened in an iframe");
    if (window.layoutTestController)
        layoutTestController.notifyDone();
}

function reload()
{
    // Reload to ensure that the main document was loaded from application cache.
    window.location.reload();
}

applicationCache.addEventListener('noupdate', noupdate, false);

applicationCache.addEventListener('cached', reload, false);
applicationCache.addEventListener('error', function() { alert("Unexpected error event") }, false);

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