Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-fillPath-alpha-shadow.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-fillPath-alpha-shadow.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-fillPath-alpha-shadow.html |
| index 324e67b8d2b19a7c4ec1cd3522e573a37676bc04..eb2ac4aa26446cfb11059899c2c58dfc0e07479f 100644 |
| --- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-fillPath-alpha-shadow.html |
| +++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-fillPath-alpha-shadow.html |
| @@ -1,9 +1,93 @@ |
| -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| -<html> |
| -<head> |
| -<script src="../../resources/js-test.js"></script> |
| -</head> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| <body> |
| -<script src="script-tests/canvas-fillPath-alpha-shadow.js"></script> |
| +<script> |
| +test(function(t) { |
| + |
| +var canvas = document.createElement('canvas'); |
|
Justin Novosad
2017/02/06 20:04:23
indent
zakerinasab
2017/02/09 18:02:00
Done.
|
| +document.body.appendChild(canvas); |
| +canvas.setAttribute('width', '600'); |
| +canvas.setAttribute('height', '1100'); |
| +var ctx = canvas.getContext('2d'); |
| + |
| +ctx.save(); |
| +ctx.fillStyle = 'rgba(0, 0, 255, 0.5)'; |
| +ctx.shadowColor = 'rgba(255, 0, 0, 0.5)'; |
| +ctx.shadowOffsetX = 250; |
| + |
| +function fillShape(x, y) { |
| + ctx.beginPath(); |
| + ctx.arc(x, y, 100, 0, Math.PI*2, true); |
| + ctx.arc(x, y, 50, 0, Math.PI*2, false); |
| + ctx.fill(); |
| +} |
| + |
| +// Alpha shadow. |
| +ctx.shadowBlur = 0; |
| +fillShape(150, 150); |
| + |
| +// Blurry shadow. |
| +ctx.shadowBlur = 10; |
| +fillShape(150, 400); |
| + |
| +ctx.rotate(Math.PI/2); |
| + |
| +// Rotated alpha shadow. |
| +ctx.shadowBlur = 0; |
| +fillShape(650, -150); |
| + |
| +// Rotated blurry shadow. |
| +ctx.shadowBlur = 10; |
| +fillShape(900, -150); |
| + |
| +ctx.restore(); |
| + |
| +var imageData, data; |
| +ctx.fillStyle = 'black'; |
| + |
| +function test(x, y, r, g, b, a, alphaApprox) { |
|
Justin Novosad
2017/02/06 20:04:23
call this something else. It has a name conflict w
zakerinasab
2017/02/09 18:02:00
Done.
|
| + // Get pixel. |
| + imageData = ctx.getImageData(x, y, 1, 1); |
| + data = imageData.data; |
| + // Test pixel color components. |
| + assert_equals(data[0], r); |
| + assert_equals(data[1], g); |
| + assert_equals(data[2], b); |
| + if (alphaApprox === undefined) |
| + alphaApprox = 15; |
| + assert_approx_equals(data[3], a, alphaApprox); |
| + // Plot test point. |
| + ctx.fillRect(x, y, 3, 3); |
| +} |
| + |
| +// Verifying alpha shadow... |
| +test(400, 150, 0, 0, 0, 0, 0); |
|
Justin Novosad
2017/02/06 20:04:23
Should use generate_tests() here
zakerinasab
2017/02/09 18:02:00
Done.
|
| +test(400, 75, 255, 0, 0, 64); |
| +test(400, 225, 255, 0, 0, 64); |
| +test(325, 150, 255, 0, 0, 64); |
| +test(475, 150, 255, 0, 0, 64); |
| + |
| +// Verifying blurry shadow... |
| +test(400, 400, 0, 0, 0, 0, 0); |
| +test(400, 300, 255, 0, 0, 31); |
| +test(400, 500, 255, 0, 0, 31); |
| +test(300, 400, 255, 0, 0, 31); |
| +test(500, 400, 255, 0, 0, 31); |
| + |
| +// Verifying rotated alpha shadow... |
| +test(400, 650, 0, 0, 0, 0, 0); |
| +test(400, 575, 255, 0, 0, 64); |
| +test(400, 725, 255, 0, 0, 64); |
| +test(325, 650, 255, 0, 0, 64); |
| +test(475, 650, 255, 0, 0, 64); |
| + |
| +// Verifying rotated blurry shadow... |
| +test(400, 900, 0, 0, 0, 0, 0); |
| +test(400, 800, 255, 0, 0, 31); |
| +test(400, 1000, 255, 0, 0, 31); |
| +test(300, 900, 255, 0, 0, 31); |
| +test(500, 900, 255, 0, 0, 31); |
| + |
| +}, "Ensure correct behavior of canvas with fillPath using a fillStyle color with alpha and a shadow"); |
| +</script> |
| </body> |
| -</html> |