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