summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/filter-effects/animation/filter-interpolation-003.html
blob: 1d512487de9693b2f8143a46e465cf672709b80b (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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>filter interpolation</title>
    <link rel="help" href="https://drafts.fxtf.org/filter-effects/#FilterProperty">
    <meta name="assert" content="lacuna matches spec.">
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
    <script src="/css/support/interpolation-testcommon.js"></script>
    <style>
      .target {
        display: inline-block;
        width: 50px;
        height: 50px;
        background-color: green;
        color: white;
        margin-right: 2px;
        filter: hue-rotate(10deg);
      }
      .expected {
        margin-right: 20px;
      }
      .test {
        padding-bottom: 10px;
      }
    </style>
  </head>
  <body>
    <script>
      'use strict';

      test_interpolation({
        property: 'filter',
        from: 'none', // lacuna is 0px
        to: 'blur(10px)'
      }, [
        {at: -1, expect: 'blur(0px)'}, // Negative values are not allowed.
        {at: 0, expect: 'blur(0px)'},
        {at: 0.5, expect: 'blur(5px)'},
        {at: 1, expect: 'blur(10px)'},
        {at: 1.5, expect: 'blur(15px)'}
      ]);

      test_interpolation({
        property: 'filter',
        from: 'brightness(0)',
        to: 'none' // lacuna is 1
      }, [
        {at: -1, expect: 'brightness(0)'}, // Negative values are not allowed.
        {at: 0, expect: 'brightness(0)'},
        {at: 0.5, expect: 'brightness(0.5)'},
        {at: 1, expect: 'brightness(1)'},
        {at: 1.5, expect: 'brightness(1.5)'}
      ]);

      test_interpolation({
        property: 'filter',
        from: 'contrast(0)',
        to: 'none' // lacuna is 1
      }, [
        {at: -1, expect: 'contrast(0)'}, // Negative values are not allowed.
        {at: 0, expect: 'contrast(0)'},
        {at: 0.5, expect: 'contrast(0.5)'},
        {at: 1, expect: 'contrast(1)'},
        {at: 1.5, expect: 'contrast(1.5)'}
      ]);

      test_interpolation({
        property: 'filter',
        from: 'none', // lacuna is drop-shadow(0px 0px 0px transparent)
        to: 'drop-shadow(20px 10px green)'
      }, [
        {at: -1, expect: 'drop-shadow(-20px -10px transparent)'},
        {at: 0, expect: 'drop-shadow(0px 0px 0px transparent)'},
        {at: 0.5, expect: 'drop-shadow(10px 5px rgba(0, 128, 0, 0.5))'},
        {at: 1, expect: 'drop-shadow(20px 10px green)'},
        {at: 1.5, expect: 'drop-shadow(30px 15px #00C000)'}
      ]);

      test_interpolation({
        property: 'filter',
        from: 'none', // lacuna is 0
        to: 'grayscale(1)'
      }, [
        {at: -1, expect: 'grayscale(0)'}, // Negative values are not allowed.
        {at: 0, expect: 'grayscale(0)'},
        {at: 0.5, expect: 'grayscale(0.5)'},
        {at: 1, expect: 'grayscale(1)'},
        {at: 1.5, expect: 'grayscale(1)'} // Should clamp values to 1.
      ]);

      test_interpolation({
        property: 'filter',
        from: 'none', // lacuna is 0deg
        to: 'hue-rotate(360deg)'
      }, [
        {at: -1, expect: 'hue-rotate(-360deg)'},
        {at: 0, expect: 'hue-rotate(0deg)'},
        {at: 0.5, expect: 'hue-rotate(180deg)'},
        {at: 1, expect: 'hue-rotate(360deg)'},
        {at: 1.5, expect: 'hue-rotate(540deg)'}
      ]);

      test_interpolation({
        property: 'filter',
        from: 'none', // lacuna is 0
        to: 'invert(1)'
      }, [
        {at: -1, expect: 'invert(0)'}, // Negative values are not allowed.
        {at: 0, expect: 'invert(0)'},
        {at: 0.5, expect: 'invert(0.5)'},
        {at: 1, expect: 'invert(1)'},
        {at: 1.5, expect: 'invert(1)'} // Should clamp values to 1.
      ]);

      test_interpolation({
        property: 'filter',
        from: 'opacity(0)',
        to: 'none' // lacuna is 1
      }, [
        {at: -1, expect: 'opacity(0)'}, // Negative values are not allowed.
        {at: 0, expect: 'opacity(0)'},
        {at: 0.5, expect: 'opacity(0.5)'},
        {at: 1, expect: 'opacity(1)'},
        {at: 1.5, expect: 'opacity(1)'} // Should clamp values to 1.
      ]);

      test_interpolation({
        property: 'filter',
        from: 'saturate(0)',
        to: 'none' // lacuna is 1
      }, [
        {at: -1, expect: 'saturate(0)'}, // Negative values are not allowed.
        {at: 0, expect: 'saturate(0)'},
        {at: 0.5, expect: 'saturate(0.5)'},
        {at: 1, expect: 'saturate(1)'},
        {at: 1.5, expect: 'saturate(1.5)'}
      ]);

      test_interpolation({
        property: 'filter',
        from: 'none', // lacuna is 0
        to: 'sepia(1)'
      }, [
        {at: -1, expect: 'sepia(0)'}, // Negative values are not allowed.
        {at: 0, expect: 'sepia(0)'},
        {at: 0.5, expect: 'sepia(0.5)'},
        {at: 1, expect: 'sepia(1)'},
        {at: 1.5, expect: 'sepia(1)'} // Should clamp values to 1.
      ]);

      test_no_interpolation({
        property: 'filter',
        from: 'url("#svgfilter")',
        to: 'none', // lacuna is not defined
      });

      test_no_interpolation({
        property: 'filter',
        from: 'url("#svgfilter")',
        to: 'blur(5px)',
      });

      test_interpolation({
        property: 'filter',
        from: 'initial', // lacuna is 0
        to: 'sepia(1)'
      }, [
        {at: -1, expect: 'sepia(0)'}, // Negative values are not allowed.
        {at: 0, expect: 'sepia(0)'}, // Equivalent to sepia(0)
        {at: 0.5, expect: 'sepia(0.5)'},
        {at: 1, expect: 'sepia(1)'},
        {at: 1.5, expect: 'sepia(1)'} // Should clamp values to 1.
      ]);
    </script>
  </body>
</html>