conformance_requirements.yaml (8152B)
1 - name: 2d.conformance.requirements.delete 2 desc: window.CanvasRenderingContext2D is Configurable 3 notes: &bindings Defined in "Web IDL" (draft) 4 canvas_types: ['HtmlCanvas'] 5 code: | 6 @assert window.CanvasRenderingContext2D !== undefined; 7 @assert delete window.CanvasRenderingContext2D === true; 8 @assert window.CanvasRenderingContext2D === undefined; 9 10 - name: 2d.conformance.requirements.basics 11 desc: void methods return undefined 12 notes: *bindings 13 code: | 14 @assert ctx.save() === undefined; 15 @assert ctx.restore() === undefined; 16 @assert ctx.scale(1, 1) === undefined; 17 @assert ctx.rotate(0) === undefined; 18 @assert ctx.translate(0, 0) === undefined; 19 if (ctx.transform) { // (avoid spurious failures, since the aim here is not to test that all features are supported) 20 @assert ctx.transform(1, 0, 0, 1, 0, 0) === undefined; 21 } 22 if (ctx.setTransform) { 23 @assert ctx.setTransform(1, 0, 0, 1, 0, 0) === undefined; 24 @assert ctx.setTransform() === undefined; 25 } 26 @assert ctx.clearRect(0, 0, 0, 0) === undefined; 27 @assert ctx.fillRect(0, 0, 0, 0) === undefined; 28 @assert ctx.strokeRect(0, 0, 0, 0) === undefined; 29 @assert ctx.beginPath() === undefined; 30 @assert ctx.closePath() === undefined; 31 @assert ctx.moveTo(0, 0) === undefined; 32 @assert ctx.lineTo(0, 0) === undefined; 33 @assert ctx.quadraticCurveTo(0, 0, 0, 0) === undefined; 34 @assert ctx.bezierCurveTo(0, 0, 0, 0, 0, 0) === undefined; 35 @assert ctx.arcTo(0, 0, 0, 0, 1) === undefined; 36 @assert ctx.rect(0, 0, 0, 0) === undefined; 37 @assert ctx.arc(0, 0, 1, 0, 0, true) === undefined; 38 @assert ctx.fill() === undefined; 39 @assert ctx.stroke() === undefined; 40 @assert ctx.clip() === undefined; 41 if (ctx.fillText) { 42 @assert ctx.fillText('test', 0, 0) === undefined; 43 @assert ctx.strokeText('test', 0, 0) === undefined; 44 } 45 if (ctx.putImageData) { 46 @assert ctx.putImageData(ctx.getImageData(0, 0, 1, 1), 0, 0) === undefined; 47 } 48 @assert ctx.drawImage(canvas, 0, 0, 1, 1, 0, 0, 0, 0) === undefined; 49 @assert ctx.createLinearGradient(0, 0, 0, 0).addColorStop(0, 'white') === undefined; 50 51 - name: 2d.conformance.requirements.missingargs 52 desc: Missing arguments cause TypeError 53 code: | 54 @assert throws TypeError ctx.scale(); 55 @assert throws TypeError ctx.scale(1); 56 @assert throws TypeError ctx.rotate(); 57 @assert throws TypeError ctx.translate(); 58 @assert throws TypeError ctx.translate(0); 59 if (ctx.transform) { // (avoid spurious failures, since the aim here is not to test that all features are supported) 60 @assert throws TypeError ctx.transform(); 61 @assert throws TypeError ctx.transform(1); 62 @assert throws TypeError ctx.transform(1, 0); 63 @assert throws TypeError ctx.transform(1, 0, 0); 64 @assert throws TypeError ctx.transform(1, 0, 0, 1); 65 @assert throws TypeError ctx.transform(1, 0, 0, 1, 0); 66 } 67 if (ctx.setTransform) { 68 @assert throws TypeError ctx.setTransform(1); 69 @assert throws TypeError ctx.setTransform(1, 0); 70 @assert throws TypeError ctx.setTransform(1, 0, 0); 71 @assert throws TypeError ctx.setTransform(1, 0, 0, 1); 72 @assert throws TypeError ctx.setTransform(1, 0, 0, 1, 0); 73 } 74 @assert throws TypeError ctx.createLinearGradient(); 75 @assert throws TypeError ctx.createLinearGradient(0); 76 @assert throws TypeError ctx.createLinearGradient(0, 0); 77 @assert throws TypeError ctx.createLinearGradient(0, 0, 1); 78 @assert throws TypeError ctx.createRadialGradient(); 79 @assert throws TypeError ctx.createRadialGradient(0); 80 @assert throws TypeError ctx.createRadialGradient(0, 0); 81 @assert throws TypeError ctx.createRadialGradient(0, 0, 1); 82 @assert throws TypeError ctx.createRadialGradient(0, 0, 1, 0); 83 @assert throws TypeError ctx.createRadialGradient(0, 0, 1, 0, 0); 84 @assert throws TypeError ctx.createPattern(canvas); 85 @assert throws TypeError ctx.clearRect(); 86 @assert throws TypeError ctx.clearRect(0); 87 @assert throws TypeError ctx.clearRect(0, 0); 88 @assert throws TypeError ctx.clearRect(0, 0, 0); 89 @assert throws TypeError ctx.fillRect(); 90 @assert throws TypeError ctx.fillRect(0); 91 @assert throws TypeError ctx.fillRect(0, 0); 92 @assert throws TypeError ctx.fillRect(0, 0, 0); 93 @assert throws TypeError ctx.strokeRect(); 94 @assert throws TypeError ctx.strokeRect(0); 95 @assert throws TypeError ctx.strokeRect(0, 0); 96 @assert throws TypeError ctx.strokeRect(0, 0, 0); 97 @assert throws TypeError ctx.moveTo(); 98 @assert throws TypeError ctx.moveTo(0); 99 @assert throws TypeError ctx.lineTo(); 100 @assert throws TypeError ctx.lineTo(0); 101 @assert throws TypeError ctx.quadraticCurveTo(); 102 @assert throws TypeError ctx.quadraticCurveTo(0); 103 @assert throws TypeError ctx.quadraticCurveTo(0, 0); 104 @assert throws TypeError ctx.quadraticCurveTo(0, 0, 0); 105 @assert throws TypeError ctx.bezierCurveTo(); 106 @assert throws TypeError ctx.bezierCurveTo(0); 107 @assert throws TypeError ctx.bezierCurveTo(0, 0); 108 @assert throws TypeError ctx.bezierCurveTo(0, 0, 0); 109 @assert throws TypeError ctx.bezierCurveTo(0, 0, 0, 0); 110 @assert throws TypeError ctx.bezierCurveTo(0, 0, 0, 0, 0); 111 @assert throws TypeError ctx.arcTo(); 112 @assert throws TypeError ctx.arcTo(0); 113 @assert throws TypeError ctx.arcTo(0, 0); 114 @assert throws TypeError ctx.arcTo(0, 0, 0); 115 @assert throws TypeError ctx.arcTo(0, 0, 0, 0); 116 @assert throws TypeError ctx.rect(); 117 @assert throws TypeError ctx.rect(0); 118 @assert throws TypeError ctx.rect(0, 0); 119 @assert throws TypeError ctx.rect(0, 0, 0); 120 @assert throws TypeError ctx.arc(); 121 @assert throws TypeError ctx.arc(0); 122 @assert throws TypeError ctx.arc(0, 0); 123 @assert throws TypeError ctx.arc(0, 0, 1); 124 @assert throws TypeError ctx.arc(0, 0, 1, 0); 125 // (6th argument to arc is optional) 126 if (ctx.isPointInPath) { 127 @assert throws TypeError ctx.isPointInPath(); 128 @assert throws TypeError ctx.isPointInPath(0); 129 } 130 if (ctx.drawFocusRing) { 131 @assert throws TypeError ctx.drawFocusRing(); 132 @assert throws TypeError ctx.drawFocusRing(canvas); 133 @assert throws TypeError ctx.drawFocusRing(canvas, 0); 134 } 135 if (ctx.fillText) { 136 @assert throws TypeError ctx.fillText(); 137 @assert throws TypeError ctx.fillText('test'); 138 @assert throws TypeError ctx.fillText('test', 0); 139 @assert throws TypeError ctx.strokeText(); 140 @assert throws TypeError ctx.strokeText('test'); 141 @assert throws TypeError ctx.strokeText('test', 0); 142 @assert throws TypeError ctx.measureText(); 143 } 144 @assert throws TypeError ctx.drawImage(); 145 @assert throws TypeError ctx.drawImage(canvas); 146 @assert throws TypeError ctx.drawImage(canvas, 0); 147 // TODO: n >= 3 args on drawImage could be either a valid overload, 148 // or too few for another overload, or too many for another 149 // overload - what should happen? 150 if (ctx.createImageData) { 151 @assert throws TypeError ctx.createImageData(); 152 @assert throws TypeError ctx.createImageData(1); 153 } 154 if (ctx.getImageData) { 155 @assert throws TypeError ctx.getImageData(); 156 @assert throws TypeError ctx.getImageData(0); 157 @assert throws TypeError ctx.getImageData(0, 0); 158 @assert throws TypeError ctx.getImageData(0, 0, 1); 159 } 160 if (ctx.putImageData) { 161 var imgdata = ctx.getImageData(0, 0, 1, 1); 162 @assert throws TypeError ctx.putImageData(); 163 @assert throws TypeError ctx.putImageData(imgdata); 164 @assert throws TypeError ctx.putImageData(imgdata, 0); 165 } 166 var g = ctx.createLinearGradient(0, 0, 0, 0); 167 @assert throws TypeError g.addColorStop(); @moz-todo 168 @assert throws TypeError g.addColorStop(0); @moz-todo 169 170 171 - name: 2d.conformance.requirements.drawings 172 desc: void methods return undefined 173 images: 174 - yellow.png 175 canvas_types: ['HtmlCanvas'] 176 code: | 177 @assert ctx.drawImage(document.getElementById('yellow.png'), 0, 0, 1, 1, 0, 0, 0, 0) === undefined;