summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-backgrounds/animations/border-image-width-interpolation.html
blob: ea138201b15805cd86d8a63ed37b401b103bfee2 (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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<!DOCTYPE html>
<meta charset="UTF-8">
<title>border-image-width interpolation</title>
<link rel="help" href="https://drafts.csswg.org/css-backgrounds-3/#border-image-width">
<meta name="assert" content="border-image-width supports animation by computed value">

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/interpolation-testcommon.js"></script>

<style>
.parent {
  border-image-width: 100px;
}
.target {
  width: 80px;
  height: 80px;
  background-color: black;
  display: inline-block;
  border: 10px;
  border-image-source: linear-gradient(45deg, red, blue, green);
  border-image-width: 10px;
}
.expected {
  background-color: green;
  margin-right: 2px;
}
</style>

<body></body>

<script>
test_interpolation({
  property: 'border-image-width',
  from: neutralKeyframe,
  to: '20px',
}, [
  {at: -0.3, expect:   '7px'},
  {at: 0,    expect:  '10px'},
  {at: 0.3,  expect:  '13px'},
  {at: 0.6,  expect:  '16px'},
  {at: 1,    expect:  '20px'},
  {at: 1.5,  expect:  '25px'},
  {at: 5,    expect:  '60px'},
  {at: 10,   expect: '110px'},
]);
test_no_interpolation({
  property: 'border-image-width',
  from: 'initial',
  to: '20px',
});
test_interpolation({
  property: 'border-image-width',
  from: 'inherit',
  to: '20px',
}, [
  {at: -0.3, expect: '124px'},
  {at: 0,    expect: '100px'},
  {at: 0.3,  expect:  '76px'},
  {at: 0.6,  expect:  '52px'},
  {at: 1,    expect:  '20px'},
  {at: 1.5,  expect:   '0px'},
  {at: 5,    expect:   '0px'},
  {at: 10,   expect:   '0px'},
]);
test_no_interpolation({
  property: 'border-image-width',
  from: 'unset',
  to: '20px',
});
test_interpolation({
  property: 'border-image-width',
  from: '0px',
  to: '20px'
}, [
  {at: -0.3, expect:   '0px'}, // CSS border-image-width can't be negative.
  {at: 0,    expect:   '0px'},
  {at: 0.3,  expect:   '6px'},
  {at: 0.6,  expect:  '12px'},
  {at: 1,    expect:  '20px'},
  {at: 1.5,  expect:  '30px'},
  {at: 5,    expect: '100px'},
  {at: 10,   expect: '200px'}
]);
test_interpolation({
  property: 'border-image-width',
  from: '0%',
  to: '20%'
}, [
  {at: -0.3, expect:   '0%'}, // CSS border-image-width can't be negative.
  {at: 0,    expect:   '0%'},
  {at: 0.3,  expect:   '6%'},
  {at: 0.6,  expect:  '12%'},
  {at: 1,    expect:  '20%'},
  {at: 1.5,  expect:  '30%'},
  {at: 5,    expect: '100%'},
  {at: 10,   expect: '200%'}
]);
test_interpolation({
  property: 'border-image-width',
  from: '0',
  to: '20'
}, [
  {at: -0.3, expect:   '0'}, // CSS border-image-width can't be negative.
  {at: 0,    expect:   '0'},
  {at: 0.3,  expect:   '6'},
  {at: 0.6,  expect:  '12'},
  {at: 1,    expect:  '20'},
  {at: 1.5,  expect:  '30'},
  {at: 5,    expect: '100'},
  {at: 10,   expect: '200'}
]);
test_interpolation({
  property: 'border-image-width',
  from: '10px 20% 30 40px',
  to: '80px 70% 60 50px'
}, [
  {at: -0.3, expect:   '0px   5%  21  37px'}, // CSS border-image-width can't be negative.
  {at: 0,    expect:  '10px  20%  30  40px'},
  {at: 0.3,  expect:  '31px  35%  39  43px'},
  {at: 0.6,  expect:  '52px  50%  48  46px'},
  {at: 1,    expect:  '80px  70%  60  50px'},
  {at: 1.5,  expect: '115px  95%  75  55px'},
  {at: 5,    expect: '360px 270% 180  90px'},
  {at: 10,   expect: '710px 520% 330 140px'}
]);
test_interpolation({
  property: 'border-image-width',
  from: '10%',
  to: '20px'
}, [
  // Percentages are relative to the size of the border image area, which is 120px.
  {at: -0.3, expect: 'calc(13% + -6px)'}, // Should be parsed as 16px - 6px = 10px
  {at: 0,    expect: '10%'},              // Should be parsed as 12px
  {at: 0.3,  expect: 'calc(7% + 6px)'},   // Should be parsed as 8px + 6px = 14px
  {at: 0.6,  expect: 'calc(4% + 12px)'},  // Should be parsed as 5px + 12px = 17px
  {at: 1,    expect: 'calc(0% + 20px)'},
  {at: 1.5,  expect: 'calc(-5% + 30px)'}, // Should be parsed as -6px + 30px = 24px
]);
test_interpolation({
  property: 'border-image-width',
  from: '10px',
  to: '20%'
}, [
  // Percentages are relative to the size of the border image area, which is 120px.
  {at: -0.3, expect: 'calc(13px + -6%)'}, // Should be parsed as 13px - 7px = 6px
  {at: 0,    expect: 'calc(0% + 10px)'},
  {at: 0.3,  expect: 'calc(7px + 6%)'},   // Should be parsed as 7px + 7px = 14px
  {at: 0.6,  expect: 'calc(4px + 12%)'},  // Should be parsed as 4px + 14px = 18px
  {at: 1,    expect: '20%'},              // Should be parsed as 24px
  {at: 1.5,  expect: 'calc(-5px + 30%)'}, // Should be parsed as -5px + 36px = 31px
]);

test_interpolation({
  property: 'border-image-width',
  from: '10px auto auto 20',
  to: '110px auto auto 120'
}, [
  {at: -0.3, expect: '  0px auto auto   0'},
  {at: 0,    expect: ' 10px auto auto  20'},
  {at: 0.3,  expect: ' 40px auto auto  50'},
  {at: 0.6,  expect: ' 70px auto auto  80'},
  {at: 1,    expect: '110px auto auto 120'},
  {at: 1.5,  expect: '160px auto auto 170'},
]);

test_no_interpolation({
  property: 'border-image-width',
  from: '10px auto auto 20',
  to: '110px auto 120 auto'
});
test_no_interpolation({
  property: 'border-image-width',
  from: '10px',
  to: '20'
});
test_no_interpolation({
  property: 'border-image-width',
  from: '10',
  to: '20px'
});
test_no_interpolation({
  property: 'border-image-width',
  from: '10%',
  to: '20'
});
test_no_interpolation({
  property: 'border-image-width',
  from: '10',
  to: '20%'
});
</script>