summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.dropShadow.tentative.w.html
blob: fe9087244a08f47fbdca8bfd9b844abe56bb984a (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
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<html class="reftest-wait">
<link rel="match" href="2d.filter.canvasFilterObject.dropShadow.tentative-expected.html">
<title>Canvas test: 2d.filter.canvasFilterObject.dropShadow.tentative</title>
<h1>2d.filter.canvasFilterObject.dropShadow.tentative</h1>
<p class="desc">Test CanvasFilter() dropShadow object.</p>
<canvas id="canvas" width="520" height="420">
  <p class="fallback">FAIL (fallback content)</p>
</canvas>
<script id='myWorker' type='text/worker'>
  self.onmessage = function(e) {
    const canvas = new OffscreenCanvas(520, 420);
    const ctx = canvas.getContext('2d');

    ctx.fillStyle = 'teal';
    ctx.fillRect(0, 0, 520, 50);
    ctx.fillRect(0, 100, 520, 50);
    ctx.fillRect(0, 200, 520, 50);
    ctx.fillRect(0, 300, 520, 50);

    ctx.fillStyle = 'crimson';

    // Parameter defaults.
    ctx.filter = new CanvasFilter({name: 'dropShadow'});
    ctx.fillRect(10, 10, 80, 80);

    // All parameters specified.
    ctx.filter = new CanvasFilter(
      {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 5,
       floodColor: 'purple', floodOpacity: 0.7});
    ctx.fillRect(110, 10, 80, 80);

    // Named color.
    ctx.filter = new CanvasFilter(
      {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 3,
       floodColor: 'purple'});
    ctx.fillRect(10, 110, 80, 80);

    // System color.
    ctx.filter = new CanvasFilter(
      {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 3,
       floodColor: 'LinkText'});
    ctx.fillRect(110, 110, 80, 80);

    // Numerical color.
    ctx.filter = new CanvasFilter(
      {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 3,
       floodColor: 'rgba(20, 50, 130, 1)'});
    ctx.fillRect(210, 110, 80, 80);

    // Transparent floodColor.
    ctx.filter = new CanvasFilter(
      {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 3,
       floodColor: 'rgba(20, 50, 130, 0.7)'});
    ctx.fillRect(310, 110, 80, 80);

    // Transparent floodColor and floodOpacity.
    ctx.filter = new CanvasFilter(
      {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 3,
       floodColor: 'rgba(20, 50, 130, 0.7)', floodOpacity: 0.7});
    ctx.fillRect(410, 110, 80, 80);

    // No blur.
    ctx.filter = new CanvasFilter(
      {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 0,
       floodColor: 'purple'});
    ctx.fillRect(10, 210, 80, 80);

    // Single float blur.
    ctx.filter = new CanvasFilter(
      {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 5,
       floodColor: 'purple'});
    ctx.fillRect(110, 210, 80, 80);

    // Single negative float blur.
    ctx.filter = new CanvasFilter(
      {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: -5,
       floodColor: 'purple'});
    ctx.fillRect(210, 210, 80, 80);

    // Two floats (X&Y) blur.
    ctx.filter = new CanvasFilter(
      {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: [3, 5],
       floodColor: 'purple'});
    ctx.fillRect(310, 210, 80, 80);

    // Two negative floats (X&Y) blur.
    ctx.filter = new CanvasFilter(
      {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: [-3, -5],
       floodColor: 'purple'});
    ctx.fillRect(410, 210, 80, 80);

    // Degenerate parameter values.
    ctx.filter = new CanvasFilter(
      {name: 'dropShadow', dx: [-5], dy: [], stdDeviation: null,
       floodColor: 'purple', floodOpacity: [2]});
    ctx.fillRect(10, 310, 80, 80);

    ctx.filter = new CanvasFilter(
      {name: 'dropShadow', dx: null, dy: '5', stdDeviation: [[-5], ['3']],
       floodColor: 'purple', floodOpacity: '0.8'});
    ctx.fillRect(110, 310, 80, 80);

    ctx.filter = new CanvasFilter(
      {name: 'dropShadow', dx: true, dy: ['10'], stdDeviation: false,
       floodColor: 'purple', floodOpacity: ['0.4']});
    ctx.fillRect(210, 310, 80, 80);

    const bitmap = canvas.transferToImageBitmap();
    self.postMessage(bitmap, bitmap);
  };
</script>
<script>
  const blob = new Blob([document.getElementById('myWorker').textContent]);
  const worker = new Worker(URL.createObjectURL(blob));
  worker.addEventListener('message', msg => {
    const outputCtx = document.getElementById("canvas").getContext('2d');
    outputCtx.drawImage(msg.data, 0, 0);
    document.documentElement.classList.remove("reftest-wait");
  });
  worker.postMessage(null);
</script>
</html>