Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/canvas/2d.composite.globalAlpha.fillPath.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/canvas/2d.composite.globalAlpha.fillPath.html b/third_party/WebKit/LayoutTests/fast/canvas/2d.composite.globalAlpha.fillPath.html |
| index 9464879198c59b326ef4b4c07e500267ea9422b0..2cb385c317c1dae58269ca7b9fb9d1c070512809 100644 |
| --- a/third_party/WebKit/LayoutTests/fast/canvas/2d.composite.globalAlpha.fillPath.html |
| +++ b/third_party/WebKit/LayoutTests/fast/canvas/2d.composite.globalAlpha.fillPath.html |
| @@ -1,35 +1,26 @@ |
| - <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| +<!DOCTYPE html> |
| <!-- Test based on that found at |
| http://http://philip.html5.org/tests/canvas/suite/tests/index.2d.composite.globalAlpha.html |
|
fs
2016/08/25 10:50:37
Nit: Maybe drop the initial http:// here (since it
sivag
2016/08/25 11:04:03
Done.
|
| --> |
| -<html> |
| -<head> |
| -<script src="../../resources/js-test.js"></script> |
| -</head> |
| -<body> |
| -<canvas id="canvas" width="100" height="100"></canvas> |
| +<title>The test to ensure correct sync behaviour with globalAlpha and fillPath() in accelerated-2d-canvas mode.</title> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<canvas width="100" height="100"></canvas> |
| <script> |
| - |
| -function assertPixelApprox(ctx, x,y, r,g,b,a, pos, colour, tolerance) |
| -{ |
| - var imgdata = ctx.getImageData(x, y, 1, 1); |
| - var diff = Math.max(Math.abs(r-imgdata.data[0]), Math.abs(g-imgdata.data[1]), Math.abs(b-imgdata.data[2]), Math.abs(a-imgdata.data[3])); |
| - shouldBeFalse((diff > tolerance).toString()); |
| -} |
| - |
| -description("The test to ensure correct sync behaviour with globalAlpha and fillPath() in accelerated-2d-canvas mode."); |
| -var ctx = document.getElementById('canvas').getContext('2d'); |
| - |
| -ctx.fillStyle = '#0f0'; |
| -ctx.fillRect(0, 0, 100, 100); |
| -ctx.globalAlpha = 0.01; // avoid any potential alpha=0 optimisations |
| -ctx.beginPath(); |
| -ctx.fillStyle = '#f00'; |
| -ctx.rect(0, 0, 100, 100); |
| -ctx.fill(); |
| -assertPixelApprox(ctx, 50,25, 2,253,0,255, "50,25", "2,253,0,255", 2); |
| - |
| +test(function() { |
| + function assertPixelApprox(ctx, x,y, r,g,b,a, pos, colour, tolerance) { |
| + var imgdata = ctx.getImageData(x, y, 1, 1); |
| + var diff = Math.max(Math.abs(r-imgdata.data[0]), Math.abs(g-imgdata.data[1]), Math.abs(b-imgdata.data[2]), Math.abs(a-imgdata.data[3])); |
| + assert_false(diff > tolerance); |
|
fs
2016/08/25 10:50:36
assert_greater_than
sivag
2016/08/25 11:04:03
Done.
|
| + } |
| + var ctx = document.querySelector('canvas').getContext('2d'); |
| + ctx.fillStyle = '#0f0'; |
| + ctx.fillRect(0, 0, 100, 100); |
| + ctx.globalAlpha = 0.01; // avoid any potential alpha = 0 optimisations. |
| + ctx.beginPath(); |
| + ctx.fillStyle = '#f00'; |
| + ctx.rect(0, 0, 100, 100); |
| + ctx.fill(); |
| + assertPixelApprox(ctx, 50,25, 2,253,0,255, "50,25", "2,253,0,255", 2); |
| +}); |
| </script> |
| -</body> |
| -</html> |
| - |