| Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-animated.html
|
| diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-animated.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-animated.html
|
| index e6acaeb6c6833d9f6086a170a26d1fac96347c9a..8529369955c5010e007b82ebf41989002060ba6d 100644
|
| --- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-animated.html
|
| +++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-animated.html
|
| @@ -1,40 +1,35 @@
|
| -<html>
|
| -<head>
|
| -<script src="../../resources/js-test.js"></script>
|
| -</head>
|
| +<script src="../../resources/testharness.js"></script>
|
| +<script src="../../resources/testharnessreport.js"></script>
|
| <body>
|
| <script>
|
| - window.jsTestIsAsync = true;
|
| +var img = new Image();
|
| +img.onload = imageLoaded;
|
| +img.src = 'resources/green-red-animated.gif';
|
|
|
| - function shouldBeGreen(x, y) {
|
| - d = ctx.getImageData(x, y, 1, 1).data;
|
| - shouldBeTrue("d[0] == 0");
|
| - shouldBeTrue("d[1] == 255");
|
| - shouldBeTrue("d[2] == 0");
|
| - shouldBeTrue("d[3] == 255");
|
| - }
|
| +function consumeImageBitmap(image, t)
|
| +{
|
| + var myCanvas = document.createElement('canvas');
|
| + myCanvas.width = myCanvas.height = 200;
|
| + var myCtx = myCanvas.getContext('bitmaprenderer');
|
| + myCtx.transferFromImageBitmap(image);
|
|
|
| - var canvas = document.createElement("canvas");
|
| - canvas.width = 200;
|
| - canvas.height = 200;
|
| - var ctx = canvas.getContext("2d");
|
| -
|
| - var img = new Image();
|
| - img.onload = imageLoaded;
|
| - img.src = 'resources/green-red-animated.gif';
|
| -
|
| - function imageLoaded() {
|
| + 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.
|
| - window.internals.advanceImageAnimation(img);
|
| - createImageBitmap(img).then(function (imageBitmap) {
|
| - ctx.drawImage(imageBitmap, 0, 0);
|
| - shouldBeGreen(100, 100);
|
| - finishJSTest();
|
| - }, function() {
|
| - testFailed("Promise was rejected.");
|
| - finishJSTest();
|
| + 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>
|
| -</html>
|
|
|