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

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: 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');
Justin Novosad 2017/02/03 18:39:32 indent
zakerinasab 2017/02/09 18:11:03 Done.
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 for (var i = 0; i < h; ++i) {
24 for (var j = 0; j < w; ++j) {
25 if (d[4 * (w * i + j) + 0] != 0) assert_equals(d[4 * (w * i + j) + 0], 0 );
Justin Novosad 2017/02/03 18:39:32 Calling assert_equals inside a big loop is a bad i
zakerinasab 2017/02/09 18:11:03 Done.
26 if (d[4 * (w * i + j) + 1] != 255) assert_equals(d[4 * (w * i + j) + 1], 255);
27 if (d[4 * (w * i + j) + 2] != 0) assert_equals(d[4 * (w * i + j) + 2], 0 );
28 if (d[4 * (w * i + j) + 3] != 255) assert_equals(d[4 * (w * i + j) + 3], 255);
29 }
30 }
31
32 ctx.fillStyle = '#0f0';
33 ctx.fillRect(0, 0, canvasWidth, canvasHeight);
34
35 ctx.fillStyle = '#f00';
36 ctx.fillText("fail fail fail fail fail", 5, 35, -1);
37
38 var imageData = ctx.getImageData(0, 0, canvasWidth, canvasHeight);
39 var w = imageData.width, h = imageData.height, d = imageData.data;
40 for (var i = 0; i < h; ++i) {
41 for (var j = 0; j < w; ++j) {
42 if (d[4 * (w * i + j) + 0] != 0) assert_equals(d[4 * (w * i + j) + 0], 0 );
Justin Novosad 2017/02/03 18:39:32 same here
zakerinasab 2017/02/09 18:11:03 Done.
43 if (d[4 * (w * i + j) + 1] != 255) assert_equals(d[4 * (w * i + j) + 1], 255);
44 if (d[4 * (w * i + j) + 2] != 0) assert_equals(d[4 * (w * i + j) + 2], 0 );
45 if (d[4 * (w * i + j) + 3] != 255) assert_equals(d[4 * (w * i + j) + 3], 255);
46 }
47 }
48
49 }, 'Series of tests to ensure that fillText() does not display any text when max Width is invalid.');
50 </script>
8 </body> 51 </body>
9 </html>
10 52
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698