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

31 lines
1.0 KiB
HTML
Raw Normal View History

<!DOCTYPE HTML>
<title>Canvas test: 2d.imageData.get.nonpremul</title>
<!-- Testing: getImageData() returns non-premultiplied colours -->
<script src="/MochiKit/packed.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 = 'rgba(255, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
var imgdata = ctx.getImageData(10, 10, 10, 10);
ok(imgdata.data[0] > 200, "imgdata.data[\""+(0)+"\"] > 200");
ok(imgdata.data[1] > 200, "imgdata.data[\""+(1)+"\"] > 200");
ok(imgdata.data[2] > 200, "imgdata.data[\""+(2)+"\"] > 200");
ok(imgdata.data[3] > 100, "imgdata.data[\""+(3)+"\"] > 100");
ok(imgdata.data[3] < 200, "imgdata.data[\""+(3)+"\"] < 200");
SimpleTest.finish();
});
</script>