Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/canvas/offscreen/filters/2d.filter.layers.dropShadow.exceptions.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<meta charset="UTF-8">
<title>OffscreenCanvas test: 2d.filter.layers.dropShadow.exceptions</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.layers.dropShadow.exceptions</h1>
<p class="desc">Test exceptions on CanvasFilter() dropShadow object</p>
<script>
var t = async_test("Test exceptions on CanvasFilter() dropShadow 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');
// Should not throw an error.
// dx
ctx.beginLayer({filter:
{name: 'dropShadow', dx: 10}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', dx: -1}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', dx: 0.5}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', dx: null}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', dx: true}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', dx: false}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', dx: []}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', dx: [20]}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', dx: '30'}}); ctx.endLayer();
// dy
ctx.beginLayer({filter:
{name: 'dropShadow', dy: 10}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', dy: -1}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', dy: 0.5}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', dy: null}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', dy: true}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', dy: false}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', dy: []}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', dy: [20]}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', dy: '30'}}); ctx.endLayer();
// floodOpacity
ctx.beginLayer({filter:
{name: 'dropShadow', floodOpacity: 10}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', floodOpacity: -1}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', floodOpacity: 0.5}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', floodOpacity: null}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', floodOpacity: true}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', floodOpacity: false}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', floodOpacity: []}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', floodOpacity: [20]}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', floodOpacity: '30'}}); ctx.endLayer();
// stdDeviation
ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: 10}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: -1}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: 0.5}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: null}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: true}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: false}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: []}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: [20]}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: '30'}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: [10, -1]}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: [0.5, null]}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: [true, false]}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: [[], [20]]}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: ['30', ['40']]}}); ctx.endLayer();
// floodColor
ctx.beginLayer({filter:
{name: 'dropShadow', floodColor: 'red'}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', floodColor: 'canvas'}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', floodColor: 'rgba(4, -3, 0.5, 1)'}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', floodColor: '#aabbccdd'}}); ctx.endLayer();
ctx.beginLayer({filter:
{name: 'dropShadow', floodColor: '#abcd'}}); ctx.endLayer();
// Should throw a TypeError.
// dx
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', dx: NaN}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', dx: Infinity}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', dx: -Infinity}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', dx: undefined}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', dx: 'test'}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', dx: {}}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', dx: [1, 2]}}); ctx.endLayer(); });
// dy
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', dy: NaN}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', dy: Infinity}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', dy: -Infinity}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', dy: undefined}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', dy: 'test'}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', dy: {}}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', dy: [1, 2]}}); ctx.endLayer(); });
// floodOpacity
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', floodOpacity: NaN}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', floodOpacity: Infinity}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', floodOpacity: -Infinity}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', floodOpacity: undefined}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', floodOpacity: 'test'}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', floodOpacity: {}}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', floodOpacity: [1, 2]}}); ctx.endLayer(); });
// stdDeviation
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: NaN}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: Infinity}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: -Infinity}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: undefined}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: 'test'}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: {}}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: [1, 2, 3]}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: [1, NaN]}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: [1, Infinity]}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: [1, -Infinity]}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: [1, undefined]}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: [1, 'test']}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: [1, {}]}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', stdDeviation: [1, [2, 3]]}}); ctx.endLayer(); });
// floodColor
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', floodColor: 'test'}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', floodColor: 'rgba(NaN, 3, 2, 1)'}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', floodColor: 10}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', floodColor: undefined}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', floodColor: null}}); ctx.endLayer(); });
assert_throws_js(TypeError, function() { ctx.beginLayer({filter:
{name: 'dropShadow', floodColor: NaN}}); ctx.endLayer(); });
t.done();
});
</script>