-
Notifications
You must be signed in to change notification settings - Fork 54
/
2d.missingargs.worker.js
118 lines (113 loc) · 6.7 KB
/
2d.missingargs.worker.js
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
// DO NOT EDIT! This test has been generated by tools/gentest.py.
// OffscreenCanvas test in a worker:2d.missingargs
// Description:Missing arguments cause TypeError
// Note:
importScripts("/resources/testharness.js");
importScripts("/2dcontext/resources/canvas-tests.js");
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 offscreenCanvas = new OffscreenCanvas(100, 50);
var ctx = offscreenCanvas.getContext('2d');
assert_throws(new TypeError(), function() { ctx.scale(); });
assert_throws(new TypeError(), function() { ctx.scale(1); });
assert_throws(new TypeError(), function() { ctx.rotate(); });
assert_throws(new TypeError(), function() { ctx.translate(); });
assert_throws(new 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(new TypeError(), function() { ctx.transform(); });
assert_throws(new TypeError(), function() { ctx.transform(1); });
assert_throws(new TypeError(), function() { ctx.transform(1, 0); });
assert_throws(new TypeError(), function() { ctx.transform(1, 0, 0); });
assert_throws(new TypeError(), function() { ctx.transform(1, 0, 0, 1); });
assert_throws(new TypeError(), function() { ctx.transform(1, 0, 0, 1, 0); });
}
if (ctx.setTransform) {
assert_throws(new TypeError(), function() { ctx.setTransform(1); });
assert_throws(new TypeError(), function() { ctx.setTransform(1, 0); });
assert_throws(new TypeError(), function() { ctx.setTransform(1, 0, 0); });
assert_throws(new TypeError(), function() { ctx.setTransform(1, 0, 0, 1); });
assert_throws(new TypeError(), function() { ctx.setTransform(1, 0, 0, 1, 0); });
}
assert_throws(new TypeError(), function() { ctx.createLinearGradient(); });
assert_throws(new TypeError(), function() { ctx.createLinearGradient(0); });
assert_throws(new TypeError(), function() { ctx.createLinearGradient(0, 0); });
assert_throws(new TypeError(), function() { ctx.createLinearGradient(0, 0, 1); });
assert_throws(new TypeError(), function() { ctx.createRadialGradient(); });
assert_throws(new TypeError(), function() { ctx.createRadialGradient(0); });
assert_throws(new TypeError(), function() { ctx.createRadialGradient(0, 0); });
assert_throws(new TypeError(), function() { ctx.createRadialGradient(0, 0, 1); });
assert_throws(new TypeError(), function() { ctx.createRadialGradient(0, 0, 1, 0); });
assert_throws(new TypeError(), function() { ctx.createRadialGradient(0, 0, 1, 0, 0); });
assert_throws(new TypeError(), function() { ctx.createPattern(offscreenCanvas); });
assert_throws(new TypeError(), function() { ctx.clearRect(); });
assert_throws(new TypeError(), function() { ctx.clearRect(0); });
assert_throws(new TypeError(), function() { ctx.clearRect(0, 0); });
assert_throws(new TypeError(), function() { ctx.clearRect(0, 0, 0); });
assert_throws(new TypeError(), function() { ctx.fillRect(); });
assert_throws(new TypeError(), function() { ctx.fillRect(0); });
assert_throws(new TypeError(), function() { ctx.fillRect(0, 0); });
assert_throws(new TypeError(), function() { ctx.fillRect(0, 0, 0); });
assert_throws(new TypeError(), function() { ctx.strokeRect(); });
assert_throws(new TypeError(), function() { ctx.strokeRect(0); });
assert_throws(new TypeError(), function() { ctx.strokeRect(0, 0); });
assert_throws(new TypeError(), function() { ctx.strokeRect(0, 0, 0); });
assert_throws(new TypeError(), function() { ctx.moveTo(); });
assert_throws(new TypeError(), function() { ctx.moveTo(0); });
assert_throws(new TypeError(), function() { ctx.lineTo(); });
assert_throws(new TypeError(), function() { ctx.lineTo(0); });
assert_throws(new TypeError(), function() { ctx.quadraticCurveTo(); });
assert_throws(new TypeError(), function() { ctx.quadraticCurveTo(0); });
assert_throws(new TypeError(), function() { ctx.quadraticCurveTo(0, 0); });
assert_throws(new TypeError(), function() { ctx.quadraticCurveTo(0, 0, 0); });
assert_throws(new TypeError(), function() { ctx.bezierCurveTo(); });
assert_throws(new TypeError(), function() { ctx.bezierCurveTo(0); });
assert_throws(new TypeError(), function() { ctx.bezierCurveTo(0, 0); });
assert_throws(new TypeError(), function() { ctx.bezierCurveTo(0, 0, 0); });
assert_throws(new TypeError(), function() { ctx.bezierCurveTo(0, 0, 0, 0); });
assert_throws(new TypeError(), function() { ctx.bezierCurveTo(0, 0, 0, 0, 0); });
assert_throws(new TypeError(), function() { ctx.arcTo(); });
assert_throws(new TypeError(), function() { ctx.arcTo(0); });
assert_throws(new TypeError(), function() { ctx.arcTo(0, 0); });
assert_throws(new TypeError(), function() { ctx.arcTo(0, 0, 0); });
assert_throws(new TypeError(), function() { ctx.arcTo(0, 0, 0, 0); });
assert_throws(new TypeError(), function() { ctx.rect(); });
assert_throws(new TypeError(), function() { ctx.rect(0); });
assert_throws(new TypeError(), function() { ctx.rect(0, 0); });
assert_throws(new TypeError(), function() { ctx.rect(0, 0, 0); });
assert_throws(new TypeError(), function() { ctx.arc(); });
assert_throws(new TypeError(), function() { ctx.arc(0); });
assert_throws(new TypeError(), function() { ctx.arc(0, 0); });
assert_throws(new TypeError(), function() { ctx.arc(0, 0, 1); });
assert_throws(new TypeError(), function() { ctx.arc(0, 0, 1, 0); });
assert_throws(new TypeError(), function() { ctx.drawImage(); });
assert_throws(new TypeError(), function() { ctx.drawImage(offscreenCanvas); });
assert_throws(new TypeError(), function() { ctx.drawImage(offscreenCanvas, 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(new TypeError(), function() { ctx.createImageData(); });
assert_throws(new TypeError(), function() { ctx.createImageData(1); });
}
if (ctx.getImageData) {
assert_throws(new TypeError(), function() { ctx.getImageData(); });
assert_throws(new TypeError(), function() { ctx.getImageData(0); });
assert_throws(new TypeError(), function() { ctx.getImageData(0, 0); });
assert_throws(new TypeError(), function() { ctx.getImageData(0, 0, 1); });
}
if (ctx.putImageData) {
var imgdata = ctx.getImageData(0, 0, 1, 1);
assert_throws(new TypeError(), function() { ctx.putImageData(); });
assert_throws(new TypeError(), function() { ctx.putImageData(imgdata); });
assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 0); });
}
var g = ctx.createLinearGradient(0, 0, 0, 0);
assert_throws(new TypeError(), function() { g.addColorStop(); });
assert_throws(new TypeError(), function() { g.addColorStop(0); });
t.done();
});
done();