4 .fail { color: red; font-weight: bold;}
5 .pass { color: green; font-weight: bold;}
7 <script type=
"text/javascript">
11 var span
= document
.createElement("span");
12 span
.innerHTML
= msg
+ '<br>';
13 document
.getElementById("console").appendChild(span
);
17 debug('<span class="pass">PASS</span> ' + msg
+ '</span>');
21 debug('<span class="fail">FAIL</span> ' + msg
+ '</span>');
26 var canvas
= document
.getElementById("test");
27 var context
= canvas
.getContext("2d");
28 context
.fillStyle
= '#f00';
29 context
.fillRect(0, 0, canvas
.width
, canvas
.height
);
31 context
.fillRect(0, 0, 0, 0);
32 pass("called fillRect 0*0 fillRect without throwing an exception.");
34 fail("threw exception code " + e
.code
+ " with 0*0 fillRect");
37 context
.fillRect(0, 0, 0.0/1.0, 0.0/1.0);
38 pass("called fillRect with Infinity*Infinity fillRect without throwing an exception.");
40 fail("threw exception code " + e
.code
+ " with Infinity*Infinity fillRect");
43 context
.fillRect(0, 0, NaN
, NaN
);
44 pass("did not throw exception with NaN*NaN fillRect.");
46 fail("threw exception code " + e
.code
+ " on NaN*NaN fillRect.");
49 context
.clearRect(0, 0, 0, 0);
50 pass("called clearRect 0*0 clearRect without throwing an exception.");
52 fail("threw exception code " + e
.code
+ " with 0*0 clearRect.");
55 context
.clearRect(0, 0, 0.0/1.0, 0.0/1.0);
56 pass("called clearRect with Infinity*Infinity clearRect without throwing an exception.");
58 fail("threw exception code " + e
.code
+ " with Infinity*Infinity clearRect.");
61 context
.clearRect(0, 0, NaN
, NaN
);
62 pass("did not throw exception with NaN*NaN clearRect.");
64 fail("threw exception code " + e
.code
+ " on NaN*NaN clearRect.");
67 context
.rect(0, 0, 0, 0);
68 pass("called rect 0*0 rect without throwing an exception.");
70 fail("threw exception code " + e
.code
+ " with 0*0 rect.");
73 context
.rect(0, 0, 0.0/1.0, 0.0/1.0);
74 pass("called rect with Infinity*Infinity rect without throwing an exception.");
76 fail("threw exception code " + e
.code
+ " with Infinity*Infinity rect.");
79 context
.rect(0, 0, NaN
, NaN
);
80 pass("did not throw exception with NaN*NaN rect.");
82 fail("threw exception code " + e
.code
+ " on NaN*NaN rect.");
86 pass("called fill with an empty path without throwing an exception.");
88 fail("threw exception code " + e
.code
+ " on fill with no path.");
91 context
.arc(2, 2, 0, 0, 90, true);
92 pass("did not throw exception on arc with zero-length radius");
94 fail("threw exception code " + e
.code
+ " on arc with zero-length radius");
97 context
.arc(2, 2, -10, 0, 90, true);
98 fail("did not throw exception on arc with negative-length radius");
100 pass("threw exception code " + e
.code
+ " on arc with negative-length radius");
103 context
.arc(2, 2, Infinity
, 0, 90, true);
104 pass("did not throw exception on arc with infinite radius");
106 fail("threw exception code " + e
.code
+ " on arc with infinite radius");
109 context
.arc(2, 2, NaN
, 0, 90, true);
110 pass("did not throw exception on arc with NaN-length radius");
112 fail("threw exception code " + e
.code
+ " on arc with NaN-length radius");
116 context
.moveTo(10, 10);
117 context
.arcTo(2, 2, 4, 4, 0);
118 pass("did not throw exception on arcTo with zero-length radius");
120 fail("threw exception code " + e
.code
+ " on arcTo with zero-length radius");
125 context
.moveTo(10, 10);
126 context
.arcTo(2, 2, 4, 4, -10);
127 fail("did not throw exception on arcTo with negative-length radius");
129 pass("threw exception code " + e
.code
+ " on arcTo with negative-length radius");
134 context
.moveTo(10, 10);
135 context
.arcTo(2, 2, 4, 4, Infinity
);
136 pass("did not throw exception on arcTo with infinite radius");
138 fail("threw exception code " + e
.code
+ " on arcTo with infinite radius");
143 context
.moveTo(10, 10);
144 context
.arcTo(2, 2, 4, 4, NaN
);
145 pass("did not throw exception on arcTo with NaN-length radius");
147 fail("threw exception code " + e
.code
+ " on arcTo with NaN-length radius");
152 context
.moveTo(10, 10);
153 context
.lineTo(Infinity
, Infinity
);
154 pass("did not throw exception on lineTo(Infinity, Infinity).");
156 fail("threw exception code " + e
.code
+ " on lineTo(Infinity, Infinity).");
161 context
.moveTo(10, 10);
162 context
.lineTo(Infinity
, 20);
163 pass("did not throw exception on lineTo(Infinity, 20).");
165 fail("threw exception code " + e
.code
+ " on lineTo(Infinity, 20).");
170 context
.moveTo(10, 10);
171 context
.lineTo(20, Infinity
);
172 pass("did not throw exception on lineTo(20, Infinity).");
174 fail("threw exception code " + e
.code
+ " on lineTo(20, Infinity).");
179 context
.moveTo(10, 10);
180 context
.lineTo(NaN
, NaN
);
181 pass("did not throw exception on lineTo(NaN, NaN).");
183 fail("threw exception code " + e
.code
+ " on lineTo(NaN, NaN).");
188 context
.moveTo(10, 10);
189 context
.lineTo(20, NaN
);
190 pass("did not throw exception on lineTo(20, NaN).");
192 fail("threw exception code " + e
.code
+ " on lineTo(20, NaN).");
197 context
.moveTo(10, 10);
198 context
.lineTo(NaN
, 20);
199 pass("did not throw exception on lineTo(NaN, 20).");
201 fail("threw exception code " + e
.code
+ " on lineTo(NaN, 20).");
206 context
.moveTo(10, 10);
207 context
.quadraticCurveTo(20, 20, Infinity
, Infinity
);
208 pass("did not throw exception on quadraticCurveTo(20, 20, Infinity, Infinity).");
210 fail("threw exception code " + e
.code
+ " on quadraticCurveTo(20, 20, Infinity, Infinity).");
215 context
.moveTo(10, 10);
216 context
.quadraticCurveTo(Infinity
, Infinity
, 20, 20);
217 pass("did not throw exception on quadraticCurveTo(Infinity, Infinity, 20, 20).");
219 fail("threw exception code " + e
.code
+ " on quadraticCurveTo(Infinity, Infinity, 20, 20).");
224 context
.moveTo(10, 10);
225 context
.quadraticCurveTo(Infinity
, 20, 20, 20);
226 pass("did not throw exception on quadraticCurveTo(Infinity, 20, 20, 20).");
228 fail("threw exception code " + e
.code
+ " on quadraticCurveTo(Infinity, 20, 20, 20).");
233 context
.moveTo(10, 10);
234 context
.quadraticCurveTo(20, Infinity
, 20, 20);
235 pass("did not throw exception on quadraticCurveTo(20, Infinity, 20, 20).");
237 fail("threw exception code " + e
.code
+ " on quadraticCurveTo(20, Infinity, 20, 20).");
242 context
.moveTo(10, 10);
243 context
.quadraticCurveTo(20, 20, Infinity
, 20);
244 pass("did not throw exception on quadraticCurveTo(20, 20, Infinity, 20).");
246 fail("threw exception code " + e
.code
+ " on quadraticCurveTo(20, 20, Infinity, 20).");
251 context
.moveTo(10, 10);
252 context
.quadraticCurveTo(20, 20, 20, Infinity
);
253 pass("did not throw exception on quadraticCurveTo(20, 20, 20, Infinity).");
255 fail("threw exception code " + e
.code
+ " on quadraticCurveTo(20, 20, 20, Infinity).");
260 context
.moveTo(10, 10);
261 context
.quadraticCurveTo(20, 20, NaN
, NaN
);
262 pass("did not throw exception on quadraticCurveTo(20, 20, NaN, NaN).");
264 fail("threw exception code " + e
.code
+ " on quadraticCurveTo(20, 20, NaN, NaN).");
269 context
.moveTo(10, 10);
270 context
.quadraticCurveTo(NaN
, NaN
, 20, 20);
271 pass("did not throw exception on quadraticCurveTo(NaN, NaN, 20, 20).");
273 fail("threw exception code " + e
.code
+ " on quadraticCurveTo(NaN, NaN, 20, 20).");
278 context
.moveTo(10, 10);
279 context
.quadraticCurveTo(NaN
, 20, 20, 20);
280 pass("did not throw exception on quadraticCurveTo(NaN, 20, 20, 20).");
282 fail("threw exception code " + e
.code
+ " on quadraticCurveTo(NaN, 20, 20, 20).");
287 context
.moveTo(10, 10);
288 context
.quadraticCurveTo(20, NaN
, 20, 20);
289 pass("did not throw exception on quadraticCurveTo(20, NaN, 20, 20).");
291 fail("threw exception code " + e
.code
+ " on quadraticCurveTo(20, NaN, 20, 20).");
296 context
.moveTo(10, 10);
297 context
.quadraticCurveTo(20, 20, NaN
, 20);
298 pass("did not throw exception on quadraticCurveTo(20, 20, Nan, 20).");
300 fail("threw exception code " + e
.code
+ " on quadraticCurveTo(20, 20, NaN, 20).");
305 context
.moveTo(10, 10);
306 context
.quadraticCurveTo(20, 20, 20, NaN
);
307 pass("did not throw exception on quadraticCurveTo(20, 20, 20, NaN).");
309 fail("threw exception code " + e
.code
+ " on quadraticCurveTo(20, 20, 20, NaN).");
314 context
.moveTo(10, 10);
315 context
.bezierCurveTo(20, 20, 30, 30, Infinity
, Infinity
);
316 pass("did not throw exception on bezierCurveTo(20, 20, 30, 30, Infinity, Infinity).");
318 fail("threw exception code " + e
.code
+ " on bezierCurveTo(20, 20, 30, 30, Infinity, Infinity).");
323 context
.moveTo(10, 10);
324 context
.bezierCurveTo(20, 20, 30, 30, 30, Infinity
);
325 pass("did not throw exception on bezierCurveTo(20, 20, 30, 30, 30, Infinity).");
327 fail("threw exception code " + e
.code
+ " on bezierCurveTo(20, 20, 30, 30, 30, Infinity).");
332 context
.moveTo(10, 10);
333 context
.bezierCurveTo(20, 20, 30, 30, Infinity
, 30);
334 pass("did not throw exception on bezierCurveTo(20, 20, 30, 30, Infinity, 30).");
336 fail("threw exception code " + e
.code
+ " on bezierCurveTo(20, 20, 30, 30, Infinity, 30).");
341 context
.moveTo(10, 10);
342 context
.bezierCurveTo(20, 20, Infinity
, Infinity
, 30, 30);
343 pass("did not throw exception on bezierCurveTo(20, 20, Infinity, Infinity, 30, 30).");
345 fail("threw exception code " + e
.code
+ " on bezierCurveTo(20, 20, Infinity, Infinity, 30, 30).");
350 context
.moveTo(10, 10);
351 context
.bezierCurveTo(20, 20, 30, Infinity
, 30, 30);
352 pass("did not throw exception on bezierCurveTo(20, 20, 30, Infinity, 30, 30).");
354 fail("threw exception code " + e
.code
+ " on bezierCurveTo(20, 20, 30, Infinity, 30, 30).");
359 context
.moveTo(10, 10);
360 context
.bezierCurveTo(20, 20, Infinity
, 30, 30, 30);
361 pass("did not throw exception on bezierCurveTo(20, 20, Infinity, 30, 30, 30).");
363 fail("threw exception code " + e
.code
+ " on bezierCurveTo(20, 20, Infinity, 30, 30, 30).");
368 context
.moveTo(10, 10);
369 context
.bezierCurveTo(Infinity
, Infinity
, 20, 20, 30, 30);
370 pass("did not throw exception on bezierCurveTo(Infinity, Infinity, 20, 20, 30, 30).");
372 fail("threw exception code " + e
.code
+ " on bezierCurveTo(Infinity, Infinity, 20, 20, 30, 30).");
377 context
.moveTo(10, 10);
378 context
.bezierCurveTo(30, Infinity
, 20, 20, 30, 30);
379 pass("did not throw exception on bezierCurveTo(30, Infinity, 20, 20, 30, 30).");
381 fail("threw exception code " + e
.code
+ " on bezierCurveTo(30, Infinity, 20, 20, 30, 30).");
386 context
.moveTo(10, 10);
387 context
.bezierCurveTo(Infinity
, 30, 20, 20, 30, 30);
388 pass("did not throw exception on bezierCurveTo(Infinity, 30, 20, 20, 30, 30).");
390 fail("threw exception code " + e
.code
+ " on bezierCurveTo(Infinity, 30, 20, 20, 30, 30).");
395 context
.moveTo(10, 10);
396 context
.bezierCurveTo(20, 20, 30, 30, NaN
, NaN
);
397 pass("did not throw exception on bezierCurveTo(20, 20, 30, 30, NaN, NaN).");
399 fail("threw exception code " + e
.code
+ " on bezierCurveTo(20, 20, 30, 30, NaN, NaN).");
404 context
.moveTo(10, 10);
405 context
.bezierCurveTo(20, 20, 30, 30, 0, NaN
);
406 pass("did not throw exception on bezierCurveTo(20, 20, 30, 30, 0, NaN).");
408 fail("threw exception code " + e
.code
+ " on bezierCurveTo(20, 20, 30, 30, 0, NaN).");
413 context
.moveTo(10, 10);
414 context
.bezierCurveTo(20, 20, 30, 30, NaN
, 0);
415 pass("did not throw exception on bezierCurveTo(20, 20, 30, 30, NaN, 0).");
417 fail("threw exception code " + e
.code
+ " on bezierCurveTo(20, 20, 30, 30, NaN, 0).");
422 context
.moveTo(10, 10);
423 context
.bezierCurveTo(20, 20, NaN
, NaN
, 30, 30);
424 pass("did not throw exception on bezierCurveTo(20, 20, NaN, NaN, 30, 30).");
426 fail("threw exception code " + e
.code
+ " on bezierCurveTo(20, 20, NaN, NaN, 30, 30).");
431 context
.moveTo(10, 10);
432 context
.bezierCurveTo(20, 20, 30, NaN
, 30, 30);
433 pass("did not throw exception on bezierCurveTo(20, 20, 30, NaN, 30, 30).");
435 fail("threw exception code " + e
.code
+ " on bezierCurveTo(20, 20, 30, NaN, 30, 30).");
440 context
.moveTo(10, 10);
441 context
.bezierCurveTo(20, 20, NaN
, 30, 30, 30);
442 pass("did not throw exception on bezierCurveTo(20, 20, NaN, 30, 30, 30).");
444 fail("threw exception code " + e
.code
+ " on bezierCurveTo(20, 20, NaN, 30, 30, 30).");
449 context
.moveTo(10, 10);
450 context
.bezierCurveTo(NaN
, NaN
, 20, 20, 30, 30);
451 pass("did not throw exception on bezierCurveTo(NaN, NaN, 20, 20, 30, 30).");
453 fail("threw exception code " + e
.code
+ " on bezierCurveTo(NaN, NaN, 20, 20, 30, 30).");
458 context
.moveTo(10, 10);
459 context
.bezierCurveTo(20, NaN
, 20, 20, 30, 30);
460 pass("did not throw exception on bezierCurveTo(20, NaN, 20, 20, 30, 30).");
462 fail("threw exception code " + e
.code
+ " on bezierCurveTo(20, NaN, 20, 20, 30, 30).");
467 context
.moveTo(10, 10);
468 context
.bezierCurveTo(NaN
, 20, 20, 20, 30, 30);
469 pass("did not throw exception on bezierCurveTo(NaN, 20, 20, 20, 30, 30).");
471 fail("threw exception code " + e
.code
+ " on bezierCurveTo(NaN, 20, 20, 20, 30, 30).");
475 var canvas2
= document
.createElement('canvas');
479 var pattern
= ctx
.createPattern(canvas2
, 'repeat');
480 fail("did not throw exception on createPattern with 0x0 canvas.")
482 pass("threw exception code " + e
.code
+ " on createPattern with 0x0 canvas.")
485 context
.fillStyle
= '#0f0';
486 context
.fillRect(0, 0, canvas
.width
, canvas
.height
);
488 if (window
.testRunner
)
489 testRunner
.dumpAsText();
492 <title>Canvas test of doom
</title>
494 <body onload=
"runTest()">
495 <canvas id=
"test" width=
"100" height=
"100"></canvas><br />
497 This tests the behaviour of a number of the DOM Canvas drawing methods when
498 given
0, Infinity, or NaN as parameters.