| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <body> |
| <script> |
| test(function(t) { |
| ctx = document.createElement('canvas').getContext('2d'); |
| |
| ctx.fillStyle = 'red'; |
| ctx.fillRect(0, 0, 100, 100); |
| ctx.fillStyle = 'green'; |
| ctx.fillRect(0, 0, 6, 6); |
| |
| var imageData = ctx.getImageData(-10, 0, 100, 1); |
| var imgdata = imageData.data; |
| |
| // Fully transparent black |
| assert_equals(imgdata[0], 0); |
| assert_equals(imgdata[1], 0); |
| assert_equals(imgdata[2], 0); |
| assert_equals(imgdata[3], 0); |
| |
| // Green |
| assert_equals(imgdata[60], 0); |
| assert_equals(imgdata[61], 128); |
| assert_equals(imgdata[62], 0); |
| assert_equals(imgdata[63], 255); |
| |
| // Red |
| assert_equals(imgdata[64], 255); |
| assert_equals(imgdata[65], 0); |
| assert_equals(imgdata[66], 0); |
| assert_equals(imgdata[67], 255); |
| }, "Test the handling of negative sourceRect offset in getImageData()."); |
| </script> |
| </body> |