4 <script src=
"../../resources/js-test.js"></script>
8 description("Test the handling of non-integer source coordinates in getImageData().");
10 ctx
= document
.createElement('canvas').getContext('2d');
12 function dimensionsShouldBe(sx
, sy
, sw
, sh
, width
, height
)
14 imageData
= ctx
.getImageData(sx
, sy
, sw
, sh
);
15 debug('getImageData(' + sx
+ ', ' + sy
+ ', ' + sw
+ ', ' + sh
+ ')');
16 shouldBe('imageData.width', width
+ '');
17 shouldBe('imageData.height', height
+ '');
20 // Basic integer values
21 dimensionsShouldBe( 0, 0, 20, 10, 20, 10);
23 // Source point is not an integer
24 dimensionsShouldBe( .1, .2, 20, 10, 21, 11);
25 dimensionsShouldBe( .9, .8, 20, 10, 21, 11);
27 // Size is not an integer
28 dimensionsShouldBe( 0, 0, 19.9, 9.9, 20, 10);
29 dimensionsShouldBe( 0, 0, 19.1, 9.1, 20, 10);
31 // Width straddles a pixel boundary
32 dimensionsShouldBe( .9, 0, .2, 10, 2, 10);
34 // Basic integer negative values
35 dimensionsShouldBe( -1, -1, 20, 10, 20, 10);
37 // Non-integer negative values
38 dimensionsShouldBe(-1.1, 0, 20, 10, 21, 10);
39 dimensionsShouldBe(-1.9, 0, 20, 10, 21, 10);