Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <title>Test for chromium's canvas bug where fillText resets the current context< /title> |
| 3 <head> | 3 <script src="../../resources/testharness.js"></script> |
| 4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/testharnessreport.js"></script> |
| 5 </head> | 5 |
| 6 <body> | 6 <body></body> |
| 7 <script src="script-tests/translate-text.js"></script> | 7 <script> |
| 8 </body> | 8 // Chromium Bug: https://bugs.webkit.org/show_bug.cgi?id=26436. |
| 9 </html> | 9 // You must see green box with message 'This text should be seen', |
| 10 // and black box below the green box. | |
| 11 test(function() { | |
| 12 function pixelToString(p) { | |
| 13 return "[" + p[0] + ", " + p[1] + ", " + p[2] + ", " + p[3] + "]" | |
| 14 } | |
| 15 | |
| 16 var canvas = document.createElement("canvas"); | |
| 17 canvas.height = 100; | |
| 18 canvas.width = 500; | |
| 19 canvas.style.height = "100"; | |
| 20 canvas.style.width = "500"; | |
| 21 | |
| 22 document.body.appendChild(canvas); | |
| 23 | |
| 24 var ctx = canvas.getContext('2d'); | |
| 25 ctx.fillStyle = 'rgb(0,255,0)'; | |
| 26 ctx.fillRect(0, 0, 500, 100); | |
| 27 ctx.fillStyle = 'rgb(0,0,0)'; | |
| 28 ctx.fillText("This text should be seen", 20, 20); | |
| 29 ctx.translate(0, 50); | |
| 30 ctx.font = "10pt Arial"; | |
| 31 ctx.fillText("This text should NOT be seen", 20, 20); | |
| 32 // If fillText resets the current context, this rectangle won't hide the tex t. | |
| 33 ctx.fillStyle = 'rgb(0,0,0)'; | |
| 34 ctx.fillRect(0, 0, 500, 50); | |
| 35 | |
| 36 // Pixel value at 0, 0 | |
| 37 var imageData = ctx.getImageData(0, 0, 1, 1); | |
|
Srirama
2016/09/16 06:58:43
same here also,
var pixelData = ctx.getImageData(0
Abhishek Kanike
2016/09/16 08:53:41
Done.
| |
| 38 var pixel = imageData.data; | |
| 39 | |
| 40 assert_equals(pixelToString(pixel), "[0, 255, 0, 255]"); | |
| 41 }); | |
| 42 </script> | |
| OLD | NEW |