Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / content / canvas / test / test_2d.line.width.transformed.html
blob275cd64246ccc0a75574c3c2c643811ba9a5dc2d
1 <!DOCTYPE HTML>
2 <title>Canvas test: 2d.line.width.transformed</title>
3 <!-- Testing: Line stroke widths are affected by scale transformations -->
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 ctx.lineWidth = 4;
33 // Draw a green line over a red box, to check the line is not too small
34 ctx.fillStyle = '#f00';
35 ctx.strokeStyle = '#0f0';
36 ctx.fillRect(15, 15, 20, 20);
37 ctx.save();
38 ctx.scale(5, 1);
39 ctx.beginPath();
40 ctx.moveTo(5, 15);
41 ctx.lineTo(5, 35);
42 ctx.stroke();
43 ctx.restore();
45 // Draw a green box over a red line, to check the line is not too large
46 ctx.fillStyle = '#0f0';
47 ctx.strokeStyle = '#f00';
48 ctx.save();
49 ctx.scale(-5, 1);
50 ctx.beginPath();
51 ctx.moveTo(-15, 15);
52 ctx.lineTo(-15, 35);
53 ctx.stroke();
54 ctx.restore();
55 ctx.fillRect(65, 15, 20, 20);
57 isPixel(ctx, 14,25, 0,255,0,255, "14,25", "0,255,0,255", 0);
58 isPixel(ctx, 15,25, 0,255,0,255, "15,25", "0,255,0,255", 0);
59 isPixel(ctx, 16,25, 0,255,0,255, "16,25", "0,255,0,255", 0);
60 isPixel(ctx, 25,25, 0,255,0,255, "25,25", "0,255,0,255", 0);
61 isPixel(ctx, 34,25, 0,255,0,255, "34,25", "0,255,0,255", 0);
62 isPixel(ctx, 35,25, 0,255,0,255, "35,25", "0,255,0,255", 0);
63 isPixel(ctx, 36,25, 0,255,0,255, "36,25", "0,255,0,255", 0);
65 isPixel(ctx, 64,25, 0,255,0,255, "64,25", "0,255,0,255", 0);
66 isPixel(ctx, 65,25, 0,255,0,255, "65,25", "0,255,0,255", 0);
67 isPixel(ctx, 66,25, 0,255,0,255, "66,25", "0,255,0,255", 0);
68 isPixel(ctx, 75,25, 0,255,0,255, "75,25", "0,255,0,255", 0);
69 isPixel(ctx, 84,25, 0,255,0,255, "84,25", "0,255,0,255", 0);
70 isPixel(ctx, 85,25, 0,255,0,255, "85,25", "0,255,0,255", 0);
71 isPixel(ctx, 86,25, 0,255,0,255, "86,25", "0,255,0,255", 0);
73 SimpleTest.finish();
75 });
76 </script>