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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/2d.composite.globalAlpha.fillPath.html

Issue 2278723005: Convert LayoutTests/fast/canvas/2d tests to testharness (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test changed as per the comments. Created 4 years, 4 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/canvas/2d.composite.globalAlpha.fillPath-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
-
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/canvas/2d.composite.globalAlpha.fillPath-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698