2d.conformance.requirements.missingargs.html (7990B)
1 <!DOCTYPE html> 2 <!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> 3 <meta charset="UTF-8"> 4 <title>OffscreenCanvas test: 2d.conformance.requirements.missingargs</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/html/canvas/resources/canvas-tests.js"></script> 8 9 <h1>2d.conformance.requirements.missingargs</h1> 10 <p class="desc">Missing arguments cause TypeError</p> 11 12 13 <script> 14 var t = async_test("Missing arguments cause TypeError"); 15 var t_pass = t.done.bind(t); 16 var t_fail = t.step_func(function(reason) { 17 throw reason; 18 }); 19 t.step(function() { 20 21 var canvas = new OffscreenCanvas(100, 50); 22 var ctx = canvas.getContext('2d'); 23 24 assert_throws_js(TypeError, function() { ctx.scale(); }); 25 assert_throws_js(TypeError, function() { ctx.scale(1); }); 26 assert_throws_js(TypeError, function() { ctx.rotate(); }); 27 assert_throws_js(TypeError, function() { ctx.translate(); }); 28 assert_throws_js(TypeError, function() { ctx.translate(0); }); 29 if (ctx.transform) { // (avoid spurious failures, since the aim here is not to test that all features are supported) 30 assert_throws_js(TypeError, function() { ctx.transform(); }); 31 assert_throws_js(TypeError, function() { ctx.transform(1); }); 32 assert_throws_js(TypeError, function() { ctx.transform(1, 0); }); 33 assert_throws_js(TypeError, function() { ctx.transform(1, 0, 0); }); 34 assert_throws_js(TypeError, function() { ctx.transform(1, 0, 0, 1); }); 35 assert_throws_js(TypeError, function() { ctx.transform(1, 0, 0, 1, 0); }); 36 } 37 if (ctx.setTransform) { 38 assert_throws_js(TypeError, function() { ctx.setTransform(1); }); 39 assert_throws_js(TypeError, function() { ctx.setTransform(1, 0); }); 40 assert_throws_js(TypeError, function() { ctx.setTransform(1, 0, 0); }); 41 assert_throws_js(TypeError, function() { ctx.setTransform(1, 0, 0, 1); }); 42 assert_throws_js(TypeError, function() { ctx.setTransform(1, 0, 0, 1, 0); }); 43 } 44 assert_throws_js(TypeError, function() { ctx.createLinearGradient(); }); 45 assert_throws_js(TypeError, function() { ctx.createLinearGradient(0); }); 46 assert_throws_js(TypeError, function() { ctx.createLinearGradient(0, 0); }); 47 assert_throws_js(TypeError, function() { ctx.createLinearGradient(0, 0, 1); }); 48 assert_throws_js(TypeError, function() { ctx.createRadialGradient(); }); 49 assert_throws_js(TypeError, function() { ctx.createRadialGradient(0); }); 50 assert_throws_js(TypeError, function() { ctx.createRadialGradient(0, 0); }); 51 assert_throws_js(TypeError, function() { ctx.createRadialGradient(0, 0, 1); }); 52 assert_throws_js(TypeError, function() { ctx.createRadialGradient(0, 0, 1, 0); }); 53 assert_throws_js(TypeError, function() { ctx.createRadialGradient(0, 0, 1, 0, 0); }); 54 assert_throws_js(TypeError, function() { ctx.createPattern(canvas); }); 55 assert_throws_js(TypeError, function() { ctx.clearRect(); }); 56 assert_throws_js(TypeError, function() { ctx.clearRect(0); }); 57 assert_throws_js(TypeError, function() { ctx.clearRect(0, 0); }); 58 assert_throws_js(TypeError, function() { ctx.clearRect(0, 0, 0); }); 59 assert_throws_js(TypeError, function() { ctx.fillRect(); }); 60 assert_throws_js(TypeError, function() { ctx.fillRect(0); }); 61 assert_throws_js(TypeError, function() { ctx.fillRect(0, 0); }); 62 assert_throws_js(TypeError, function() { ctx.fillRect(0, 0, 0); }); 63 assert_throws_js(TypeError, function() { ctx.strokeRect(); }); 64 assert_throws_js(TypeError, function() { ctx.strokeRect(0); }); 65 assert_throws_js(TypeError, function() { ctx.strokeRect(0, 0); }); 66 assert_throws_js(TypeError, function() { ctx.strokeRect(0, 0, 0); }); 67 assert_throws_js(TypeError, function() { ctx.moveTo(); }); 68 assert_throws_js(TypeError, function() { ctx.moveTo(0); }); 69 assert_throws_js(TypeError, function() { ctx.lineTo(); }); 70 assert_throws_js(TypeError, function() { ctx.lineTo(0); }); 71 assert_throws_js(TypeError, function() { ctx.quadraticCurveTo(); }); 72 assert_throws_js(TypeError, function() { ctx.quadraticCurveTo(0); }); 73 assert_throws_js(TypeError, function() { ctx.quadraticCurveTo(0, 0); }); 74 assert_throws_js(TypeError, function() { ctx.quadraticCurveTo(0, 0, 0); }); 75 assert_throws_js(TypeError, function() { ctx.bezierCurveTo(); }); 76 assert_throws_js(TypeError, function() { ctx.bezierCurveTo(0); }); 77 assert_throws_js(TypeError, function() { ctx.bezierCurveTo(0, 0); }); 78 assert_throws_js(TypeError, function() { ctx.bezierCurveTo(0, 0, 0); }); 79 assert_throws_js(TypeError, function() { ctx.bezierCurveTo(0, 0, 0, 0); }); 80 assert_throws_js(TypeError, function() { ctx.bezierCurveTo(0, 0, 0, 0, 0); }); 81 assert_throws_js(TypeError, function() { ctx.arcTo(); }); 82 assert_throws_js(TypeError, function() { ctx.arcTo(0); }); 83 assert_throws_js(TypeError, function() { ctx.arcTo(0, 0); }); 84 assert_throws_js(TypeError, function() { ctx.arcTo(0, 0, 0); }); 85 assert_throws_js(TypeError, function() { ctx.arcTo(0, 0, 0, 0); }); 86 assert_throws_js(TypeError, function() { ctx.rect(); }); 87 assert_throws_js(TypeError, function() { ctx.rect(0); }); 88 assert_throws_js(TypeError, function() { ctx.rect(0, 0); }); 89 assert_throws_js(TypeError, function() { ctx.rect(0, 0, 0); }); 90 assert_throws_js(TypeError, function() { ctx.arc(); }); 91 assert_throws_js(TypeError, function() { ctx.arc(0); }); 92 assert_throws_js(TypeError, function() { ctx.arc(0, 0); }); 93 assert_throws_js(TypeError, function() { ctx.arc(0, 0, 1); }); 94 assert_throws_js(TypeError, function() { ctx.arc(0, 0, 1, 0); }); 95 // (6th argument to arc is optional) 96 if (ctx.isPointInPath) { 97 assert_throws_js(TypeError, function() { ctx.isPointInPath(); }); 98 assert_throws_js(TypeError, function() { ctx.isPointInPath(0); }); 99 } 100 if (ctx.drawFocusRing) { 101 assert_throws_js(TypeError, function() { ctx.drawFocusRing(); }); 102 assert_throws_js(TypeError, function() { ctx.drawFocusRing(canvas); }); 103 assert_throws_js(TypeError, function() { ctx.drawFocusRing(canvas, 0); }); 104 } 105 if (ctx.fillText) { 106 assert_throws_js(TypeError, function() { ctx.fillText(); }); 107 assert_throws_js(TypeError, function() { ctx.fillText('test'); }); 108 assert_throws_js(TypeError, function() { ctx.fillText('test', 0); }); 109 assert_throws_js(TypeError, function() { ctx.strokeText(); }); 110 assert_throws_js(TypeError, function() { ctx.strokeText('test'); }); 111 assert_throws_js(TypeError, function() { ctx.strokeText('test', 0); }); 112 assert_throws_js(TypeError, function() { ctx.measureText(); }); 113 } 114 assert_throws_js(TypeError, function() { ctx.drawImage(); }); 115 assert_throws_js(TypeError, function() { ctx.drawImage(canvas); }); 116 assert_throws_js(TypeError, function() { ctx.drawImage(canvas, 0); }); 117 // TODO: n >= 3 args on drawImage could be either a valid overload, 118 // or too few for another overload, or too many for another 119 // overload - what should happen? 120 if (ctx.createImageData) { 121 assert_throws_js(TypeError, function() { ctx.createImageData(); }); 122 assert_throws_js(TypeError, function() { ctx.createImageData(1); }); 123 } 124 if (ctx.getImageData) { 125 assert_throws_js(TypeError, function() { ctx.getImageData(); }); 126 assert_throws_js(TypeError, function() { ctx.getImageData(0); }); 127 assert_throws_js(TypeError, function() { ctx.getImageData(0, 0); }); 128 assert_throws_js(TypeError, function() { ctx.getImageData(0, 0, 1); }); 129 } 130 if (ctx.putImageData) { 131 var imgdata = ctx.getImageData(0, 0, 1, 1); 132 assert_throws_js(TypeError, function() { ctx.putImageData(); }); 133 assert_throws_js(TypeError, function() { ctx.putImageData(imgdata); }); 134 assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 0); }); 135 } 136 var g = ctx.createLinearGradient(0, 0, 0, 0); 137 assert_throws_js(TypeError, function() { g.addColorStop(); }); 138 assert_throws_js(TypeError, function() { g.addColorStop(0); }); 139 t.done(); 140 141 }); 142 </script>