3 <script src=
"../../resources/js-test.js"></script>
7 window
.jsTestIsAsync
= true;
9 function shouldBeGreen(x
, y
) {
10 d
= ctx
.getImageData(x
, y
, 1, 1).data
;
11 shouldBeTrue("d[0] == 0");
12 shouldBeTrue("d[1] == 255");
13 shouldBeTrue("d[2] == 0");
14 shouldBeTrue("d[3] == 255");
17 var canvas
= document
.createElement("canvas");
20 var ctx
= canvas
.getContext("2d");
22 var img
= new Image();
23 img
.onload
= imageLoaded
;
24 img
.src
= 'resources/green-red-animated.gif';
26 function imageLoaded() {
27 // If the ImageBitmap is green, we know that it is a snapshot of the gif's 0th frame.
28 window
.internals
.advanceImageAnimation(img
);
29 createImageBitmap(img
).then(function (imageBitmap
) {
30 ctx
.drawImage(imageBitmap
, 0, 0);
31 shouldBeGreen(100, 100);
34 testFailed("Promise was rejected.");