summaryrefslogtreecommitdiffstats
path: root/LayoutTests/http/tests/appcache/destroyed-frame.html
blob: c1dd731c8670f8974fd0b2332d14a9f955ad5e91 (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
<body onload="test()">
<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=33813">bug 33813</a>: Crash when using DOMApplicationCache from a destroyed frame.</p>
<p>PASS if didn't crash.</p>
<iframe src="about:blank"></iframe>

<script>

function gc()
{
    if (window.GCController)
        return GCController.collect();

    for (var i = 0; i < 10000; i++) { // > force garbage collection (FF requires about 9K allocations before a collect)
        var s = new String("");
    }
}

if (window.layoutTestController) {
    layoutTestController.dumpAsText();
    layoutTestController.waitUntilDone();
}

var ifrCache;

function test()
{
    ifrCache = frames[0].applicationCache;
    document.body.removeChild(document.getElementsByTagName("iframe")[0]);
    setTimeout(function() {
        gc();
        ifrCache.onchecking = function() { }
        ifrCache.onerror = function() { }
        ifrCache.onnoupdate = function() { }
        ifrCache.ondownloading = function() { }
        ifrCache.onprogress = function() { }
        ifrCache.onupdateready = function() { }
        ifrCache.oncached = function() { }
        ifrCache.onobsolete = function() { }
        ifrCache.addEventListener("error", function() { }, true);

        var evt = document.createEvent("Event");
        evt.initEvent("error", true, true);
        ifrCache.dispatchEvent(evt);

        try { ifrCache.update(); } catch (ex) { }
        try { ifrCache.swapCache(); } catch (ex) { }

        if (window.layoutTestController)
            layoutTestController.notifyDone();
    }, 0);
}
</script>