Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-svg.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-svg.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-svg.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2fb0bb38846094233287b6a5fc30d762eb655641 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-svg.html |
| @@ -0,0 +1,48 @@ |
| +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| +<html> |
| +<head> |
| +<script src="../../resources/js-test.js"></script> |
| +</head> |
| +<body> |
| +<script> |
| + |
| +description("Test createImageBitmap from a SVG image."); |
| +window.jsTestIsAsync = true; |
| + |
| +function shouldBeBlue(x, y) { |
| + d = ctx.getImageData(x, y, 1, 1).data; |
| + shouldBe("d[0]", "0"); |
|
sof
2016/04/14 19:29:26
shouldBeEqualToNumber("d[0]", 0);
etc.
|
| + shouldBe("d[1]", "0"); |
| + shouldBe("d[2]", "255"); |
| + shouldBe("d[3]", "255"); |
| +} |
| + |
| +var canvas = document.createElement("canvas"); |
| +canvas.setAttribute("width", "200"); |
| +canvas.setAttribute("height", "200"); |
| +var ctx = canvas.getContext("2d"); |
| +var bitmap; |
| + |
| +var image = new Image(); |
| +image.onload = function() { |
| + createImageBitmap(image).then(function(imageBitmap) { |
| + bitmap = imageBitmap; |
| + shouldBe("bitmap.width", "200"); |
| + shouldBe("bitmap.height", "200"); |
| + ctx.clearRect(0, 0, 200, 200); |
| + ctx.drawImage(imageBitmap, 0, 0); |
| + shouldBeBlue(0, 0); |
| + shouldBeBlue(0, 199); |
| + shouldBeBlue(199, 0); |
| + shouldBeBlue(199, 199); |
| + finishJSTest(); |
| + }, function (e) { |
| + testFailed("createImageBitmap promise rejected: " + e); |
| + finishJSTest(); |
| + }); |
| +} |
| +image.src = '../../svg/as-image/resources/200x200-blue-rect.svg'; |
| + |
| +</script> |
| +</body> |
| +</html> |