Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!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.canvasFilterObject.dropShadow.exceptions.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.dropShadow.exceptions.tentative</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.filter = new CanvasFilter(
{name: 'dropShadow', dx: 10});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', dx: -1});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', dx: 0.5});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', dx: null});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', dx: true});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', dx: false});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', dx: []});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', dx: [20]});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', dx: '30'});
// dy
ctx.filter = new CanvasFilter(
{name: 'dropShadow', dy: 10});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', dy: -1});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', dy: 0.5});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', dy: null});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', dy: true});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', dy: false});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', dy: []});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', dy: [20]});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', dy: '30'});
// floodOpacity
ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodOpacity: 10});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodOpacity: -1});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodOpacity: 0.5});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodOpacity: null});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodOpacity: true});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodOpacity: false});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodOpacity: []});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodOpacity: [20]});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodOpacity: '30'});
// stdDeviation
ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: 10});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: -1});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: 0.5});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: null});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: true});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: false});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: []});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: [20]});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: '30'});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: [10, -1]});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: [0.5, null]});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: [true, false]});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: [[], [20]]});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: ['30', ['40']]});
// floodColor
ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodColor: 'red'});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodColor: 'canvas'});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodColor: 'rgba(4, -3, 0.5, 1)'});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodColor: '#aabbccdd'});
ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodColor: '#abcd'});
// Should throw a TypeError.
// dx
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', dx: NaN}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', dx: Infinity}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', dx: -Infinity}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', dx: undefined}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', dx: 'test'}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', dx: {}}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', dx: [1, 2]}); });
// dy
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', dy: NaN}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', dy: Infinity}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', dy: -Infinity}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', dy: undefined}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', dy: 'test'}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', dy: {}}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', dy: [1, 2]}); });
// floodOpacity
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodOpacity: NaN}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodOpacity: Infinity}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodOpacity: -Infinity}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodOpacity: undefined}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodOpacity: 'test'}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodOpacity: {}}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodOpacity: [1, 2]}); });
// stdDeviation
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: NaN}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: Infinity}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: -Infinity}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: undefined}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: 'test'}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: {}}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: [1, 2, 3]}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: [1, NaN]}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: [1, Infinity]}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: [1, -Infinity]}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: [1, undefined]}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: [1, 'test']}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: [1, {}]}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', stdDeviation: [1, [2, 3]]}); });
// floodColor
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodColor: 'test'}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodColor: 'rgba(NaN, 3, 2, 1)'}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodColor: 10}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodColor: undefined}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodColor: null}); });
assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter(
{name: 'dropShadow', floodColor: NaN}); });
t.done();
});
</script>