• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<body onload="test()">
2<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>
3<p>PASS if didn't crash.</p>
4<iframe src="about:blank"></iframe>
5
6<script>
7
8function gc()
9{
10    if (window.GCController)
11        return GCController.collect();
12
13    for (var i = 0; i < 10000; i++) { // > force garbage collection (FF requires about 9K allocations before a collect)
14        var s = new String("");
15    }
16}
17
18if (window.layoutTestController) {
19    layoutTestController.dumpAsText();
20    layoutTestController.waitUntilDone();
21}
22
23var ifrCache;
24
25function test()
26{
27    ifrCache = frames[0].applicationCache;
28    document.body.removeChild(document.getElementsByTagName("iframe")[0]);
29    setTimeout(function() {
30        gc();
31        ifrCache.onchecking = function() { }
32        ifrCache.onerror = function() { }
33        ifrCache.onnoupdate = function() { }
34        ifrCache.ondownloading = function() { }
35        ifrCache.onprogress = function() { }
36        ifrCache.onupdateready = function() { }
37        ifrCache.oncached = function() { }
38        ifrCache.onobsolete = function() { }
39        ifrCache.addEventListener("error", function() { }, true);
40
41        var evt = document.createEvent("Event");
42        evt.initEvent("error", true, true);
43        ifrCache.dispatchEvent(evt);
44
45        try { ifrCache.update(); } catch (ex) { }
46        try { ifrCache.swapCache(); } catch (ex) { }
47
48        if (window.layoutTestController)
49            layoutTestController.notifyDone();
50    }, 0);
51}
52</script>
53