gecko/content/canvas/test/test_2d.imageData.get.range.html

31 lines
936 B
HTML

<!DOCTYPE HTML>
<title>Canvas test: 2d.imageData.get.range</title>
<!-- Testing: getImageData() returns values in the range [0, 255] -->
<script src="/MochiKit/MochiKit.js"></script>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
<body>
<canvas id="c" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
SimpleTest.waitForExplicitFinish();
MochiKit.DOM.addLoadEvent(function () {
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#000';
ctx.fillRect(0, 0, 100, 50);
ctx.fillStyle = '#fff';
ctx.fillRect(20, 10, 60, 10);
var imgdata1 = ctx.getImageData(10, 5, 1, 1);
ok(imgdata1.data[0] === 0, "imgdata1.data[\""+(0)+"\"] === 0");
var imgdata2 = ctx.getImageData(30, 15, 1, 1);
ok(imgdata2.data[0] === 255, "imgdata2.data[\""+(0)+"\"] === 255");
SimpleTest.finish();
});
</script>