<!DOCTYPE html>
<html>
<meta name="fuzzy" content="maxDifference=0-1;totalPixels=28600-29000" />
<style>
    .box {
        height: 50px;
        display: inline-block;
        zoom: 2;
        image-rendering: crisp-edges;
    }
    .green-box {
        width: 100px;
        background-position: -50px -16500px;
    }
    .repeat-box {
        width: 400px;
        background-position: 0px -16500px;
        background-repeat: repeat-x;
    }
    .image-background {
    }
</style>
<body>
    <div class="box green-box image-background"></div>
    <br>
    <div class="box repeat-box image-background"></div>
    <script>
        function setElementImageBackground(element, image) {
            return new Promise((resolve) => {
                element.style.backgroundImage = 'url(' + image.src + ')';

                // Force layout and display so the image frame starts decoding.
                document.body.offsetHeight;
                testRunner.display();
 
                element.addEventListener("webkitImageFrameReady", function() {
                    resolve();
                }, false);
            });
        }

        (function() {
            if (window.internals && window.testRunner) {
                internals.clearMemoryCache();
                internals.settings.setWebkitImageReadyEventEnabled(true);
                internals.settings.setLargeImageAsyncDecodingEnabled(true);
                testRunner.waitUntilDone();
            }

            var image = new Image();
            image.onload = function() {
                 // Force async image decoding for this image.
                if (window.internals)
                    internals.setLargeImageAsyncDecodingEnabledForTesting(image, true);

                // Change the background of the elements.
                var elements = document.getElementsByClassName("image-background");
                if (window.internals && window.testRunner) {
                    var promises = [];
                    for (var index = 0; index < elements.length; ++index)
                        promises.push(setElementImageBackground(elements[index], image));
 
                    Promise.all(promises).then(() => {
                        // Ensure internals.destroyDecodedDataForAllImages() will not destroy
                        // the images' decoded data because it is inside the viewport.
                        internals.destroyDecodedDataForAllImages();
                        testRunner.notifyDone();
                    });
                } else {
                    for (var index = 0; index < elements.length; ++index)
                        elements[index].style.backgroundImage = 'url(' + image.src + ')';
                }
            }
            image.src = "resources/sprite-sheet-red-green-blue.png";
        })();
    </script>
</body>
</html>
