Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-clip-rule.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-clip-rule.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-clip-rule.html |
| index 663c7e5fecf136517ac74f7115fa5da3f5048e31..671cd6b5c8f2ae93de1ac7d3a93382e9d19dc3c1 100644 |
| --- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-clip-rule.html |
| +++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-clip-rule.html |
| @@ -1,8 +1,67 @@ |
| -<!doctype html> |
| -<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-clip-rule.js"></script> |
| +<script> |
| +test(function(t) { |
| +var tmpimg = document.createElement('canvas'); |
| + tmpimg.width = 200; |
| + tmpimg.height = 200; |
| + ctx = tmpimg.getContext('2d'); |
| + |
| + // Create the image for blending test with images. |
| + var img = document.createElement('canvas'); |
| + img.width = 100; |
| + img.height = 100; |
| + var imgCtx = img.getContext('2d'); |
| + |
| + function pixelDataAtPoint() |
| + { |
| + return ctx.getImageData(50, 50, 1, 1).data; |
| + } |
| + |
| + function checkResult(expectedColors, sigma) { |
| + for (var i = 0; i < 4; i++) |
| + assert_approx_equals(pixelDataAtPoint()[i], expectedColors[i], sigma); |
| + } |
| + |
| + // Execute test. |
| + function prepareTestScenario() { |
|
Justin Novosad
2017/02/08 18:23:33
Nit: unnecessary nested function
zakerinasab
2017/02/08 19:57:49
Done.
|
| + ctx.fillStyle = 'rgb(255,0,0)'; |
| + ctx.fillRect(0, 0, 100, 100); |
| + ctx.fillStyle = 'rgb(0,255,0)'; |
| + ctx.beginPath(); |
| + ctx.rect(0, 0, 100, 100); |
| + ctx.rect(25, 25, 50, 50); |
| + ctx.clip(); |
| + ctx.beginPath(); |
| + ctx.fillRect(0, 0, 100, 100); |
| + checkResult([0, 255, 0, 255], 5); |
| + |
| + ctx.fillStyle = 'rgb(255,0,0)'; |
| + ctx.fillRect(0, 0, 100, 100); |
| + ctx.fillStyle = 'rgb(0,255,0)'; |
| + ctx.beginPath(); |
| + ctx.rect(0, 0, 100, 100); |
| + ctx.rect(25, 25, 50, 50); |
| + ctx.clip('nonzero'); |
| + ctx.beginPath(); |
| + ctx.fillRect(0, 0, 100, 100); |
| + checkResult([0, 255, 0, 255], 5); |
| + |
| + ctx.fillStyle = 'rgb(255,0,0)'; |
| + ctx.fillRect(0, 0, 100, 100); |
| + ctx.fillStyle = 'rgb(0,255,0)'; |
| + ctx.beginPath(); |
| + ctx.rect(0, 0, 100, 100); |
| + ctx.rect(25, 25, 50, 50); |
| + ctx.clip('evenodd'); |
| + ctx.beginPath(); |
| + ctx.fillRect(0, 0, 100, 100); |
| + checkResult([255, 0, 0, 255], 5); |
| + } |
| + |
| + // Run test and allow variation of results. |
| + prepareTestScenario(); |
| + }, "Series of tests to ensure correct results of the winding rule."); |
| +</script> |
| </body> |