summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.turbulence.inputTypes.tentative.html
blob: 040c62a96bbb633dc6bf1602461f08a33fe9ec1a (plain)
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
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<title>OffscreenCanvas test: 2d.filter.canvasFilterObject.turbulence.inputTypes.tentative</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/canvas/resources/canvas-tests.js"></script>

<h1>2d.filter.canvasFilterObject.turbulence.inputTypes.tentative</h1>
<p class="desc">Test exceptions on CanvasFilter() turbulence object</p>


<script>
var t = async_test("Test exceptions on CanvasFilter() turbulence object");
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');

  const errorTestCases = [
    {baseFrequency: {}},
    {baseFrequency: -1},
    {baseFrequency: [0, -1]},
    {baseFrequency: NaN},
    {baseFrequency: Infinity},
    {baseFrequency: undefined},
    {baseFrequency: -Infinity},
    {baseFrequency: 'test'},

    {numOctaves: {}},
    {numOctaves: -1},
    {numOctaves: NaN},
    {numOctaves: Infinity},
    {numOctaves: undefined},
    {numOctaves: -Infinity},
    {numOctaves: [1, 1]},
    {numOctaves: 'test'},

    {seed: {}},
    {seed: NaN},
    {seed: Infinity},
    {seed: undefined},
    {seed: -Infinity},
    {seed: [1, 1]},
    {seed: 'test'},

    {stitchTiles: {}},
    {stitchTiles: NaN},
    {stitchTiles: Infinity},
    {stitchTiles: undefined},
    {stitchTiles: -Infinity},
    {stitchTiles: [1, 1]},
    {stitchTiles: 'test'},
    {stitchTiles: null},
    {stitchTiles: []},
    {stitchTiles: [10]},
    {stitchTiles: 30},
    {stitchTiles: false},
    {stitchTiles: true},
    {stitchTiles: '10'},
    {stitchTiles: -1},

    {type: {}},
    {type: NaN},
    {type: Infinity},
    {type: undefined},
    {type: -Infinity},
    {type: [1, 1]},
    {type: 'test'},
    {type: null},
    {type: []},
    {type: [10]},
    {type: 30},
    {type: false},
    {type: true},
    {type: '10'},
    {type: -1},
  ]

  // null and [] = 0 when parsed as number
  const workingTestCases = [
    {baseFrequency: null},
    {baseFrequency: []},
    {baseFrequency: [10]},
    {baseFrequency: [10, 3]},
    {baseFrequency: 30},
    {baseFrequency: false},
    {baseFrequency: true},
    {baseFrequency: '10'},

    {numOctaves: null},
    {numOctaves: []},
    {numOctaves: [10]},
    {numOctaves: 30},
    {numOctaves: false},
    {numOctaves: true},
    {numOctaves: '10'},

    {seed: null},
    {seed: []},
    {seed: [10]},
    {seed: 30},
    {seed: false},
    {seed: true},
    {seed: '10'},
    {seed: -1},

    {stitchTiles: 'stitch'},
    {stitchTiles: 'noStitch'},

    {type: 'fractalNoise'},
    {type: 'turbulence'},
  ]

  for (testCase of errorTestCases) {
    const filterOptions = {...{name: 'turbulence'}, ...testCase};
    assert_throws_js(TypeError, function() { new CanvasFilter(filterOptions); });
  }

  for (testCase of workingTestCases) {
    const filterOptions = {...{name: 'turbulence'}, ...testCase};
    _assert(new CanvasFilter(filterOptions) != null, "new CanvasFilter(filterOptions) != null");
  }
  t.done();

});
</script>