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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-pattern-set-transform.html

Issue 2689243002: 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 PUBLIC "-//IETF//DTD HTML//EN"> 1 <script src="../../resources/testharness.js"></script>
2 <html> 2 <script src="../../resources/testharnessreport.js"></script>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body> 3 <body>
7 <script src="script-tests/canvas-pattern-set-transform.js"></script> 4 <script>
5 function fillWithColor(context, canvas, color1, color2) {
6 context.save();
7 context.fillStyle = color1;
8 context.fillRect(0, 0, canvas.width / 2, canvas.height);
9 context.fillStyle = color2;
10 context.fillRect(canvas.width / 2, 0, canvas.width / 2, canvas.height);
11 context.restore();
12 }
13
14 test(function(t) {
15
16 var canvas = document.createElement("canvas");
17 canvas.height = 100;
18 canvas.width = 100;
19 canvas.style.height = "100";
20 canvas.style.width = "100";
21
22 document.body.appendChild(canvas);
23
24 var patternImage = document.createElement("canvas");
25 patternImage.height = 10;
26 patternImage.width = 20;
27 var patternImageCtx = patternImage.getContext('2d');
28 fillWithColor(patternImageCtx, patternImage, "red", "green");
29 var greenPixel = patternImageCtx.getImageData(10, 0, 1, 1).data;
30
31 var ctx = canvas.getContext('2d');
32 var pattern = ctx.createPattern(patternImage, "repeat-x");
33 var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg ");
34 var matrix = svgElement.createSVGMatrix();
35 matrix = matrix.translate(10, 0);
36 pattern.setTransform(matrix);
37
38 fillWithColor(ctx, canvas, "blue", "blue");
39
40 ctx.fillStyle = pattern;
41 ctx.translate(20, 20);
42 ctx.fillRect(0, 0, 10, 10);
43 assert_array_equals(ctx.getImageData(20, 20, 1, 1).data, greenPixel);
44
45 }, "Test for supporting setTransform on canvas patterns");
46 </script>
8 </body> 47 </body>
9 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698