2 <title>Canvas test:
2d.path.arcTo.nonfinite
</title>
3 <!-- Testing: arcTo() with Infinity/NaN is ignored -->
4 <script src=
"/MochiKit/MochiKit.js"></script>
5 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel=
"stylesheet" href=
"/tests/SimpleTest/test.css">
8 <canvas id=
"c" width=
"100" height=
"50"><p class=
"fallback">FAIL (fallback content)
</p></canvas>
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],
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 var _thrown_outer
= false;
34 ctx
.arcTo(Infinity
, 50, 0, 50, 0);
35 ctx
.arcTo(-Infinity
, 50, 0, 50, 0);
36 ctx
.arcTo(NaN
, 50, 0, 50, 0);
37 ctx
.arcTo(0, Infinity
, 0, 50, 0);
38 ctx
.arcTo(0, -Infinity
, 0, 50, 0);
39 ctx
.arcTo(0, NaN
, 0, 50, 0);
40 ctx
.arcTo(0, 50, Infinity
, 50, 0);
41 ctx
.arcTo(0, 50, -Infinity
, 50, 0);
42 ctx
.arcTo(0, 50, NaN
, 50, 0);
43 ctx
.arcTo(0, 50, 0, Infinity
, 0);
44 ctx
.arcTo(0, 50, 0, -Infinity
, 0);
45 ctx
.arcTo(0, 50, 0, NaN
, 0);
46 ctx
.arcTo(0, 50, 0, 50, Infinity
);
47 ctx
.arcTo(0, 50, 0, 50, -Infinity
);
48 ctx
.arcTo(0, 50, 0, 50, NaN
);
49 ctx
.arcTo(Infinity
, Infinity
, 0, 50, 0);
50 ctx
.arcTo(Infinity
, Infinity
, Infinity
, 50, 0);
51 ctx
.arcTo(Infinity
, Infinity
, Infinity
, Infinity
, 0);
52 ctx
.arcTo(Infinity
, Infinity
, Infinity
, Infinity
, Infinity
);
53 ctx
.arcTo(Infinity
, Infinity
, Infinity
, 50, Infinity
);
54 ctx
.arcTo(Infinity
, Infinity
, 0, Infinity
, 0);
55 ctx
.arcTo(Infinity
, Infinity
, 0, Infinity
, Infinity
);
56 ctx
.arcTo(Infinity
, Infinity
, 0, 50, Infinity
);
57 ctx
.arcTo(Infinity
, 50, Infinity
, 50, 0);
58 ctx
.arcTo(Infinity
, 50, Infinity
, Infinity
, 0);
59 ctx
.arcTo(Infinity
, 50, Infinity
, Infinity
, Infinity
);
60 ctx
.arcTo(Infinity
, 50, Infinity
, 50, Infinity
);
61 ctx
.arcTo(Infinity
, 50, 0, Infinity
, 0);
62 ctx
.arcTo(Infinity
, 50, 0, Infinity
, Infinity
);
63 ctx
.arcTo(Infinity
, 50, 0, 50, Infinity
);
64 ctx
.arcTo(0, Infinity
, Infinity
, 50, 0);
65 ctx
.arcTo(0, Infinity
, Infinity
, Infinity
, 0);
66 ctx
.arcTo(0, Infinity
, Infinity
, Infinity
, Infinity
);
67 ctx
.arcTo(0, Infinity
, Infinity
, 50, Infinity
);
68 ctx
.arcTo(0, Infinity
, 0, Infinity
, 0);
69 ctx
.arcTo(0, Infinity
, 0, Infinity
, Infinity
);
70 ctx
.arcTo(0, Infinity
, 0, 50, Infinity
);
71 ctx
.arcTo(0, 50, Infinity
, Infinity
, 0);
72 ctx
.arcTo(0, 50, Infinity
, Infinity
, Infinity
);
73 ctx
.arcTo(0, 50, Infinity
, 50, Infinity
);
74 ctx
.arcTo(0, 50, 0, Infinity
, Infinity
);
77 ctx
.fillStyle
= '#0f0';
79 isPixel(ctx
, 50,25, 0,255,0,255, "50,25", "0,255,0,255", 0);
80 isPixel(ctx
, 90,45, 0,255,0,255, "90,45", "0,255,0,255", 0);
85 todo(!_thrown_outer
, 'should not throw exception');