OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <script src="../js/resources/js-test-pre.js"></script> |
| 4 </head> |
| 5 <body> |
| 6 <script> |
| 7 window.jsTestIsAsync = true; |
| 8 |
| 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"); |
| 15 } |
| 16 |
| 17 var canvas = document.createElement("canvas"); |
| 18 canvas.width = 200; |
| 19 canvas.height = 200; |
| 20 var ctx = canvas.getContext("2d"); |
| 21 |
| 22 var img = new Image(); |
| 23 img.src = 'resources/green-red-animated.gif'; |
| 24 img.onload = imageLoaded; |
| 25 |
| 26 function imageLoaded() { |
| 27 // The gif switches from green to red in 10ms. We wait 50ms to ensure th
at the gif will have changed colors. |
| 28 // If the ImageBitmap is green, we know that it is a snapshot of the gif
's 0th frame. |
| 29 window.setTimeout(function() { |
| 30 createImageBitmap(img).then(function (imageBitmap) { |
| 31 ctx.drawImage(imageBitmap, 0, 0); |
| 32 shouldBeGreen(100, 100); |
| 33 finishJSTest(); |
| 34 }, function() { |
| 35 testFailed("Promise was rejected."); |
| 36 finishJSTest(); |
| 37 }); |
| 38 }, 50); |
| 39 } |
| 40 </script> |
| 41 <script src="../js/resources/js-test-post.js"></script> |
| 42 </body> |
| 43 </html> |
OLD | NEW |