| Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-svg-no-intrinsic-size.html
|
| diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-svg-no-intrinsic-size.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-svg-no-intrinsic-size.html
|
| index b6f756b0ff2226c2bc06193d36238e74e1192ed8..3195433396a6f318258f1513b5f8449f377f77f2 100644
|
| --- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-svg-no-intrinsic-size.html
|
| +++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-svg-no-intrinsic-size.html
|
| @@ -6,20 +6,72 @@
|
| <body>
|
| <script>
|
|
|
| -description("Test createImageBitmap from a SVG image without intrinsic size.");
|
| +description("Test createImageBitmap from a SVG image without intrinsic size and with zero size.");
|
| window.jsTestIsAsync = true;
|
|
|
| -var image = new Image();
|
| -image.onload = function() {
|
| - createImageBitmap(image).then(function(imageBitmap) {
|
| - testFailed("createImageBitmap promise resolved, expected to be rejected");
|
| - finishJSTest();
|
| - }, function (e) {
|
| - testPassed("createImageBitmap promise rejected: " + e);
|
| - finishJSTest();
|
| - });
|
| +var image1Loaded = false;
|
| +var image2Loaded = false;
|
| +var image1 = new Image();
|
| +var image2 = new Image();
|
| +image1.onload = function() {
|
| + image1Loaded = true;
|
| + testCreateImageBitmap();
|
| +}
|
| +image1.src = '../../svg/hixie/intrinsic/resources/003.svg';
|
| +image2.onload = function() {
|
| + image2Loaded = true;
|
| + testCreateImageBitmap();
|
| +}
|
| +image2.src = 'resources/zeroSize.svg';
|
| +
|
| +function testCreateImageBitmap()
|
| +{
|
| + if (image1Loaded && image2Loaded) {
|
| + createImageBitmap(image1).then(function(bitmap1) {
|
| + testFailed("createImageBitmap from a SVG without intrinsic size succeed, expected to be rejected");
|
| + finishJSTest();
|
| + }, function (e) {
|
| + testPassed("createImageBitmap from a SVG without intrinsic size rejected: " + e);
|
| + createImageBitmap(image2).then(function(bitmap2) {
|
| + testFailed("createImageBitmap from a SVG with zero size succeed, expected to be rejected");
|
| + finishJSTest();
|
| + }, function(e) {
|
| + testPassed("createImageBitmap from a SVG with zero size rejected: " + e);
|
| + createImageBitmap(image2, 0, 0, 100, 100).then(function(bitmap3) {
|
| + testPassed("createImageBitmap from a zero size SVG with cropRect succeed");
|
| + checkImageBitmap(bitmap3);
|
| + finishJSTest();
|
| + }, function(e) {
|
| + testFailed("createImageBitmap from a zero size SVG with cropRect rejected: " + e);
|
| + finishJSTest();
|
| + });
|
| + });
|
| + });
|
| + }
|
| +}
|
| +
|
| +function shouldBeClear(ctx, x, y) {
|
| + // should be transparent black pixels
|
| + d = ctx.getImageData(x, y, 1, 1).data;
|
| + shouldBe("d[0]", "0");
|
| + shouldBe("d[1]", "0");
|
| + shouldBe("d[2]", "0");
|
| + shouldBe("d[3]", "0");
|
| +}
|
| +
|
| +function checkImageBitmap(bitmap)
|
| +{
|
| + var canvas = document.createElement("canvas");
|
| + canvas.width = 100;
|
| + canvas.height = 100;
|
| + var ctx = canvas.getContext('2d');
|
| + ctx.clearRect(0, 0, 100, 100);
|
| + ctx.drawImage(bitmap, 0, 0);
|
| + shouldBeClear(ctx, 0, 0);
|
| + shouldBeClear(ctx, 0, 99);
|
| + shouldBeClear(ctx, 99, 0);
|
| + shouldBeClear(ctx, 99, 99);
|
| }
|
| -image.src = '../../svg/hixie/intrinsic/resources/003.svg';
|
|
|
| </script>
|
| </body>
|
|
|