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
|
<!DOCTYPE html>
<link rel="help" href="https://drafts.csswg.org/scroll-animations-1/#view-timeline-shorthand">
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7627">
<link rel="help" href="https://github.com/w3c/csswg-drafts/pull/7694">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/computed-testcommon.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
<script src="/css/support/shorthand-testcommon.js"></script>
<div id="target"></div>
<script>
test_valid_value('view-timeline', 'abcd');
test_valid_value('view-timeline', 'none block', 'none');
test_valid_value('view-timeline', 'none inline');
// view-timeline-name: inline/block/horizontal/vertical.
test_valid_value('view-timeline', 'inline block', 'inline');
test_valid_value('view-timeline', 'block block', 'block');
test_valid_value('view-timeline', 'vertical block', 'vertical');
test_valid_value('view-timeline', 'horizontal block', 'horizontal');
test_valid_value('view-timeline', 'a, b, c');
test_valid_value('view-timeline', 'a inline, b block, c vertical', 'a inline, b, c vertical');
test_valid_value('view-timeline', 'auto');
test_invalid_value('view-timeline', 'abc abc');
test_invalid_value('view-timeline', 'block none');
test_invalid_value('view-timeline', 'none none');
test_invalid_value('view-timeline', 'default');
test_invalid_value('view-timeline', ',');
test_invalid_value('view-timeline', ',,block,,');
test_computed_value('view-timeline', 'abcd');
test_computed_value('view-timeline', 'none block', 'none');
test_computed_value('view-timeline', 'none inline');
test_computed_value('view-timeline', 'inline block', 'inline');
test_computed_value('view-timeline', 'block block', 'block');
test_computed_value('view-timeline', 'vertical block', 'vertical');
test_computed_value('view-timeline', 'horizontal block', 'horizontal');
test_computed_value('view-timeline', 'a, b, c');
test_computed_value('view-timeline', 'a inline, b block, c vertical', 'a inline, b, c vertical');
test_shorthand_value('view-timeline', 'abc vertical',
{
'view-timeline-name': 'abc',
'view-timeline-axis': 'vertical',
});
test_shorthand_value('view-timeline', 'abc vertical, def',
{
'view-timeline-name': 'abc, def',
'view-timeline-axis': 'vertical, block',
});
test_shorthand_value('view-timeline', 'abc, def',
{
'view-timeline-name': 'abc, def',
'view-timeline-axis': 'block, block',
});
test_shorthand_value('view-timeline', 'inline horizontal',
{
'view-timeline-name': 'inline',
'view-timeline-axis': 'horizontal',
});
function test_shorthand_contraction(shorthand, longhands, expected) {
let longhands_fmt = Object.entries(longhands).map((e) => `${e[0]}:${e[1]}`).join(';');
test((t) => {
t.add_cleanup(() => {
for (let shorthand of Object.keys(longhands))
target.style.removeProperty(shorthand);
});
for (let [shorthand, value] of Object.entries(longhands))
target.style.setProperty(shorthand, value);
assert_equals(target.style.getPropertyValue(shorthand), expected, 'Declared value');
assert_equals(getComputedStyle(target).getPropertyValue(shorthand), expected, 'Computed value');
}, `Shorthand contraction of ${longhands_fmt}`);
}
test_shorthand_contraction('view-timeline', {
'view-timeline-name': 'abc',
'view-timeline-axis': 'inline',
}, 'abc inline');
test_shorthand_contraction('view-timeline', {
'view-timeline-name': 'a, b',
'view-timeline-axis': 'inline, block',
}, 'a inline, b');
test_shorthand_contraction('view-timeline', {
'view-timeline-name': 'none, none',
'view-timeline-axis': 'block, block',
}, 'none, none');
// Longhands with different lengths:
test_shorthand_contraction('view-timeline', {
'view-timeline-name': 'a, b, c',
'view-timeline-axis': 'inline, inline',
}, '');
test_shorthand_contraction('view-timeline', {
'view-timeline-name': 'a, b',
'view-timeline-axis': 'inline, inline, inline',
}, '');
</script>
|