chromium/third_party/blink/web_tests/fast/canvas/canvas-createImageBitmap-animated.html

<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<body>
<script>
var img = new Image();
img.onload = imageLoaded;
img.src = 'resources/green-red-animated.gif';

function consumeImageBitmap(image, t)
{
    var myCanvas = document.createElement('canvas');
    myCanvas.width = myCanvas.height = 200;
    var myCtx = myCanvas.getContext('bitmaprenderer');
    myCtx.transferFromImageBitmap(image);

    createImageBitmap(myCanvas).then(t.step_func_done(function(imageBitmap) {
        var dstCanvas = document.createElement('canvas');
        dstCanvas.width = dstCanvas.height = 200;
        var dstCtx = dstCanvas.getContext('2d');
        dstCtx.clearRect(0, 0, 200, 200);
        dstCtx.drawImage(imageBitmap, 0, 0);
        // If the ImageBitmap is green, we know that it is a snapshot of the gif's 0th frame.
        assert_array_equals(dstCtx.getImageData(100, 100, 1, 1).data, [0, 255, 0, 255]);
    }));
}

function imageLoaded() {
    async_test(function(t) {
        createImageBitmap(img).then(function(image) {
            consumeImageBitmap(image, t);
        });
    }, 'Test that createImageBitmap from an animated gif produces correct result.');
}
</script>
</body>