chromium/third_party/blink/web_tests/http/tests/images/image-currentsrc-load.html

<!DOCTYPE html>
<script src="/js-test-resources/js-test.js"></script>
<body>
<script>
    document.body.innerHTML += '<img id="load" src="http://127.0.0.1:8000/resources/slow-image-dimensions.php?name=square100.png&mimeType=image/png&sleep=100">';
    jsTestIsAsync = true;
    var img = window.document.getElementById("load");
    shouldBe('img.currentSrc', '""');
    shouldBe('img.width', '0');
    var interval = setInterval(function() {
        if (img.width != 0) {
            shouldBe('img.currentSrc', '"http://127.0.0.1:8000/resources/slow-image-dimensions.php?name=square100.png&mimeType=image/png&sleep=100"');
            shouldBe('img.width', '100');
            clearInterval(interval);
            img.src = "http://127.0.0.1:8000/resources/slow-image-dimensions.php?name=square200.png&mimeType=image/png&sleep=100";
            shouldBe('img.currentSrc', '"http://127.0.0.1:8000/resources/slow-image-dimensions.php?name=square100.png&mimeType=image/png&sleep=100"');
            shouldBe('img.width', '100');
            var interval2 = setInterval(function() {
                if (img.width != 100) {
                    shouldBe('img.currentSrc', '"http://127.0.0.1:8000/resources/slow-image-dimensions.php?name=square200.png&mimeType=image/png&sleep=100"');
                    shouldBe('img.width', '200');
                    clearInterval(interval2);
                    setTimeout(finishJSTest, 100);
                }
            }, 10);
        }
    }, 10);
</script>
</body>