| OLD | NEW |
| 1 description("This test ensures that putImageData works correctly, the end result
should be a 100x100px green square."); | 1 description("This test ensures that putImageData works correctly, the end result
should be a 100x100px green square."); |
| 2 | 2 |
| 3 function fillRect(imageData, x, y, width, height, r, g, b, a) | 3 function fillRect(imageData, x, y, width, height, r, g, b, a) |
| 4 { | 4 { |
| 5 var bytesPerRow = imageData.width * 4; | 5 var bytesPerRow = imageData.width * 4; |
| 6 var data =imageData.data; | 6 var data =imageData.data; |
| 7 for (var i = 0; i < height; i++) { | 7 for (var i = 0; i < height; i++) { |
| 8 var rowOrigin = (y+i) * bytesPerRow; | 8 var rowOrigin = (y+i) * bytesPerRow; |
| 9 rowOrigin += x * 4; | 9 rowOrigin += x * 4; |
| 10 for (var j = 0; j < width; j++) { | 10 for (var j = 0; j < width; j++) { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 context.fillRect(1, 1, 8, 8); | 194 context.fillRect(1, 1, 8, 8); |
| 195 context.putImageData(smallbuffer, 1, 1, 0.0, 0.0, 8.25, 8.25); | 195 context.putImageData(smallbuffer, 1, 1, 0.0, 0.0, 8.25, 8.25); |
| 196 pixelShouldBe(1, 1, [0, 128,0,255]); | 196 pixelShouldBe(1, 1, [0, 128,0,255]); |
| 197 pixelShouldBe(9, 9, [0, 128,0,255]); | 197 pixelShouldBe(9, 9, [0, 128,0,255]); |
| 198 context.fillRect(1, 1, 7, 7); | 198 context.fillRect(1, 1, 7, 7); |
| 199 context.putImageData(smallbuffer, 1, 1, 0.5, 0.5, 7.9, 7.9); | 199 context.putImageData(smallbuffer, 1, 1, 0.5, 0.5, 7.9, 7.9); |
| 200 pixelShouldBe(1, 1, [0, 128,0,255]); | 200 pixelShouldBe(1, 1, [0, 128,0,255]); |
| 201 pixelShouldBe(9, 9, [0, 128,0,255]); | 201 pixelShouldBe(9, 9, [0, 128,0,255]); |
| 202 | 202 |
| 203 | 203 |
| 204 shouldThrow("context.putImageData({}, 0, 0)", "'TypeError: Type error'"); | 204 shouldThrow("context.putImageData({}, 0, 0)", '"TypeError: Failed to execute \'p
utImageData\' on \'CanvasRenderingContext2D\': No function was found that matche
d the signature provided."'); |
| 205 shouldThrow("context.putImageData(buffer, NaN, 0, 0, 0, 0, 0)", "'NotSupportedEr
ror: The implementation did not support the requested type of object or operatio
n.'"); | 205 shouldThrow("context.putImageData(buffer, NaN, 0, 0, 0, 0, 0)", "'NotSupportedEr
ror: The implementation did not support the requested type of object or operatio
n.'"); |
| 206 shouldThrow("context.putImageData(buffer, 0, NaN, 0, 0, 0, 0)", "'NotSupportedEr
ror: The implementation did not support the requested type of object or operatio
n.'"); | 206 shouldThrow("context.putImageData(buffer, 0, NaN, 0, 0, 0, 0)", "'NotSupportedEr
ror: The implementation did not support the requested type of object or operatio
n.'"); |
| 207 shouldThrow("context.putImageData(buffer, 0, 0, NaN, 0, 0, 0)", "'NotSupportedEr
ror: The implementation did not support the requested type of object or operatio
n.'"); | 207 shouldThrow("context.putImageData(buffer, 0, 0, NaN, 0, 0, 0)", "'NotSupportedEr
ror: The implementation did not support the requested type of object or operatio
n.'"); |
| 208 shouldThrow("context.putImageData(buffer, 0, 0, 0, NaN, 0, 0)", "'NotSupportedEr
ror: The implementation did not support the requested type of object or operatio
n.'"); | 208 shouldThrow("context.putImageData(buffer, 0, 0, 0, NaN, 0, 0)", "'NotSupportedEr
ror: The implementation did not support the requested type of object or operatio
n.'"); |
| 209 shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, NaN, 0)", "'NotSupportedEr
ror: The implementation did not support the requested type of object or operatio
n.'"); | 209 shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, NaN, 0)", "'NotSupportedEr
ror: The implementation did not support the requested type of object or operatio
n.'"); |
| 210 shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, 0, NaN)", "'NotSupportedEr
ror: The implementation did not support the requested type of object or operatio
n.'"); | 210 shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, 0, NaN)", "'NotSupportedEr
ror: The implementation did not support the requested type of object or operatio
n.'"); |
| 211 shouldThrow("context.putImageData(buffer, Infinity, 0, 0, 0, 0, 0)", "'NotSuppor
tedError: The implementation did not support the requested type of object or ope
ration.'"); | 211 shouldThrow("context.putImageData(buffer, Infinity, 0, 0, 0, 0, 0)", "'NotSuppor
tedError: The implementation did not support the requested type of object or ope
ration.'"); |
| 212 shouldThrow("context.putImageData(buffer, 0, Infinity, 0, 0, 0, 0)", "'NotSuppor
tedError: The implementation did not support the requested type of object or ope
ration.'"); | 212 shouldThrow("context.putImageData(buffer, 0, Infinity, 0, 0, 0, 0)", "'NotSuppor
tedError: The implementation did not support the requested type of object or ope
ration.'"); |
| 213 shouldThrow("context.putImageData(buffer, 0, 0, Infinity, 0, 0, 0)", "'NotSuppor
tedError: The implementation did not support the requested type of object or ope
ration.'"); | 213 shouldThrow("context.putImageData(buffer, 0, 0, Infinity, 0, 0, 0)", "'NotSuppor
tedError: The implementation did not support the requested type of object or ope
ration.'"); |
| 214 shouldThrow("context.putImageData(buffer, 0, 0, 0, Infinity, 0, 0)", "'NotSuppor
tedError: The implementation did not support the requested type of object or ope
ration.'"); | 214 shouldThrow("context.putImageData(buffer, 0, 0, 0, Infinity, 0, 0)", "'NotSuppor
tedError: The implementation did not support the requested type of object or ope
ration.'"); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 226 rectcanvas.width = 20; | 226 rectcanvas.width = 20; |
| 227 rectcanvas.height = 10; | 227 rectcanvas.height = 10; |
| 228 var rectbuffer = rectcanvas.getContext("2d"); | 228 var rectbuffer = rectcanvas.getContext("2d"); |
| 229 rectbuffer.putImageData(smallbuffer, 10, 0); | 229 rectbuffer.putImageData(smallbuffer, 10, 0); |
| 230 | 230 |
| 231 var rectcanvas = document.createElement("canvas"); | 231 var rectcanvas = document.createElement("canvas"); |
| 232 rectcanvas.width = 10; | 232 rectcanvas.width = 10; |
| 233 rectcanvas.height = 20; | 233 rectcanvas.height = 20; |
| 234 var rectbuffer = rectcanvas.getContext("2d"); | 234 var rectbuffer = rectcanvas.getContext("2d"); |
| 235 rectbuffer.putImageData(smallbuffer, 0, 10); | 235 rectbuffer.putImageData(smallbuffer, 0, 10); |
| OLD | NEW |