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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-blending-global-alpha.html

Issue 2673883002: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Addressing comments Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE HTML> 1 <script src="../../resources/testharness.js"></script>
2 <html> 2 <script src="../../resources/testharnessreport.js"></script>
3 <body> 3 <script type="text/javascript" src="canvas-blending-helpers.js"></script>
4 <script src="../../resources/js-test.js"></script>
5 <script type="text/javascript" src="canvas-blending-helpers.js"></script>
6 <script type="text/javascript">
7 4
8 description("Series of tests to ensure correct results on applying diffe rent blend modes when globalAlpha is set."); 5 <script>
6 function checkBlendModeResult(i, context, sigma) {
7 var expectedColor = blendColors([129 / 255, 1, 129 / 255, 1], [1, 129 / 255, 129 / 255, 0.1], i);
8 var ac = context.getImageData(0, 0, 1, 1).data;
9 assert_approx_equals(ac[0], expectedColor[0], sigma);
10 assert_approx_equals(ac[1], expectedColor[1], sigma);
11 assert_approx_equals(ac[2], expectedColor[2], sigma);
12 assert_approx_equals(ac[3], expectedColor[3], sigma);
13 }
9 14
10 var context; 15 test(function(t) {
11 function actualColor(x, y) { 16 var canvas = document.createElement("canvas");
12 return context.getImageData(x, y, 1, 1).data; 17 var sigma = 5;
13 } 18 canvas.width = 10;
19 canvas.height = 10;
20 context = canvas.getContext("2d");
14 21
15 function checkBlendModeResult(i, context, sigma) { 22 for (var i = 0; i < blendModes.length; ++i) {
16 var expectedColor = blendColors([129 / 255, 1, 129 / 255, 1], [1, 12 9 / 255, 129 / 255, 0.1], i); 23 context.clearRect(0, 0, 10, 10);
17 var ac = "actualColor(0, 0)"; 24 context.save();
18 shouldBeCloseTo(ac + "[0]", expectedColor[0], sigma); 25 drawBackdropColorInContext(context);
19 shouldBeCloseTo(ac + "[1]", expectedColor[1], sigma); 26 context.globalCompositeOperation = blendModes[i];
20 shouldBeCloseTo(ac + "[2]", expectedColor[2], sigma); 27 context.globalAlpha = 0.1;
21 shouldBeCloseTo(ac + "[3]", expectedColor[3], sigma); 28 drawSourceColorInContext(context);
22 } 29 checkBlendModeResult(i, context, sigma);
23 30 context.restore();
24 function runTest() { 31 }
25 var canvas = document.createElement("canvas"); 32 }, 'Series of tests to ensure correct results on applying different blend modes when globalAlpha is set.');
26 var sigma = 5; 33 </script>
27 canvas.width = 10;
28 canvas.height = 10;
29 context = canvas.getContext("2d");
30
31 for (var i = 0; i < blendModes.length; ++i) {
32 debug("Testing blend mode " + blendModes[i]);
33
34 context.clearRect(0, 0, 10, 10);
35 context.save();
36 drawBackdropColorInContext(context);
37 context.globalCompositeOperation = blendModes[i];
38 context.globalAlpha = 0.1;
39 drawSourceColorInContext(context);
40 checkBlendModeResult(i, context, sigma);
41 context.restore();
42 debug('');
43 }
44 }
45
46 runTest();
47 </script>
48 </body>
49 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698