blob: e304c7e15c87002acba37b83b529053c0ca90a3b [file] [log] [blame]
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<body>
<script>
var canvas = document.createElement('canvas');
document.body.appendChild(canvas);
canvas.setAttribute('width', '700');
canvas.setAttribute('height', '200');
var ctx = canvas.getContext('2d');
ctx.miterLimit = 5;
ctx.lineWidth = 15;
ctx.fillStyle="rgba(255, 255, 255, 1.0)";
ctx.fillRect(0, 0, 700, 200);
ctx.strokeStyle="rgba(0, 0, 0, 1.0)";
ctx.lineJoin = "miter";
ctx.lineCap = "round";
ctx.translate(0, 50);
ctx.save();
ctx.beginPath();
ctx.moveTo(10, 100);
ctx.lineTo(30, 2);
ctx.lineTo(50, 100);
ctx.stroke();
ctx.translate(60 ,0);
ctx.beginPath();
ctx.moveTo(10, 100);
ctx.lineTo(30, 3);
ctx.lineTo(50, 100);
ctx.stroke();
ctx.translate(90 ,0);
ctx.save();
ctx.rotate(0.2);
ctx.beginPath();
ctx.moveTo(10, 100);
ctx.lineTo(30, 3);
ctx.lineTo(50, 100);
ctx.closePath();
ctx.stroke();
ctx.restore();
ctx.restore();
ctx.lineJoin = "bevel";
ctx.lineCap = "square";
ctx.translate(200, 0);
ctx.save();
ctx.beginPath();
ctx.moveTo(10, 100);
ctx.lineTo(30, 2);
ctx.lineTo(50, 100);
ctx.stroke();
ctx.translate(60 ,0);
ctx.beginPath();
ctx.moveTo(10, 100);
ctx.lineTo(30, 3);
ctx.lineTo(50, 100);
ctx.stroke();
ctx.translate(90 ,0);
ctx.save();
ctx.rotate(0.2);
ctx.beginPath();
ctx.moveTo(10, 100);
ctx.lineTo(30, 3);
ctx.lineTo(50, 100);
ctx.closePath();
ctx.stroke();
ctx.restore();
ctx.restore();
ctx.lineJoin = "round";
ctx.lineCap = "butt";
ctx.translate(200, 0);
ctx.save();
ctx.beginPath();
ctx.moveTo(10, 100);
ctx.lineTo(30, 2);
ctx.lineTo(50, 100);
ctx.stroke();
ctx.translate(60 ,0);
ctx.beginPath();
ctx.moveTo(10, 100);
ctx.lineTo(30, 3);
ctx.lineTo(50, 100);
ctx.stroke();
ctx.translate(90 ,0);
ctx.save();
ctx.rotate(0.2);
ctx.beginPath();
ctx.moveTo(10, 100);
ctx.lineTo(30, 3);
ctx.lineTo(50, 100);
ctx.closePath();
ctx.stroke();
ctx.restore();
ctx.restore();
function checkPixel(x, y, redComponent)
{
assert_equals(ctx.getImageData(x, y, 1, 1).data[0], redComponent);
}
var testScenarios = [
['Verify Join : miter, Cap : round. 1', 30, 51, 0],
['Verify Join : miter, Cap : round. 2', 30, 49, 255],
['Verify Join : miter, Cap : round. 3', 14, 154, 0],
['Verify Join : miter, Cap : round. 4', 14, 157, 255],
['Verify Join : miter, Cap : round. 5', 89, 22, 0],
['Verify Join : miter, Cap : round. 6', 89, 12, 255],
['Verify Join : miter, Cap : round. 7', 184, 29, 0],
['Verify Join : miter, Cap : round. 8', 180, 27, 255],
['Verify Join : miter, Cap : round. 9', 132, 152, 0],
['Verify Join : miter, Cap : round. 10', 130, 157, 255],
['Verify Join : bevel, Cap : square. 1', 202, 154, 0],
['Verify Join : bevel, Cap : square. 2', 201, 150, 255],
['Verify Join : bevel, Cap : square. 3', 228, 52, 0],
['Verify Join : bevel, Cap : square. 4', 225, 48, 255],
['Verify Join : bevel, Cap : square. 5', 316, 154, 0],
['Verify Join : bevel, Cap : square. 6', 316, 157, 255],
['Verify Join : bevel, Cap : square. 7', 289, 52, 0],
['Verify Join : bevel, Cap : square. 8', 289, 48, 255],
['Verify Join : bevel, Cap : square. 9', 372, 58, 0],
['Verify Join : bevel, Cap : square. 10', 373, 54, 255],
['Verify Join : bevel, Cap : square. 11', 380, 159, 0],
['Verify Join : bevel, Cap : square. 12', 383, 162, 255],
['Verify Join : round, Cap : butt. 1', 405, 147, 0],
['Verify Join : round, Cap : butt. 2', 405, 151, 255],
['Verify Join : round, Cap : butt. 3', 429, 46, 0],
['Verify Join : round, Cap : butt. 4', 429, 43, 255],
['Verify Join : round, Cap : butt. 5', 464, 146, 0],
['Verify Join : round, Cap : butt. 6', 464, 150, 255],
['Verify Join : round, Cap : butt. 7', 489, 46, 0],
['Verify Join : round, Cap : butt. 8', 489, 43, 255],
['Verify Join : round, Cap : butt. 9', 534, 151, 0],
['Verify Join : round, Cap : butt. 10', 531, 153, 255],
['Verify Join : round, Cap : butt. 11', 579, 52, 0],
['Verify Join : round, Cap : butt. 12', 579, 48, 255],
];
generate_tests(checkPixel, testScenarios);
</script>
</body>