summaryrefslogtreecommitdiffstats
path: root/LayoutTests/http/tests/appcache/local-content.html
blob: 07875675c7b6d6841e950b195c91bea2a54875e6 (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
<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>