Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-scale-fillPath-shadow.html |
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-scale-fillPath-shadow.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-scale-fillPath-shadow.html |
index 0da6772ead343ab2a1534e717fa5e189d75e4883..e1d7a5c97031ad155bda06be3c82e6f9c4230c73 100644 |
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-scale-fillPath-shadow.html |
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-scale-fillPath-shadow.html |
@@ -1,9 +1,86 @@ |
-<!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-scale-fillPath-shadow.js"></script> |
+<script> |
+// Ensure correct behavior of canvas with path fill + shadow after scaling. A blue and red checkered pattern should be displayed. |
+ |
+var canvas = document.createElement('canvas'); |
+document.body.appendChild(canvas); |
+canvas.setAttribute('width', '1000'); |
+canvas.setAttribute('height', '1000'); |
+var ctx = canvas.getContext('2d'); |
+ |
+ctx.scale(2, 2); |
+ctx.shadowOffsetX = 100; |
+ctx.shadowOffsetY = 100; |
+ctx.fillStyle = 'rgba(0, 0, 255, 1)'; |
+ |
+ctx.shadowColor = 'rgba(255, 0, 0, 1.0)'; |
+ctx.beginPath(); |
+ctx.moveTo(50, 50); |
+ctx.lineTo(100, 50); |
+ctx.lineTo(100, 100); |
+ctx.lineTo(50, 100); |
+ctx.fill(); |
+ |
+ctx.shadowColor = 'rgba(255, 0, 0, 0.3)'; |
+ctx.beginPath(); |
+ctx.moveTo(50, 150); |
+ctx.lineTo(100, 150); |
+ctx.lineTo(100, 200); |
+ctx.lineTo(50, 200); |
+ctx.fill(); |
+ |
+ctx.shadowColor = 'rgba(255, 0, 0, 1.0)'; |
+ctx.shadowBlur = 10; |
+ctx.beginPath(); |
+ctx.moveTo(150, 50); |
+ctx.lineTo(200, 50); |
+ctx.lineTo(200, 100); |
+ctx.lineTo(150, 100); |
+ctx.fill(); |
+ |
+ctx.shadowColor = 'rgba(255, 0, 0, 0.3)'; |
+ctx.beginPath(); |
+ctx.moveTo(150, 150); |
+ctx.lineTo(200, 150); |
+ctx.lineTo(200, 200); |
+ctx.lineTo(150, 200); |
+ctx.fill(); |
+ |
+function testPixelShadow(x, y, color) |
+{ |
+ assert_array_equals(ctx.getImageData(x, y, 1, 1).data, color); |
+} |
+ |
+function testPixelShadowAlpha(x, y, color) |
+{ |
+ var data = ctx.getImageData(x, y, 1, 1).data; |
+ assert_array_equals(data.slice(0,3), color.slice(0,3)); |
+ assert_approx_equals(data[3], color[3], 20); |
+} |
+ |
+var testPixelShadowScenarios = [ |
+ ['Verify solid shadow 1', 201, 205, [255, 0, 0, 255]], |
+ ['Verify solid shadow 2', 298, 295, [255, 0, 0, 255]], |
+ ['Verify solid shadow 3', 201, 298, [255, 0, 0, 255]], |
+]; |
+ |
+var testPixelShadowAlphaScenarios = [ |
+ ['Verify solid alpha shadow 1', 201, 405, [255, 0, 0, 76]], |
+ ['Verify solid alpha shadow 2', 298, 405, [255, 0, 0, 76]], |
+ ['Verify solid alpha shadow 3', 205, 498, [255, 0, 0, 76]], |
+ |
+ ['Verify blurry shadow 1', 398, 205, [255, 0, 0, 83]], |
+ ['Verify blurry shadow 2', 501, 205, [255, 0, 0, 83]], |
+ ['Verify blurry shadow 3', 500, 300, [255, 0, 0, 53]], |
+ |
+ ['Verify blurry alpha shadow 1', 398, 405, [255, 0, 0, 24]], |
+ ['Verify blurry alpha shadow 2', 405, 501, [255, 0, 0, 24]], |
+]; |
+ |
+generate_tests(testPixelShadow, testPixelShadowScenarios); |
+generate_tests(testPixelShadowAlpha, testPixelShadowAlphaScenarios); |
+ |
+</script> |
</body> |
-</html> |