Tests: Import transition parsing tests

This commit is contained in:
Callum Law 2025-10-18 19:04:53 +13:00 committed by Sam Atkins
parent 0b45a68423
commit fd2f3b1f03
6 changed files with 172 additions and 0 deletions

View File

@ -0,0 +1,16 @@
Harness status: OK
Found 10 tests
6 Pass
4 Fail
Pass Default transition value
Pass Property transition value '1s'
Pass Property transition value 'cubic-bezier(0, -2, 1, 3)'
Pass Property transition value '1s -3s'
Fail Property transition value 'none'
Pass Property transition value 'top'
Pass Property transition value '1s -3s cubic-bezier(0, -2, 1, 3) top'
Fail Property transition value '1s -3s, cubic-bezier(0, -2, 1, 3) top'
Fail Property transition value 'all, all'
Fail Transition with a delay but no duration

View File

@ -0,0 +1,24 @@
Harness status: OK
Found 18 tests
16 Pass
2 Fail
Pass e.style['transition'] = "1s -3s cubic-bezier(0, -2, 1, 3) top" should set transition-behavior
Pass e.style['transition'] = "1s -3s cubic-bezier(0, -2, 1, 3) top" should set transition-delay
Pass e.style['transition'] = "1s -3s cubic-bezier(0, -2, 1, 3) top" should set transition-duration
Pass e.style['transition'] = "1s -3s cubic-bezier(0, -2, 1, 3) top" should set transition-property
Pass e.style['transition'] = "1s -3s cubic-bezier(0, -2, 1, 3) top" should set transition-timing-function
Pass e.style['transition'] = "1s -3s cubic-bezier(0, -2, 1, 3) top" should not set unrelated longhands
Fail e.style['transition'] = "1s -3s, cubic-bezier(0, -2, 1, 3) top" should set transition-behavior
Pass e.style['transition'] = "1s -3s, cubic-bezier(0, -2, 1, 3) top" should set transition-delay
Pass e.style['transition'] = "1s -3s, cubic-bezier(0, -2, 1, 3) top" should set transition-duration
Pass e.style['transition'] = "1s -3s, cubic-bezier(0, -2, 1, 3) top" should set transition-property
Pass e.style['transition'] = "1s -3s, cubic-bezier(0, -2, 1, 3) top" should set transition-timing-function
Pass e.style['transition'] = "1s -3s, cubic-bezier(0, -2, 1, 3) top" should not set unrelated longhands
Fail e.style['transition'] = "cubic-bezier(0, -2, 1, 3) top, 1s -3s" should set transition-behavior
Pass e.style['transition'] = "cubic-bezier(0, -2, 1, 3) top, 1s -3s" should set transition-delay
Pass e.style['transition'] = "cubic-bezier(0, -2, 1, 3) top, 1s -3s" should set transition-duration
Pass e.style['transition'] = "cubic-bezier(0, -2, 1, 3) top, 1s -3s" should set transition-property
Pass e.style['transition'] = "cubic-bezier(0, -2, 1, 3) top, 1s -3s" should set transition-timing-function
Pass e.style['transition'] = "cubic-bezier(0, -2, 1, 3) top, 1s -3s" should not set unrelated longhands

View File

@ -0,0 +1,16 @@
Harness status: OK
Found 10 tests
8 Pass
2 Fail
Pass e.style['transition'] = "1s" should set the property value
Pass e.style['transition'] = "cubic-bezier(0, -2, 1, 3)" should set the property value
Pass e.style['transition'] = "1s -3s" should set the property value
Fail e.style['transition'] = "none" should set the property value
Pass e.style['transition'] = "top" should set the property value
Pass e.style['transition'] = "1s -3s cubic-bezier(0, -2, 1, 3) top" should set the property value
Fail e.style['transition'] = "1s -3s, cubic-bezier(0, -2, 1, 3) top" should set the property value
Pass e.style['transition'] = "all" should set the property value
Pass e.style['transition'] = "all 1s" should set the property value
Pass e.style['transition'] = "initial" should set the property value

View File

