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..04fbc317eee0b155884014c1fa8afda57a04924a 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 |
+ http://philip.html5.org/tests/canvas/suite/tests/index.2d.composite.globalAlpha.html |
--> |
-<html> |
-<head> |
-<script src="../../resources/js-test.js"></script> |
-</head> |
-<body> |
-<canvas id="canvas" width="100" height="100"></canvas> |
+<title>Test that canvas2d context fills with the globalAlpha property when applied</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_less_than_equal(diff, tolerance); |
+ } |
+ 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> |
- |