Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / canvas / canvas-with-incorrect-args.html
blobe3185d68b4d278cfa2c59db8a3fe84ebc370f134
1 <html>
2 <head>
3 <style>
4 .fail { color: red; font-weight: bold;}
5 .pass { color: green; font-weight: bold;}
6 </style>
7 <script type="text/javascript">
8 failed = false;
10 function debug(msg) {
11 var span = document.createElement("span");
12 span.innerHTML = msg + '<br>';
13 document.getElementById("console").appendChild(span);
16 function pass(msg) {
17 debug('<span class="pass">PASS</span> ' + msg + '</span>');
20 function fail(msg) {
21 debug('<span class="fail">FAIL</span> ' + msg + '</span>');
22 failed = true;
25 function runTest() {
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);
30 try {
31 context.fillRect(0, 0, 0, 0);
32 pass("called fillRect 0*0 fillRect without throwing an exception.");
33 } catch (e) {
34 fail("threw exception code " + e.code + " with 0*0 fillRect");
36 try {
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.");
39 } catch (e) {
40 fail("threw exception code " + e.code + " with Infinity*Infinity fillRect");
42 try {
43 context.fillRect(0, 0, NaN, NaN);
44 pass("did not throw exception with NaN*NaN fillRect.");
45 } catch (e) {
46 fail("threw exception code " + e.code + " on NaN*NaN fillRect.");
48 try {
49 context.clearRect(0, 0, 0, 0);
50 pass("called clearRect 0*0 clearRect without throwing an exception.");
51 } catch (e) {
52 fail("threw exception code " + e.code + " with 0*0 clearRect.");
54 try {
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.");
57 } catch (e) {
58 fail("threw exception code " + e.code + " with Infinity*Infinity clearRect.");
60 try {
61 context.clearRect(0, 0, NaN, NaN);
62 pass("did not throw exception with NaN*NaN clearRect.");
63 } catch (e) {
64 fail("threw exception code " + e.code + " on NaN*NaN clearRect.");
66 try {
67 context.rect(0, 0, 0, 0);
68 pass("called rect 0*0 rect without throwing an exception.");
69 } catch (e) {
70 fail("threw exception code " + e.code + " with 0*0 rect.");
72 try {
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.");
75 } catch (e) {
76 fail("threw exception code " + e.code + " with Infinity*Infinity rect.");
78 try {
79 context.rect(0, 0, NaN, NaN);
80 pass("did not throw exception with NaN*NaN rect.");
81 } catch (e) {
82 fail("threw exception code " + e.code + " on NaN*NaN rect.");
84 try {
85 context.fill();
86 pass("called fill with an empty path without throwing an exception.");
87 } catch (e) {
88 fail("threw exception code " + e.code + " on fill with no path.");
90 try {
91 context.arc(2, 2, 0, 0, 90, true);
92 pass("did not throw exception on arc with zero-length radius");
93 } catch (e) {
94 fail("threw exception code " + e.code + " on arc with zero-length radius");
96 try {
97 context.arc(2, 2, -10, 0, 90, true);
98 fail("did not throw exception on arc with negative-length radius");
99 } catch (e) {
100 pass("threw exception code " + e.code + " on arc with negative-length radius");
102 try {
103 context.arc(2, 2, Infinity, 0, 90, true);
104 pass("did not throw exception on arc with infinite radius");
105 } catch (e) {
106 fail("threw exception code " + e.code + " on arc with infinite radius");
108 try {
109 context.arc(2, 2, NaN, 0, 90, true);
110 pass("did not throw exception on arc with NaN-length radius");
111 } catch (e) {
112 fail("threw exception code " + e.code + " on arc with NaN-length radius");
114 context.beginPath();
115 try {
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");
119 } catch (e) {
120 fail("threw exception code " + e.code + " on arcTo with zero-length radius");
122 context.closePath();
123 context.beginPath();
124 try {
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");
128 } catch (e) {
129 pass("threw exception code " + e.code + " on arcTo with negative-length radius");
131 context.closePath();
132 context.beginPath();
133 try {
134 context.moveTo(10, 10);
135 context.arcTo(2, 2, 4, 4, Infinity);
136 pass("did not throw exception on arcTo with infinite radius");
137 } catch (e) {
138 fail("threw exception code " + e.code + " on arcTo with infinite radius");
140 context.closePath();
141 context.beginPath();
142 try {
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");
146 } catch (e) {
147 fail("threw exception code " + e.code + " on arcTo with NaN-length radius");
149 context.closePath();
150 context.beginPath();
151 try {
152 context.moveTo(10, 10);
153 context.lineTo(Infinity, Infinity);
154 pass("did not throw exception on lineTo(Infinity, Infinity).");
155 } catch (e) {
156 fail("threw exception code " + e.code + " on lineTo(Infinity, Infinity).");
158 context.closePath();
159 context.beginPath();
160 try {
161 context.moveTo(10, 10);
162 context.lineTo(Infinity, 20);
163 pass("did not throw exception on lineTo(Infinity, 20).");
164 } catch (e) {
165 fail("threw exception code " + e.code + " on lineTo(Infinity, 20).");
167 context.closePath();
168 context.beginPath();
169 try {
170 context.moveTo(10, 10);
171 context.lineTo(20, Infinity);
172 pass("did not throw exception on lineTo(20, Infinity).");
173 } catch (e) {
174 fail("threw exception code " + e.code + " on lineTo(20, Infinity).");
176 context.closePath();
177 context.beginPath();
178 try {
179 context.moveTo(10, 10);
180 context.lineTo(NaN, NaN);
181 pass("did not throw exception on lineTo(NaN, NaN).");
182 } catch (e) {
183 fail("threw exception code " + e.code + " on lineTo(NaN, NaN).");
185 context.closePath();
186 context.beginPath();
187 try {
188 context.moveTo(10, 10);
189 context.lineTo(20, NaN);
190 pass("did not throw exception on lineTo(20, NaN).");
191 } catch (e) {
192 fail("threw exception code " + e.code + " on lineTo(20, NaN).");
194 context.closePath();
195 context.beginPath();
196 try {
197 context.moveTo(10, 10);
198 context.lineTo(NaN, 20);
199 pass("did not throw exception on lineTo(NaN, 20).");
200 } catch (e) {
201 fail("threw exception code " + e.code + " on lineTo(NaN, 20).");
203 context.closePath();
204 context.beginPath();
205 try {
206 context.moveTo(10, 10);
207 context.quadraticCurveTo(20, 20, Infinity, Infinity);
208 pass("did not throw exception on quadraticCurveTo(20, 20, Infinity, Infinity).");
209 } catch (e) {
210 fail("threw exception code " + e.code + " on quadraticCurveTo(20, 20, Infinity, Infinity).");
212 context.closePath();
213 context.beginPath();
214 try {
215 context.moveTo(10, 10);
216 context.quadraticCurveTo(Infinity, Infinity, 20, 20);
217 pass("did not throw exception on quadraticCurveTo(Infinity, Infinity, 20, 20).");
218 } catch (e) {
219 fail("threw exception code " + e.code + " on quadraticCurveTo(Infinity, Infinity, 20, 20).");
221 context.closePath();
222 context.beginPath();
223 try {
224 context.moveTo(10, 10);
225 context.quadraticCurveTo(Infinity, 20, 20, 20);
226 pass("did not throw exception on quadraticCurveTo(Infinity, 20, 20, 20).");
227 } catch (e) {
228 fail("threw exception code " + e.code + " on quadraticCurveTo(Infinity, 20, 20, 20).");
230 context.closePath();
231 context.beginPath();
232 try {
233 context.moveTo(10, 10);
234 context.quadraticCurveTo(20, Infinity, 20, 20);
235 pass("did not throw exception on quadraticCurveTo(20, Infinity, 20, 20).");
236 } catch (e) {
237 fail("threw exception code " + e.code + " on quadraticCurveTo(20, Infinity, 20, 20).");
239 context.closePath();
240 context.beginPath();
241 try {
242 context.moveTo(10, 10);
243 context.quadraticCurveTo(20, 20, Infinity, 20);
244 pass("did not throw exception on quadraticCurveTo(20, 20, Infinity, 20).");
245 } catch (e) {
246 fail("threw exception code " + e.code + " on quadraticCurveTo(20, 20, Infinity, 20).");
248 context.closePath();
249 context.beginPath();
250 try {
251 context.moveTo(10, 10);
252 context.quadraticCurveTo(20, 20, 20, Infinity);
253 pass("did not throw exception on quadraticCurveTo(20, 20, 20, Infinity).");
254 } catch (e) {
255 fail("threw exception code " + e.code + " on quadraticCurveTo(20, 20, 20, Infinity).");
257 context.closePath();
258 context.beginPath();
259 try {
260 context.moveTo(10, 10);
261 context.quadraticCurveTo(20, 20, NaN, NaN);
262 pass("did not throw exception on quadraticCurveTo(20, 20, NaN, NaN).");
263 } catch (e) {
264 fail("threw exception code " + e.code + " on quadraticCurveTo(20, 20, NaN, NaN).");
266 context.closePath();
267 context.beginPath();
268 try {
269 context.moveTo(10, 10);
270 context.quadraticCurveTo(NaN, NaN, 20, 20);
271 pass("did not throw exception on quadraticCurveTo(NaN, NaN, 20, 20).");
272 } catch (e) {
273 fail("threw exception code " + e.code + " on quadraticCurveTo(NaN, NaN, 20, 20).");
275 context.closePath();
276 context.beginPath();
277 try {
278 context.moveTo(10, 10);
279 context.quadraticCurveTo(NaN, 20, 20, 20);
280 pass("did not throw exception on quadraticCurveTo(NaN, 20, 20, 20).");
281 } catch (e) {
282 fail("threw exception code " + e.code + " on quadraticCurveTo(NaN, 20, 20, 20).");
284 context.closePath();
285 context.beginPath();
286 try {
287 context.moveTo(10, 10);
288 context.quadraticCurveTo(20, NaN, 20, 20);
289 pass("did not throw exception on quadraticCurveTo(20, NaN, 20, 20).");
290 } catch (e) {
291 fail("threw exception code " + e.code + " on quadraticCurveTo(20, NaN, 20, 20).");
293 context.closePath();
294 context.beginPath();
295 try {
296 context.moveTo(10, 10);
297 context.quadraticCurveTo(20, 20, NaN, 20);
298 pass("did not throw exception on quadraticCurveTo(20, 20, Nan, 20).");
299 } catch (e) {
300 fail("threw exception code " + e.code + " on quadraticCurveTo(20, 20, NaN, 20).");
302 context.closePath();
303 context.beginPath();
304 try {
305 context.moveTo(10, 10);
306 context.quadraticCurveTo(20, 20, 20, NaN);
307 pass("did not throw exception on quadraticCurveTo(20, 20, 20, NaN).");
308 } catch (e) {
309 fail("threw exception code " + e.code + " on quadraticCurveTo(20, 20, 20, NaN).");
311 context.closePath();
312 context.beginPath();
313 try {
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).");
317 } catch (e) {
318 fail("threw exception code " + e.code + " on bezierCurveTo(20, 20, 30, 30, Infinity, Infinity).");
320 context.closePath();
321 context.beginPath();
322 try {
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).");
326 } catch (e) {
327 fail("threw exception code " + e.code + " on bezierCurveTo(20, 20, 30, 30, 30, Infinity).");
329 context.closePath();
330 context.beginPath();
331 try {
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).");
335 } catch (e) {
336 fail("threw exception code " + e.code + " on bezierCurveTo(20, 20, 30, 30, Infinity, 30).");
338 context.closePath();
339 context.beginPath();
340 try {
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).");
344 } catch (e) {
345 fail("threw exception code " + e.code + " on bezierCurveTo(20, 20, Infinity, Infinity, 30, 30).");
347 context.closePath();
348 context.beginPath();
349 try {
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).");
353 } catch (e) {
354 fail("threw exception code " + e.code + " on bezierCurveTo(20, 20, 30, Infinity, 30, 30).");
356 context.closePath();
357 context.beginPath();
358 try {
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).");
362 } catch (e) {
363 fail("threw exception code " + e.code + " on bezierCurveTo(20, 20, Infinity, 30, 30, 30).");
365 context.closePath();
366 context.beginPath();
367 try {
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).");
371 } catch (e) {
372 fail("threw exception code " + e.code + " on bezierCurveTo(Infinity, Infinity, 20, 20, 30, 30).");
374 context.closePath();
375 context.beginPath();
376 try {
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).");
380 } catch (e) {
381 fail("threw exception code " + e.code + " on bezierCurveTo(30, Infinity, 20, 20, 30, 30).");
383 context.closePath();
384 context.beginPath();
385 try {
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).");
389 } catch (e) {
390 fail("threw exception code " + e.code + " on bezierCurveTo(Infinity, 30, 20, 20, 30, 30).");
392 context.closePath();
393 context.beginPath();
394 try {
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).");
398 } catch (e) {
399 fail("threw exception code " + e.code + " on bezierCurveTo(20, 20, 30, 30, NaN, NaN).");
401 context.closePath();
402 context.beginPath();
403 try {
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).");
407 } catch (e) {
408 fail("threw exception code " + e.code + " on bezierCurveTo(20, 20, 30, 30, 0, NaN).");
410 context.closePath();
411 context.beginPath();
412 try {
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).");
416 } catch (e) {
417 fail("threw exception code " + e.code + " on bezierCurveTo(20, 20, 30, 30, NaN, 0).");
419 context.closePath();
420 context.beginPath();
421 try {
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).");
425 } catch (e) {
426 fail("threw exception code " + e.code + " on bezierCurveTo(20, 20, NaN, NaN, 30, 30).");
428 context.closePath();
429 context.beginPath();
430 try {
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).");
434 } catch (e) {
435 fail("threw exception code " + e.code + " on bezierCurveTo(20, 20, 30, NaN, 30, 30).");
437 context.closePath();
438 context.beginPath();
439 try {
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).");
443 } catch (e) {
444 fail("threw exception code " + e.code + " on bezierCurveTo(20, 20, NaN, 30, 30, 30).");
446 context.closePath();
447 context.beginPath();
448 try {
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).");
452 } catch (e) {
453 fail("threw exception code " + e.code + " on bezierCurveTo(NaN, NaN, 20, 20, 30, 30).");
455 context.closePath();
456 context.beginPath();
457 try {
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).");
461 } catch (e) {
462 fail("threw exception code " + e.code + " on bezierCurveTo(20, NaN, 20, 20, 30, 30).");
464 context.closePath();
465 context.beginPath();
466 try {
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).");
470 } catch (e) {
471 fail("threw exception code " + e.code + " on bezierCurveTo(NaN, 20, 20, 20, 30, 30).");
473 context.closePath();
475 var canvas2 = document.createElement('canvas');
476 canvas2.width = 0;
477 canvas2.height = 0;
478 try {
479 var pattern = ctx.createPattern(canvas2, 'repeat');
480 fail("did not throw exception on createPattern with 0x0 canvas.")
481 } catch (e) {
482 pass("threw exception code " + e.code + " on createPattern with 0x0 canvas.")
484 if (!failed) {
485 context.fillStyle = '#0f0';
486 context.fillRect(0, 0, canvas.width, canvas.height);
488 if (window.testRunner)
489 testRunner.dumpAsText();
491 </script>
492 <title>Canvas test of doom</title>
493 </head>
494 <body onload="runTest()">
495 <canvas id="test" width="100" height="100"></canvas><br />
496 <pre id="console">
497 This tests the behaviour of a number of the DOM Canvas drawing methods when
498 given 0, Infinity, or NaN as parameters.
500 </pre>
502 </body>
503 </html>