2 <title>Canvas test:
2d.imageData.put.unchanged
</title>
3 <!-- Testing: putImageData(getImageData(...), ...) has no effect -->
4 <script src=
"/MochiKit/MochiKit.js"></script>
5 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel=
"stylesheet" href=
"/tests/SimpleTest/test.css">
8 <canvas id=
"c" width=
"100" height=
"50"><p class=
"fallback">FAIL (fallback content)
</p></canvas>
11 SimpleTest
.waitForExplicitFinish();
12 MochiKit
.DOM
.addLoadEvent(function () {
14 var canvas
= document
.getElementById('c');
15 var ctx
= canvas
.getContext('2d');
18 for (var y
= 0; y
< 16; ++y
) {
19 for (var x
= 0; x
< 16; ++x
, ++i
) {
20 ctx
.fillStyle
= 'rgba(' + i
+ ',' + (Math
.floor(i
*1.5) % 256) + ',' + (Math
.floor(i
*23.3) % 256) + ',' + (i
/256) + ')';
21 ctx
.fillRect(x
, y
, 1, 1);
24 var imgdata1
= ctx
.getImageData(0.1, 0.2, 15.8, 15.9);
26 for (var i
= 0; i
< imgdata1
.data
.length
; ++i
)
27 olddata
[i
] = imgdata1
.data
[i
];
29 ctx
.putImageData(imgdata1
, 0.1, 0.2);
31 var imgdata2
= ctx
.getImageData(0.1, 0.2, 15.8, 15.9);
32 for (var i
= 0; i
< imgdata2
.data
.length
; ++i
) {
33 ok(olddata
[i
] === imgdata2
.data
[i
], "olddata[\""+(i
)+"\"] === imgdata2.data[\""+(i
)+"\"]");