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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/script-tests/canvas-strokeText-invalid-maxWidth.js

Issue 2690183006: 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 descriptionQuiet("Series of tests to ensure that strokeText() does not display a ny text when maxWidth is invalid.");
2
3 var canvas = document.createElement('canvas');
4 var ctx = canvas.getContext('2d');
5 var canvasWidth = 100;
6 var canvasHeight = 50;
7 canvas.setWidth = canvasWidth;
8 canvas.setHeight = canvasHeight;
9
10
11 ctx.fillStyle = '#0f0';
12 ctx.fillRect(0, 0, canvasWidth, canvasHeight);
13 ctx.font = '35px Arial, sans-serif';
14
15 debug("Test canvas.strokeText() with maxWidth zero");
16 ctx.strokeStyle = '#f00';
17 ctx.strokeText("fail fail fail fail fail", 5, 35, 0);
18
19 var imageData = ctx.getImageData(0, 0, canvasWidth, canvasHeight);
20 var w = imageData.width, h = imageData.height, d = imageData.data;
21 for (var i = 0; i < h; ++i) {
22 for (var j = 0; j < w; ++j) {
23 if (d[4 * (w * i + j) + 0] != 0) shouldBe("d[4 * (w * i + j) + 0]", "0") ;
24 if (d[4 * (w * i + j) + 1] != 255) shouldBe("d[4 * (w * i + j) + 1]", "2 55");
25 if (d[4 * (w * i + j) + 2] != 0) shouldBe("d[4 * (w * i + j) + 2]", "0") ;
26 if (d[4 * (w * i + j) + 3] != 255) shouldBe("d[4 * (w * i + j) + 3]", "2 55");
27 }
28 }
29
30 ctx.fillStyle = '#0f0';
31 ctx.fillRect(0, 0, canvasWidth, canvasHeight);
32 debug("Test canvas.strokeText() with maxWidth -1");
33 ctx.strokeStyle = '#f00';
34 ctx.strokeText("fail fail fail fail fail", 5, 35, -1);
35
36 var imageData = ctx.getImageData(0, 0, canvasWidth, canvasHeight);
37 var w = imageData.width, h = imageData.height, d = imageData.data;
38 for (var i = 0; i < h; ++i) {
39 for (var j = 0; j < w; ++j) {
40 if (d[4 * (w * i + j) + 0] != 0) shouldBe("d[4 * (w * i + j) + 0]", "0") ;
41 if (d[4 * (w * i + j) + 1] != 255) shouldBe("d[4 * (w * i + j) + 1]", "2 55");
42 if (d[4 * (w * i + j) + 2] != 0) shouldBe("d[4 * (w * i + j) + 2]", "0") ;
43 if (d[4 * (w * i + j) + 3] != 255) shouldBe("d[4 * (w * i + j) + 3]", "2 55");
44 }
45 }
46
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698