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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-fillText-invalid-maxWidth.html

Issue 2676493005: 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-fillText-invalid-maxWidth.js"></script> 4 <script>
5 test(function(t) {
6
7 var canvas = document.createElement('canvas');
8 var ctx = canvas.getContext('2d');
9 var canvasWidth = 100;
10 var canvasHeight = 50;
11 canvas.setWidth = canvasWidth;
12 canvas.setHeight = canvasHeight;
13
14 ctx.fillStyle = '#0f0';
15 ctx.fillRect(0, 0, canvasWidth, canvasHeight);
16 ctx.font = '35px Arial, sans-serif';
17
18 ctx.fillStyle = '#f00';
19 ctx.fillText("fail fail fail fail fail", 5, 35, 0);
20
21 var imageData = ctx.getImageData(0, 0, canvasWidth, canvasHeight);
22 var w = imageData.width, h = imageData.height, d = imageData.data;
23 var pixelsCheck = true;
24 loopMain1:
25 for (var i = 0; i < h; ++i) {
26 for (var j = 0; j < w; ++j) {
27 if (d[4 * (w * i + j) + 0] != 0) pixelsCheck = false;
28 if (d[4 * (w * i + j) + 1] != 255) pixelsCheck = false;
29 if (d[4 * (w * i + j) + 2] != 0) pixelsCheck = false;
30 if (d[4 * (w * i + j) + 3] != 255) pixelsCheck = false;
31 if(!pixelsCheck) break loopMain1;
32 }
33 }
34 assert_true(pixelsCheck);
35
36 ctx.fillStyle = '#0f0';
37 ctx.fillRect(0, 0, canvasWidth, canvasHeight);
38
39 ctx.fillStyle = '#f00';
40 ctx.fillText("fail fail fail fail fail", 5, 35, -1);
41
42 var imageData = ctx.getImageData(0, 0, canvasWidth, canvasHeight);
43 var w = imageData.width, h = imageData.height, d = imageData.data;
44 pixelsCheck = true;
45 loopMain2:
46 for (var i = 0; i < h; ++i) {
47 for (var j = 0; j < w; ++j) {
48 if (d[4 * (w * i + j) + 0] != 0) pixelsCheck = false;
49 if (d[4 * (w * i + j) + 1] != 255) pixelsCheck = false;
50 if (d[4 * (w * i + j) + 2] != 0) pixelsCheck = false;
51 if (d[4 * (w * i + j) + 3] != 255) pixelsCheck = false;
52 if(!pixelsCheck) break loopMain2;
53 }
54 }
55 assert_true(pixelsCheck);
56
57 }, 'Series of tests to ensure that fillText() does not display any text when max Width is invalid.');
58 </script>
8 </body> 59 </body>
9 </html>
10 60
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698