Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 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> | 4 <script> |
| 8 description("Test the handling of non-integer source coordinates in getImageData ()."); | 5 test(function(t) { |
| 9 | 6 |
| 10 ctx = document.createElement('canvas').getContext('2d'); | 7 ctx = document.createElement('canvas').getContext('2d'); |
|
Justin Novosad
2017/02/03 18:07:18
indent
| |
| 11 | 8 |
| 12 function dimensionsShouldBe(sx, sy, sw, sh, width, height) | 9 function testDimensions(sx, sy, sw, sh, width, height) |
| 13 { | 10 { |
| 14 imageData = ctx.getImageData(sx, sy, sw, sh); | 11 imageData = ctx.getImageData(sx, sy, sw, sh); |
| 15 debug('getImageData(' + sx + ', ' + sy + ', ' + sw + ', ' + sh + ')'); | 12 assert_equals(imageData.width, width); |
| 16 shouldBe('imageData.width', width + ''); | 13 assert_equals(imageData.height, height); |
| 17 shouldBe('imageData.height', height + ''); | |
| 18 } | 14 } |
| 19 | 15 |
| 20 // Basic integer values | 16 // Basic integer values |
| 21 dimensionsShouldBe( 0, 0, 20, 10, 20, 10); | 17 testDimensions( 0, 0, 20, 10, 20, 10); |
| 22 | 18 |
| 23 // Source point is not an integer | 19 // Source point is not an integer |
| 24 dimensionsShouldBe( .1, .2, 20, 10, 21, 11); | 20 testDimensions( .1, .2, 20, 10, 21, 11); |
| 25 dimensionsShouldBe( .9, .8, 20, 10, 21, 11); | 21 testDimensions( .9, .8, 20, 10, 21, 11); |
| 26 | 22 |
| 27 // Size is not an integer | 23 // Size is not an integer |
| 28 dimensionsShouldBe( 0, 0, 19.9, 9.9, 20, 10); | 24 testDimensions( 0, 0, 19.9, 9.9, 20, 10); |
| 29 dimensionsShouldBe( 0, 0, 19.1, 9.1, 20, 10); | 25 testDimensions( 0, 0, 19.1, 9.1, 20, 10); |
| 30 | 26 |
| 31 // Width straddles a pixel boundary | 27 // Width straddles a pixel boundary |
| 32 dimensionsShouldBe( .9, 0, .2, 10, 2, 10); | 28 testDimensions( .9, 0, .2, 10, 2, 10); |
| 33 | 29 |
| 34 // Basic integer negative values | 30 // Basic integer negative values |
| 35 dimensionsShouldBe( -1, -1, 20, 10, 20, 10); | 31 testDimensions( -1, -1, 20, 10, 20, 10); |
| 36 | 32 |
| 37 // Non-integer negative values | 33 // Non-integer negative values |
| 38 dimensionsShouldBe(-1.1, 0, 20, 10, 21, 10); | 34 testDimensions(-1.1, 0, 20, 10, 21, 10); |
| 39 dimensionsShouldBe(-1.9, 0, 20, 10, 21, 10); | 35 testDimensions(-1.9, 0, 20, 10, 21, 10); |
| 36 | |
| 37 }, 'Test the handling of non-integer source coordinates in getImageData().'); | |
| 40 </script> | 38 </script> |
| 41 </body> | 39 </body> |
| 42 </html> | |
| OLD | NEW |