Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / content / canvas / test / test_2d.line.cap.round.html
blob33ae23227e33f174107e82bb460d72e348ed34b7
1 <!DOCTYPE HTML>
2 <title>Canvas test: 2d.line.cap.round</title>
3 <!-- Testing: lineCap 'round' is rendered correctly -->
4 <script src="/MochiKit/MochiKit.js"></script>
5 <script src="/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
7 <body>
8 <canvas id="c" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
9 <script>
10 function isPixel(ctx, x,y, r,g,b,a, pos, colour, d) {
11 var pixel = ctx.getImageData(x, y, 1, 1);
12 var pr = pixel.data[0],
13 pg = pixel.data[1],
14 pb = pixel.data[2],
15 pa = pixel.data[3];
16 ok(r-d <= pr && pr <= r+d &&
17 g-d <= pg && pg <= g+d &&
18 b-d <= pb && pb <= b+d &&
19 a-d <= pa && pa <= a+d,
20 "pixel "+pos+" is "+pr+","+pg+","+pb+","+pa+"; expected "+colour+" +/- "+d);
23 SimpleTest.waitForExplicitFinish();
24 MochiKit.DOM.addLoadEvent(function () {
26 var canvas = document.getElementById('c');
27 var ctx = canvas.getContext('2d');
29 ctx.fillStyle = '#0f0';
30 ctx.fillRect(0, 0, 100, 50);
32 var tol = 1; // tolerance to avoid antialiasing artifacts
34 ctx.lineCap = 'round';
35 ctx.lineWidth = 20;
38 ctx.fillStyle = '#f00';
39 ctx.strokeStyle = '#0f0';
41 ctx.beginPath();
42 ctx.moveTo(35-tol, 15);
43 ctx.arc(25, 15, 10-tol, 0, Math.PI, true);
44 ctx.arc(25, 35, 10-tol, Math.PI, 0, true);
45 ctx.fill();
47 ctx.beginPath();
48 ctx.moveTo(25, 15);
49 ctx.lineTo(25, 35);
50 ctx.stroke();
53 ctx.fillStyle = '#0f0';
54 ctx.strokeStyle = '#f00';
56 ctx.beginPath();
57 ctx.moveTo(75, 15);
58 ctx.lineTo(75, 35);
59 ctx.stroke();
61 ctx.beginPath();
62 ctx.moveTo(85+tol, 15);
63 ctx.arc(75, 15, 10+tol, 0, Math.PI, true);
64 ctx.arc(75, 35, 10+tol, Math.PI, 0, true);
65 ctx.fill();
67 isPixel(ctx, 17,6, 0,255,0,255, "17,6", "0,255,0,255", 0);
68 isPixel(ctx, 25,6, 0,255,0,255, "25,6", "0,255,0,255", 0);
69 isPixel(ctx, 32,6, 0,255,0,255, "32,6", "0,255,0,255", 0);
70 isPixel(ctx, 17,43, 0,255,0,255, "17,43", "0,255,0,255", 0);
71 isPixel(ctx, 25,43, 0,255,0,255, "25,43", "0,255,0,255", 0);
72 isPixel(ctx, 32,43, 0,255,0,255, "32,43", "0,255,0,255", 0);
74 isPixel(ctx, 67,6, 0,255,0,255, "67,6", "0,255,0,255", 0);
75 isPixel(ctx, 75,6, 0,255,0,255, "75,6", "0,255,0,255", 0);
76 isPixel(ctx, 82,6, 0,255,0,255, "82,6", "0,255,0,255", 0);
77 isPixel(ctx, 67,43, 0,255,0,255, "67,43", "0,255,0,255", 0);
78 isPixel(ctx, 75,43, 0,255,0,255, "75,43", "0,255,0,255", 0);
79 isPixel(ctx, 82,43, 0,255,0,255, "82,43", "0,255,0,255", 0);
81 SimpleTest.finish();
83 });
84 </script>