blob: dde5aac4b812c69c7b329cadde0b2a2b8e42ea5c [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<!-- Test based on that found at
http://http://philip.html5.org/tests/canvas/suite/tests/index.2d.composite.globalAlpha.html
-->
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<canvas id="canvas" width="100" height="100"></canvas>
<script>
function assertPixelApprox(ctx, x,y, r,g,b,a, pos, colour, tolerance)
{
var imgdata = ctx.getImageData(x, y, 1, 1);
var diff = Math.max(Math.abs(r-imgdata.data[0]), Math.abs(g-imgdata.data[1]), Math.abs(b-imgdata.data[2]), Math.abs(a-imgdata.data[3]));
shouldBeFalse((diff > tolerance).toString());
}
description("The test to ensure correct sync behaviour with globalAlpha and fillPath() in accelerated-2d-canvas mode.");
var ctx = document.getElementById('canvas').getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 100);
ctx.globalAlpha = 0.01; // avoid any potential alpha=0 optimisations
ctx.beginPath();
ctx.fillStyle = '#f00';
ctx.rect(0, 0, 100, 100);
ctx.fill();
assertPixelApprox(ctx, 50,25, 2,253,0,255, "50,25", "2,253,0,255", 2);
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>