summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/dom/gc-image-element-2.html
blob: b1fd2ae7e1b7f167e3dda4b041d41b7484582f88 (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
<p>Tests for image elements firing their load events even when they're not in the document. Should say "onload fired" ten times, and then "PASS".</p>
<pre id="console"></pre>

<script src="../../resources/js-test.js"></script>
<script>
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

function $(id)
{
    return document.getElementById(id);
}

function log(s)
{
    $("console").appendChild(document.createTextNode(s + "\n"));
}

var imageCount = 0;

function createImage()
{
    ++imageCount;
    var image = new Image;
    image.src = "resources/apple.gif";
    image.onload = function () {
        log("onload fired...");
        gc();

        --imageCount;
        if (!imageCount) {
            log("PASS");
            if (window.testRunner)
                testRunner.notifyDone();
        }
    };
    image = null;
}

for (var i = 0; i < 10; ++i)
    createImage();

</script>