@ -0,0 +1,43 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Transitions: getComputedStyle().transition</title>
<link rel="help" href="https://drafts.csswg.org/css-transitions/#transition-shorthand-property">
<meta name="assert" content="transition computed value is as specified.">
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../css/support/computed-testcommon.js"></script>
</head>
<body>
<div id="target"></div>
<script>
// <single-transition> = [ none | <single-transition-property> ] ||
// <time> || <easing-function> || <time>
test(() => {
assert_equals(getComputedStyle(document.getElementById('target')).transition, "all");
}, "Default transition value");
test_computed_value("transition", "1s");
test_computed_value("transition", "cubic-bezier(0, -2, 1, 3)");
test_computed_value("transition", "1s -3s");
test_computed_value("transition", "none");
test_computed_value("transition", "top");
test_computed_value("transition", "1s -3s cubic-bezier(0, -2, 1, 3) top", "top 1s cubic-bezier(0, -2, 1, 3) -3s");
test_computed_value("transition", "1s -3s, cubic-bezier(0, -2, 1, 3) top", "1s -3s, top cubic-bezier(0, -2, 1, 3)");
test_computed_value("transition", "all, all");
test(() => {
const target = document.getElementById('target');
target.style.transition = "initial";
target.style.transitionDelay = "1s";
assert_equals(getComputedStyle(target).transition, "0s 1s");
}, "Transition with a delay but no duration");
// TODO: Add test with a single timing-function keyword.
</script>
</body>
</html>

View File

@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Transitions: transition sets longhands</title>
<link rel="help" href="https://drafts.csswg.org/css-transitions/#transition-shorthand-property">
<meta name="assert" content="transition supports the full grammar '<single-transition> #'.">
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../css/support/shorthand-testcommon.js"></script>
</head>
<body>
<script>
test_shorthand_value('transition', '1s -3s cubic-bezier(0, -2, 1, 3) top', {
'transition-property': 'top',
'transition-duration': '1s',
'transition-timing-function': 'cubic-bezier(0, -2, 1, 3)',
'transition-delay': '-3s',
'transition-behavior': 'normal'
});
test_shorthand_value('transition', '1s -3s, cubic-bezier(0, -2, 1, 3) top', {
'transition-property': 'all, top',
'transition-duration': '1s, 0s',
'transition-timing-function': 'ease, cubic-bezier(0, -2, 1, 3)',
'transition-delay': '-3s, 0s',
'transition-behavior': 'normal, normal'
});
test_shorthand_value('transition', 'cubic-bezier(0, -2, 1, 3) top, 1s -3s', {
'transition-property': 'top, all',
'transition-duration': '0s, 1s',
'transition-timing-function': 'cubic-bezier(0, -2, 1, 3), ease',
'transition-delay': '0s, -3s',
'transition-behavior': 'normal, normal'
});
</script>
</body>
</html>

View File

@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Transitions: parsing transition with valid values</title>
<link rel="help" href="https://drafts.csswg.org/css-transitions/#transition-shorthand-property">
<meta name="assert" content="transition supports the full grammar '<single-transition> #'.">
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../css/support/parsing-testcommon.js"></script>
</head>
<body>
<script>
// <single-transition> = [ none | <single-transition-property> ] ||
// <time> || <easing-function> || <time>
test_valid_value("transition", "1s");
test_valid_value("transition", "cubic-bezier(0, -2, 1, 3)");
test_valid_value("transition", "1s -3s");
test_valid_value("transition", "none");
test_valid_value("transition", "top");
test_valid_value("transition", "1s -3s cubic-bezier(0, -2, 1, 3) top", "top 1s cubic-bezier(0, -2, 1, 3) -3s");
test_valid_value("transition", "1s -3s, cubic-bezier(0, -2, 1, 3) top", "1s -3s, top cubic-bezier(0, -2, 1, 3)");
test_valid_value("transition", "all");
test_valid_value("transition", "all 1s", "1s");
test_valid_value("transition", "initial", "initial");
// TODO: Add test with a single negative time.
// TODO: Add test with a single timing-function keyword.
</script>
</body>
</html>