summaryrefslogtreecommitdiffstats
path: root/LayoutTests/http/tests/appcache/origin-delete.html
blob: 26c4890764166e10386e797ca6c024b6ab6658a0 (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
<html>
<head>
<script>

// Helpers.

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

// Start and end.

function startTest() {
    if (window.layoutTestController) {
        layoutTestController.clearAllApplicationCaches();
        layoutTestController.dumpApplicationCacheDelegateCallbacks();
        layoutTestController.dumpAsText();
        layoutTestController.waitUntilDone();
    }

    addIFrameWithAppCache();
}

function finishTest() {
    if (window.layoutTestController)
        layoutTestController.notifyDone();
}

function addIFrameWithAppCache() {
    var iframe = document.createElement("iframe");
    iframe.src = "resources/origin-delete-iframe.html";
    iframe.id = "cachedFrame";
    document.body.appendChild(iframe);
    
    window.onmessage = function(event) {
        log(event.data);
        if (event.data === "PASS - cached iframe-1") {
            log("clearing cache for origin");
            layoutTestController.clearApplicationCacheForOrigin("http://127.0.0.1:8000");
            var frame = document.getElementById('cachedFrame');
            frame.contentWindow.postMessage("appcache_status", "*");
        } else if (event.data === "appcache_status=5"){
            log("SUCCESS - cache was made obsolete");
            finishTest();
        } else {
            log("FAIL - received unexpected message " + event.data);
            finishTest();
        }
    };
}
</script>
</head>
<body onload="startTest()">
<p>This test checks that application cache groups correctly become obsolete after application cache is deletion for a specific origin.
</p>
<pre id="console"></pre>
</body>
</html>