OLD | NEW |
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/pattern-with-transform.js"></script> | 4 <script> |
| 5 |
| 6 var canvas; |
| 7 function fillWithColor(context, color) { |
| 8 context.save(); |
| 9 context.fillStyle = color; |
| 10 context.fillRect(0, 0, canvas.width, canvas.height); |
| 11 context.restore(); |
| 12 } |
| 13 |
| 14 canvas = document.createElement("canvas"); |
| 15 canvas.height = 100; |
| 16 canvas.width = 100; |
| 17 canvas.style.height = "100"; |
| 18 canvas.style.width = "100"; |
| 19 document.body.appendChild(canvas); |
| 20 |
| 21 test(function() { |
| 22 var patternImage = document.createElement('canvas'); |
| 23 patternImage.height = 10; |
| 24 patternImage.width = 10; |
| 25 var patternImageCtx = patternImage.getContext('2d'); |
| 26 fillWithColor(patternImageCtx, "green"); |
| 27 var greenPixel = patternImageCtx.getImageData(0, 0, 1, 1).data; |
| 28 |
| 29 var ctx = canvas.getContext('2d'); |
| 30 var pattern = ctx.createPattern(patternImage, "no-repeat"); |
| 31 fillWithColor(ctx, "blue"); |
| 32 |
| 33 ctx.fillStyle = pattern; |
| 34 ctx.translate(20, 20); |
| 35 ctx.fillRect(0, 0, 10, 10); |
| 36 assert_array_equals(ctx.getImageData(20, 20, 1, 1).data, greenPixel); |
| 37 |
| 38 }, "Test for canvas regression where pattern transforms were ignored https://bug
s.webkit.org/show_bug.cgi?id=21498"); |
| 39 </script> |
8 </body> | 40 </body> |
9 </html> | 41 </html> |
OLD | NEW |