Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-transforms-fillRect-shadow.html

Issue 2693043012: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Addressing comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-transforms-fillRect-shadow.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-transforms-fillRect-shadow.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-transforms-fillRect-shadow.html
index 6a953be9d919fc95330950628ba19fb74782e510..0925f2c2eee53f876fc6444be08696698e7d8ebd 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-transforms-fillRect-shadow.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-transforms-fillRect-shadow.html
@@ -1,9 +1,67 @@
-<!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-transforms-fillRect-shadow.js"></script>
+<script>
+// Ensure correct behavior of canvas with fillRect+shadow after translation+rotation+scaling. A blue and red checkered pattern should be displayed.
+
+var canvas = document.createElement('canvas');
+document.body.appendChild(canvas);
+canvas.setAttribute('width', '600');
+canvas.setAttribute('height', '600');
+var ctx = canvas.getContext('2d');
+
+ctx.fillStyle = 'rgba(0, 0, 255, 1.0)';
+ctx.shadowOffsetX = 100;
+ctx.shadowOffsetY = 100;
+
+ctx.translate(-100, -100);
+ctx.rotate(Math.PI/2);
+ctx.scale(2, 2);
+
+ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
+ctx.fillRect(100, -150, 50, 50);
+
+ctx.shadowColor = 'rgba(255, 0, 0, 0.5)';
+ctx.fillRect(200, -150, 50, 50);
+
+ctx.shadowBlur = 5;
+ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
+ctx.fillRect(100, -250, 50, 50);
+
+ctx.shadowColor = 'rgba(255, 0, 0, 0.5)';
+ctx.fillRect(200, -250, 50, 50);
+
+function testPixelShadowBlur(x, y, color)
+{
+ if (color.length == 4) {
+ assert_array_equals(ctx.getImageData(x, y, 1, 1).data, color);
+ } else { // we expect to have [r, g, b, a, alphaTolerance]
+ 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], color[4]);
+ }
+}
+
+var alphaTolerance = 20;
+var testPixelShadowScenarios = [
+ ['Verify solid shadow 1', 201, 205, [255, 0, 0, 255]],
+ ['Verify solid shadow 2', 298, 298, [255, 0, 0, 255]],
+ ['Verify solid shadow 3', 201, 298, [255, 0, 0, 255]],
+
+ ['Verify solid alpha shadow 1', 201, 401, [255, 0, 0, 127, alphaTolerance]],
+ ['Verify solid alpha shadow 2', 298, 450, [255, 0, 0, 127, alphaTolerance]],
+ ['Verify solid alpha shadow 3', 205, 498, [255, 0, 0, 127, alphaTolerance]],
+
+ ['Verify blurry shadow 1', 399, 205, [255, 0, 0, 106, alphaTolerance]],
+ ['Verify blurry shadow 2', 500, 205, [255, 0, 0, 106, alphaTolerance]],
+ ['Verify blurry shadow 3', 499, 299, [255, 0, 0, 83, alphaTolerance]],
+
+ ['Verify blurry alpha shadow 1', 398, 405, [255, 0, 0, 36, alphaTolerance]],
+ ['Verify blurry alpha shadow 2', 405, 501, [255, 0, 0, 36, alphaTolerance]],
+ ['Verify blurry alpha shadow 3', 405, 501, [255, 0, 0, 36, alphaTolerance]],
+];
+
+generate_tests(testPixelShadowBlur, testPixelShadowScenarios);
+
+</script>
</body>
-</html>

Powered by Google App Engine
This is Rietveld 408576698