mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-09 12:51:09 +02:00
Automatic update from web-platform-tests Cleanup min max (#22127) * Use animation-play-state:paused rather than enormous durations. Add a red square to make failure obvious. * Add a red square for obvious failure. * Add a red square for obvious failure. * Don't depend on the serialization of computed units being a particular thing. * Math functions are aggressively reduced away if possible. * Simplify with test_math_used(). * Add the ability, which other test functions have, to tack on an extra message to the built-in message. * Simplify with test_math_used(). * Use 'margin-left' instead of 'left', since the latter's resolved value is the computed value if the element isn't positioned! * Simplify with test_math_used(). * Restructure test_math_used() to accept a type specifier, and automatically choose a good property/base value/etc for that type. Also add test_math_computed, with different props where appropriate. * Switch the inf/zero/nan functions over to just using the 'number' type so they're more obvious. * Improve the documentation for numeric-testcommon.js. * Make minmax-length-percent-serialize match the spec for serialization of computed values. * Make minmax-length-serialize match the spec for serialization of computed values. * Switch minmax-number-computed over to test_math_used(). * Fix errors in test_math_computed(), and add test_math_specified(). * Extract the base-selecting code, since it's shared by all the functions. * Fix minmax-number-serialize to match spec for serialization. * Fix minmax-percentage-computed to not rely on serialization. * Well, the generic functions dont' let me test exact serialization, so start writing some that do. * Add new serializ-testcommon helper, and rewrite all the serialization tests to use it. * Remove the 'base' value from numeric-testcommon, as empty string works consistently across everything. * [css-values] Final fixes/conversion of min()/max() tests to the newer templates and spec. -- wpt-commits: 53876e32d827db82f4b7af38053529302c243d40 wpt-pr: 22127
119 lines
3.2 KiB
HTML
119 lines
3.2 KiB
HTML
<!DOCTYPE html>
|
|
<link rel="help" href="https://drafts.csswg.org/css-values-4/#comp-func">
|
|
<link rel="help" href="https://drafts.csswg.org/css-values-4/#mixed-percentages">
|
|
<link rel="help" href="https://drafts.csswg.org/css-values-4/#calc-serialize">
|
|
<link rel="author" title="Xiaocheng Hu" href="mailto:xiaochengh@chromium.org">
|
|
<link rel="author" title="Tab Atkins-Bittner" href="https://xanthir.com/contact">
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="../support/serialize-testcommon.js"></script>
|
|
<div style="width: 100px;">
|
|
<div id=target></div>
|
|
</div>
|
|
<script>
|
|
function test_serialization(t,s,c,u, {prop}={}) {
|
|
test_specified_serialization(prop || 'text-indent', t, s);
|
|
test_computed_serialization(prop || 'text-indent', t, c);
|
|
if(u) test_used_serialization(prop || 'margin-left', t, u);
|
|
}
|
|
|
|
// If fully resolvable to a number, serialize to a calc() or all the way to a number.
|
|
test_serialization(
|
|
'min(1px)',
|
|
'calc(1px)',
|
|
'1px',
|
|
'1px');
|
|
test_serialization(
|
|
'max(1px)',
|
|
'calc(1px)',
|
|
'1px',
|
|
'1px');
|
|
|
|
// If not, keep as the function.
|
|
test_serialization(
|
|
'min(1% + 1px)',
|
|
'min(1% + 1px)',
|
|
'min(1% + 1px)',
|
|
'2px');
|
|
test_serialization(
|
|
'min(1px + 1%)',
|
|
'min(1% + 1px)',
|
|
'min(1% + 1px)',
|
|
'2px');
|
|
test_serialization(
|
|
'max(1px + 1%)',
|
|
'max(1% + 1px)',
|
|
'max(1% + 1px)',
|
|
'2px');
|
|
|
|
// Arguments are simplified, but not reordered.
|
|
test_serialization(
|
|
'min(20px, 10%)',
|
|
'min(20px, 10%)',
|
|
'min(20px, 10%)',
|
|
'10px');
|
|
test_serialization(
|
|
'min(1em, 10%)',
|
|
'min(1em, 10%)',
|
|
'min(16px, 10%)',
|
|
'10px');
|
|
test_serialization(
|
|
'min(10%, 20px)',
|
|
'min(10%, 20px)',
|
|
'min(10%, 20px)',
|
|
'10px');
|
|
test_serialization(
|
|
'min(10%, 1em)',
|
|
'min(10%, 1em)',
|
|
'min(10%, 16px)',
|
|
'10px');
|
|
test_serialization(
|
|
'max(20px, 10%)',
|
|
'max(20px, 10%)',
|
|
'max(20px, 10%)',
|
|
'20px');
|
|
test_serialization(
|
|
'max(1em, 10%)',
|
|
'max(1em, 10%)',
|
|
'max(16px, 10%)',
|
|
'16px');
|
|
test_serialization(
|
|
'max(10%, 20px)',
|
|
'max(10%, 20px)',
|
|
'max(10%, 20px)',
|
|
'20px');
|
|
test_serialization(
|
|
'max(10%, 1em)',
|
|
'max(10%, 1em)',
|
|
'max(10%, 16px)',
|
|
'16px');
|
|
|
|
// Within an argument, normal sorting occurs
|
|
test_serialization(
|
|
'min(10% + 30px, 5em + 5%)',
|
|
'min(10% + 30px, 5% + 5em)',
|
|
'min(10% + 30px, 5% + 80px)',
|
|
'40px');
|
|
test_serialization(
|
|
'max(10% + 30px, 5em + 5%)',
|
|
'max(10% + 30px, 5% + 5em)',
|
|
'max(10% + 30px, 5% + 80px)',
|
|
'85px');
|
|
|
|
// min()/max() are valid inside a calc(),
|
|
// and retain their relative order
|
|
test_serialization(
|
|
'calc(min(10% + 1px) + max(1em + 10%) + min(10% + 20px))',
|
|
'calc(min(10% + 1px) + max(10% + 1em) + min(10% + 20px))',
|
|
'calc(min(10% + 1px) + max(10% + 16px) + min(10% + 20px))',
|
|
'67px');
|
|
|
|
// min()/max() can be combined with plain units as well.
|
|
// While min()/max() maintain their own ordering,
|
|
// ordinary units will re-sort around them.
|
|
test_serialization(
|
|
'calc(1em + max(10% + 20px) + 5% + min(1em + 10%) + 10px)',
|
|
'calc(5% + 1em + 10px + max(10% + 20px) + min(10% + 1em))',
|
|
'calc(5% + 26px + max(10% + 20px) + min(10% + 16px))',
|
|
'87px');
|
|
</script>
|