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