summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/images/onload-event-when-reloading-image-after-interrupted-null-src-load.html
blob: 9b8b9f89b1b50211ff0a1df313a76d7ed08a323b (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
<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<script>
    if (window.testRunner) {
        testRunner.waitUntilDone();
        testRunner.dumpAsText();
    }
    img = new Image();
    var onloadCounter = 0;
    var testImage = 'resources/green.jpg';
    var resetImage = '';
    img.onload = function(){
        onloadCounter++;
        debug("Image onload event fired for " + img.src.substring(img.src.lastIndexOf('/') + 1));
        if (onloadCounter == 2) {
            document.getElementById('result').textContent = "PASS";
            if (window.testRunner)
                testRunner.notifyDone();
            return;
        }
        if (onloadCounter == 1) {
            setTimeout(function() {
                img.src= resetImage;
                img.src = testImage;
                }, 0);
            return;
        }
        document.getElementById('result').textContent = "FAIL";
    };
    setTimeout(function() {
        img.src= resetImage;
        img.src = testImage;
        }, 0);
</script>
<div id="console">
crbug.com/469678: We should fire an image load event even if the image is the last one we loaded successfully.<br>
In this test we load an image. Then we make a null request (img.src='') which should clear down the image before we attempt to load the same image again.<br>
</div>
<div id="result">FAIL</div>