Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / content / canvas / test / test_2d.path.arcTo.shape.curve1.html
blob82b375b9e464b61e228922da080538ad6d3d0292
1 <!DOCTYPE HTML>
2 <title>Canvas test: 2d.path.arcTo.shape.curve1</title>
3 <!-- Testing: arcTo() curves in the right kind of shape -->
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);
22 function todo_isPixel(ctx, x,y, r,g,b,a, pos, colour, d) {
23 var pixel = ctx.getImageData(x, y, 1, 1);
24 var pr = pixel.data[0],
25 pg = pixel.data[1],
26 pb = pixel.data[2],
27 pa = pixel.data[3];
28 todo(r-d <= pr && pr <= r+d &&
29 g-d <= pg && pg <= g+d &&
30 b-d <= pb && pb <= b+d &&
31 a-d <= pa && pa <= a+d,
32 "pixel "+pos+" is "+pr+","+pg+","+pb+","+pa+"; expected "+colour+" +/- "+d);
35 SimpleTest.waitForExplicitFinish();
36 MochiKit.DOM.addLoadEvent(function () {
38 var canvas = document.getElementById('c');
39 var ctx = canvas.getContext('2d');
41 var tol = 1.5; // tolerance to avoid antialiasing artifacts
43 ctx.fillStyle = '#0f0';
44 ctx.fillRect(0, 0, 100, 50);
46 ctx.strokeStyle = '#f00';
47 ctx.lineWidth = 10;
48 ctx.beginPath();
49 ctx.moveTo(10, 25);
50 ctx.arcTo(75, 25, 75, 60, 20);
51 ctx.stroke();
53 ctx.fillStyle = '#0f0';
54 ctx.beginPath();
55 ctx.rect(10, 20, 45, 10);
56 ctx.moveTo(80, 45);
57 ctx.arc(55, 45, 25+tol, 0, -Math.PI/2, true);
58 ctx.arc(55, 45, 15-tol, -Math.PI/2, 0, false);
59 ctx.fill();
61 isPixel(ctx, 50,25, 0,255,0,255, "50,25", "0,255,0,255", 0);
62 isPixel(ctx, 55,19, 0,255,0,255, "55,19", "0,255,0,255", 0);
63 isPixel(ctx, 55,20, 0,255,0,255, "55,20", "0,255,0,255", 0);
64 isPixel(ctx, 55,21, 0,255,0,255, "55,21", "0,255,0,255", 0);
65 isPixel(ctx, 64,22, 0,255,0,255, "64,22", "0,255,0,255", 0);
66 isPixel(ctx, 65,21, 0,255,0,255, "65,21", "0,255,0,255", 0);
67 isPixel(ctx, 72,28, 0,255,0,255, "72,28", "0,255,0,255", 0);
68 isPixel(ctx, 73,27, 0,255,0,255, "73,27", "0,255,0,255", 0);
69 isPixel(ctx, 78,36, 0,255,0,255, "78,36", "0,255,0,255", 0);
70 isPixel(ctx, 79,35, 0,255,0,255, "79,35", "0,255,0,255", 0);
71 isPixel(ctx, 80,44, 0,255,0,255, "80,44", "0,255,0,255", 0);
72 todo_isPixel(ctx, 80,45, 0,255,0,255, "80,45", "0,255,0,255", 0);
73 todo_isPixel(ctx, 80,46, 0,255,0,255, "80,46", "0,255,0,255", 0);
75 SimpleTest.finish();
77 });
78 </script>