<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<body>
<script>
var greenApprox = 0;
function testPixelShadow(pixel, reference, shouldBeTransparent) {
assert_equals(pixel[0], reference[0]);
assert_approx_equals(pixel[1], reference[1], greenApprox);
assert_equals(pixel[2], reference[2]);
if(shouldBeTransparent)
assert_not_equals(pixel[3], 255);
}
var canvas = document.createElement('canvas');
document.body.appendChild(canvas);
canvas.setAttribute('width', '700');
canvas.setAttribute('height', '700');
var ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.moveTo(300, 300);
ctx.lineTo(300, 50);
ctx.bezierCurveTo(200, 40, 75, 150, 30, 30);
ctx.quadraticCurveTo(250, 75, 50, 300);
ctx.shadowOffsetX = 350;
ctx.shadowColor = 'rgba(255, 20, 0, 0.5)';
ctx.shadowBlur = 0;
ctx.fillStyle = 'rgba(0, 0, 255, 1)';
ctx.lineWidth = 30;
ctx.fill();
ctx.beginPath();
ctx.moveTo(300,650);
ctx.lineTo(300,400);
ctx.bezierCurveTo(200, 390, 75, 500, 30, 380);
ctx.quadraticCurveTo(250, 425, 50, 650);
ctx.shadowOffsetX = 350;
ctx.shadowColor = 'rgba(255, 0, 0, 0.5)';
ctx.shadowBlur = 30;
ctx.fillStyle = 'rgba(0, 0, 255, 1)';
ctx.lineWidth = 30;
ctx.fill();
testScenarios =
[
['TestSolidShadow 1', ctx.getImageData(640, 290, 1, 1).data, [ 255, 20, 0, 0], false],
['TestSolidShadow 2', ctx.getImageData(570, 85, 1, 1).data, [ 255, 20, 0, 0], false],
['TestSolidShadow 4', ctx.getImageData(400, 40, 1, 1).data, [ 255, 20, 0, 0], false],
['TestBlurryShadow 1', ctx.getImageData(640, 640, 1, 1).data, [ 255, 0, 0, 0], true],
['TestBlurryShadow 2', ctx.getImageData(650, 400, 1, 1).data, [ 255, 0, 0, 0], true],
['TestBlurryShadow 3', ctx.getImageData(380, 380, 1, 1).data, [ 255, 0, 0, 0], true],
['TestBlurryShadow 4', ctx.getImageData(375, 390, 1, 1).data, [ 255, 0, 0, 0], true]
];
testScenarios2 =
[['TestSolidShadow 3', ctx.getImageData(380, 30, 1, 1).data, [ 255, 20, 0, 0], false]];
generate_tests(testPixelShadow, testScenarios);
greenApprox = 3;
generate_tests(testPixelShadow, testScenarios2);
</script>
</body>