diff options
Diffstat (limited to 'testing/web-platform/tests/scroll-animations/css/view-timeline-shorthand.tentative.html')
-rw-r--r-- | testing/web-platform/tests/scroll-animations/css/view-timeline-shorthand.tentative.html | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/testing/web-platform/tests/scroll-animations/css/view-timeline-shorthand.tentative.html b/testing/web-platform/tests/scroll-animations/css/view-timeline-shorthand.tentative.html new file mode 100644 index 0000000000..f3efa88c92 --- /dev/null +++ b/testing/web-platform/tests/scroll-animations/css/view-timeline-shorthand.tentative.html @@ -0,0 +1,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> |