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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-pattern-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="canvas-pattern-transform.js"></script> 4 <script>
5 var canvas = document.createElement('canvas');
6 canvas.width = 100;
7 canvas.height = 100;
8 var ctx2 = canvas.getContext('2d');
9 ctx2.fillStyle = '#0f0';
10 ctx2.fillRect(0, 0, 50, 50);
11 ctx2.fillRect(50, 50, 50, 50);
12 ctx2.fillStyle = '#f00';
13 ctx2.fillRect(50, 0, 50, 50);
14 ctx2.fillRect(0, 50, 50, 50);
15
16 var ctx = document.createElement('canvas').getContext('2d');
17
18 ctx.save();
19 ctx.transform(2, 0, 0, 2, 0, 0);
20 var pattern = ctx.createPattern(canvas, 'repeat');
21 ctx.fillStyle = pattern;
22 ctx.fillRect(0, 0, 100, 100);
23 ctx.restore();
24
25 ctx.save();
26 ctx.transform(0.5, 0, 0, 0.5, 0, 0);
27 pattern = ctx.createPattern(canvas, 'repeat');
28 ctx.fillStyle = pattern;
29 ctx.fillRect(0, 0, 100, 100);
30 ctx.restore();
31
32 test(function(t) {
33 var imageData = ctx.getImageData(26, 26, 74, 74).data;
34 assert_array_equals(imageData.slice(4, 7), [0, 255, 0]);
35
36 imageData = ctx.getImageData(25, 0, 25, 25).data;
37 assert_array_equals(imageData.slice(4, 7), [255, 0, 0]);
38
39 imageData = ctx.getImageData(0, 0, 25, 25).data;
40 assert_array_equals(imageData.slice(4, 7), [0, 255, 0]);
41 }, "Series of tests to ensure correct behaviour on transform of a pattern.");
42 </script>
8 </body> 43 </body>
9 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698