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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/script-tests/pattern-with-transform.js

Issue 2701053003: 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
(Empty)
1 description("Test for canvas regression where pattern transforms were ignored ht tps://bugs.webkit.org/show_bug.cgi?id=21498");
2
3 function pixelValueAt(context, x, y) {
4 var imageData = context.getImageData(x, y, 1, 1);
5 return imageData.data;
6 }
7
8 function pixelToString(p) {
9 return "[" + p[0] + ", " + p[1] + ", " + p[2] + ", " + p[3] + "]"
10 }
11
12 function pixelShouldBe(context, x, y, expectedPixelString) {
13 var pixel = pixelValueAt(context, x, y);
14 var expectedPixel = eval(expectedPixelString);
15
16 var pixelString = "pixel " + x + ", " + y;
17 if (areArraysEqual(pixel, expectedPixel)) {
18 testPassed(pixelString + " is " + pixelToString(pixel));
19 } else {
20 testFailed(pixelString + " should be " + pixelToString(expectedPixel) + " was " + pixelToString(pixel));
21 }
22 }
23
24 function fillWithColor(context, color) {
25 context.save();
26 context.fillStyle = color;
27 context.fillRect(0, 0, canvas.width, canvas.height);
28 context.restore();
29 }
30
31 var canvas = document.createElement("canvas");
32 canvas.height = 100;
33 canvas.width = 100;
34 canvas.style.height = "100";
35 canvas.style.width = "100";
36
37 document.body.appendChild(canvas);
38
39 var patternImage = document.createElement("canvas");
40 patternImage.height = 10;
41 patternImage.width = 10;
42 var patternImageCtx = patternImage.getContext('2d');
43 fillWithColor(patternImageCtx, "green");
44 var greenPixel = pixelValueAt(patternImageCtx, 0, 0);
45
46
47 var ctx = canvas.getContext('2d');
48 var pattern = ctx.createPattern(patternImage, "no-repeat");
49
50 fillWithColor(ctx, "blue");
51
52 ctx.fillStyle = pattern;
53 ctx.translate(20, 20);
54 ctx.fillRect(0, 0, 10, 10);
55 pixelShouldBe(ctx, 20, 20, "greenPixel");
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698