Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-blending-clipping.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-blending-clipping.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-blending-clipping.html |
| index 78196b6563144a4c60dc028b3c306893f51315c7..918935911ed41953a4d2c19aa568c78ae10d7f62 100644 |
| --- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-blending-clipping.html |
| +++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-blending-clipping.html |
| @@ -1,62 +1,57 @@ |
| -<!DOCTYPE HTML> |
| -<html> |
| -<body> |
| - <script src="../../resources/js-test.js"></script> |
| - <script type="text/javascript" src="canvas-blending-helpers.js"></script> |
| - <script type="text/javascript"> |
| - |
| - description("Series of tests to ensure correct results on applying different blend modes when drawing with clipped regions."); |
| - |
| - var context; |
| - function actualColor(x, y) { |
| - return context.getImageData(x, y, 1, 1).data; |
| - } |
| - |
| - function checkBlendModeResult(i, context, sigma) { |
| - var expectedColor = blendColors([129 / 255, 1, 129 / 255, 1], [1, 129 / 255, 129 / 255, 1], i); |
| - var ac = "actualColor(0, 0)"; |
| - shouldBeCloseTo(ac + "[0]", 0, sigma); |
| - shouldBeCloseTo(ac + "[1]", 0, sigma); |
| - shouldBeCloseTo(ac + "[2]", 0, sigma); |
| - shouldBeCloseTo(ac + "[3]", 0, sigma); |
| - |
| - ac = "actualColor(5, 5)"; |
| - shouldBeCloseTo(ac + "[0]", expectedColor[0], sigma); |
| - shouldBeCloseTo(ac + "[1]", expectedColor[1], sigma); |
| - shouldBeCloseTo(ac + "[2]", expectedColor[2], sigma); |
| - shouldBeCloseTo(ac + "[3]", expectedColor[3], sigma); |
| - } |
| - |
| - function runTest() { |
| - var canvas = document.createElement("canvas"); |
| - var sigma = 5; |
| - canvas.width = 10; |
| - canvas.height = 10; |
| - context = canvas.getContext("2d"); |
| - |
| - for (var i = 0; i < blendModes.length; ++i) { |
| - debug("Testing blend mode " + blendModes[i]); |
| - |
| - context.clearRect(0, 0, 10, 10); |
| - context.save(); |
| - context.beginPath(); |
| - context.moveTo(3, 3); |
| - context.lineTo(3, 7); |
| - context.lineTo(7, 7); |
| - context.lineTo(7, 3); |
| - context.lineTo(3, 3); |
| - context.clip(); |
| - |
| - drawBackdropColorInContext(context); |
| - context.globalCompositeOperation = blendModes[i]; |
| - drawSourceColorInContext(context); |
| - checkBlendModeResult(i, context, sigma); |
| - context.restore(); |
| - debug(''); |
| - } |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<script type="text/javascript" src="canvas-blending-helpers.js"></script> |
| +<script> |
| +test(function(t) { |
| + var context; |
| + function actualColor(x, y) { |
| + return context.getImageData(x, y, 1, 1).data; |
| + } |
| + |
| + function checkBlendModeResult(i, context, sigma) { |
| + var expectedColor = blendColors([129 / 255, 1, 129 / 255, 1], [1, 129 / 255, 129 / 255, 1], i); |
| + var ac = actualColor(0, 0); |
| + assert_approx_equals(ac[0], 0, sigma); |
| + assert_approx_equals(ac[1], 0, sigma); |
| + assert_approx_equals(ac[2], 0, sigma); |
| + assert_approx_equals(ac[3], 0, sigma); |
| + |
| + ac = actualColor(5, 5); |
| + assert_approx_equals(ac[0], expectedColor[0], sigma); |
| + assert_approx_equals(ac[1], expectedColor[1], sigma); |
| + assert_approx_equals(ac[2], expectedColor[2], sigma); |
| + assert_approx_equals(ac[3], expectedColor[3], sigma); |
| + } |
| + |
| + function runTest() { |
|
Justin Novosad
2017/02/08 16:52:33
Nit: the nested function is not necessary
zakerinasab
2017/02/08 19:04:10
Done.
|
| + var canvas = document.createElement("canvas"); |
| + var sigma = 5; |
| + canvas.width = 10; |
| + canvas.height = 10; |
| + context = canvas.getContext("2d"); |
| + |
| + for (var i = 0; i < blendModes.length; ++i) { |
|
Justin Novosad
2017/02/08 16:52:33
Nit: this test could be unrolled with generate_tes
zakerinasab
2017/02/08 19:04:10
It can be done only if we put the each blend mode
|
| + context.clearRect(0, 0, 10, 10); |
| + context.save(); |
| + context.beginPath(); |
| + context.moveTo(3, 3); |
| + context.lineTo(3, 7); |
| + context.lineTo(7, 7); |
| + context.lineTo(7, 3); |
| + context.lineTo(3, 3); |
| + context.clip(); |
| + |
| + drawBackdropColorInContext(context); |
| + context.globalCompositeOperation = blendModes[i]; |
| + drawSourceColorInContext(context); |
| + checkBlendModeResult(i, context, sigma); |
| + context.restore(); |
| } |
| + } |
| + runTest(); |
| +}, 'Series of tests to ensure correct results on applying different blend modes when drawing with clipped regions.'); |
| +</script> |
| - runTest(); |
| </script> |
| </body> |
| </html> |