summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/canvas/element/filters/2d.filter.layers.turbulence.inputTypes.html
blob: 26dceaae1659f2ae70f6c2718125cbed54690025 (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>Canvas test: 2d.filter.layers.turbulence.inputTypes</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/canvas/resources/canvas-tests.js"></script>
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
<body class="show_output">

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


<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>

<ul id="d"></ul>
<script>
var t = async_test("Test exceptions on CanvasFilter() turbulence object");
_addTest(function(canvas, ctx) {

  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() { ctx.beginLayer({filter: filterOptions}); });
  }

  for (testCase of workingTestCases) {
    const filterOptions = {...{name: 'turbulence'}, ...testCase};
    ctx.beginLayer({filter: filterOptions});
    ctx.endLayer();
  }

});
</script>