summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/images/destroyed-image-load-event.html
blob: d0bb91cbb6f5f1d021d97cedaf97e9d5a48b25e2 (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
<body onload="test()">
<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=34490">bug 34490<a/>:
WebCore::ImageEventSender::dispatchPendingEvents() crashes in certain conditions.</p>
<div id="testRun"></div>
<div id="container"></div>
<script>
if (window.testRunner) {
    testRunner.waitUntilDone();
    testRunner.dumpAsText();
}

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("abc");
    }
}

var container = document.getElementById("container");
var testRunDiv = document.getElementById("testRun");
var remainingTestRuns = 30;

function test()
{
    testRunDiv.innerHTML = remainingTestRuns;

    if (--remainingTestRuns < 0) {
        testRunDiv.innerHTML = "PASS";
        if (window.testRunner)
            testRunner.notifyDone();
        return;
    }

    container.innerHTML = '<img src="resources/boston.gif" onload="loaded1()">' +
        '<img src="resources/boston.gif" onload="loaded2()">';
}

function loaded1()
{
    var img2 = document.getElementsByTagName("img")[1];
    img2.src = "";
    container.removeChild(img2);
    img2 = null;
    gc();
    setTimeout(test, 0);
}

function loaded2()
{
}
</script>
</body>