<!DOCTYPE html>
<html>
<head>
<script>
    if (window.internals && window.testRunner) {
        internals.clearMemoryCache();
        internals.settings.setLargeImageAsyncDecodingEnabled(true);
        internals.settings.setWebkitImageReadyEventEnabled(true);
        testRunner.dumpAsText(true);
        testRunner.waitUntilDone();
    }
</script>
</head>
<body>
    PASS if no assertion failure
    <img>
    <script>
        var img = document.getElementsByTagName('img')[0];
        img.onload = function() {
            // Force layout and display so the image frame starts decoding.
            document.body.offsetHeight;
            if (window.testRunner)
                testRunner.display();
        }
        img.addEventListener("webkitImageFrameReady", function() {
            // Force the page to be displayed. The image element is already invalidated when the frame finished decoding.
            if (window.testRunner)
                testRunner.display();
            // Change the width of the img element
            img.width = "100";
            // notifyDone() will force the last layout and display.
            if (window.testRunner)
                testRunner.notifyDone();
        });
        img.src = 'resources/animated-red-green-1000x1000-repeat-1.gif';
    </script>
</body>
</html>
