mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-09 21:00:42 +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
74 lines
3.5 KiB
HTML
74 lines
3.5 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-type-checking">
|
|
<link rel="author" title="Xiaocheng Hu" href="mailto:xiaochengh@chromium.org">
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="../support/numeric-testcommon.js"></script>
|
|
<div id="container" style="font-size: 20px; width: 400px">
|
|
<div id="target"></div>
|
|
</div>
|
|
<script>
|
|
|
|
// Identity tests
|
|
test_math_used('min(1px + 1%)', 'calc(1px + 1%)', {prop:'margin-left'});
|
|
test_math_used('min(1cm + 1%)', 'calc(1cm + 1%)');
|
|
test_math_used('min(1mm + 1%)', 'calc(1mm + 1%)');
|
|
test_math_used('min(1Q + 1%)', 'calc(1Q + 1%)');
|
|
test_math_used('min(1in + 1%)', 'calc(1in + 1%)');
|
|
test_math_used('min(1pc + 1%)', 'calc(1pc + 1%)');
|
|
test_math_used('min(1pt + 1%)', 'calc(1pt + 1%)');
|
|
test_math_used('min(1em + 1%)', 'calc(1em + 1%)');
|
|
test_math_used('min(1ex + 1%)', 'calc(1ex + 1%)');
|
|
test_math_used('min(1ch + 1%)', 'calc(1ch + 1%)');
|
|
test_math_used('min(1rem + 1%)', 'calc(1rem + 1%)');
|
|
test_math_used('min(1vh + 1%)', 'calc(1vh + 1%)');
|
|
test_math_used('min(1vw + 1%)', 'calc(1vw + 1%)');
|
|
test_math_used('min(1vmin + 1%)', 'calc(1vmin + 1%)');
|
|
test_math_used('min(1vmax + 1%)', 'calc(1vmax + 1%)');
|
|
test_math_used('max(1px + 1%)', 'calc(1px + 1%)');
|
|
test_math_used('max(1cm + 1%)', 'calc(1cm + 1%)');
|
|
test_math_used('max(1mm + 1%)', 'calc(1mm + 1%)');
|
|
test_math_used('max(1Q + 1%)', 'calc(1Q + 1%)');
|
|
test_math_used('max(1in + 1%)', 'calc(1in + 1%)');
|
|
test_math_used('max(1pc + 1%)', 'calc(1pc + 1%)');
|
|
test_math_used('max(1pt + 1%)', 'calc(1pt + 1%)');
|
|
test_math_used('max(1em + 1%)', 'calc(1em + 1%)');
|
|
test_math_used('max(1ex + 1%)', 'calc(1ex + 1%)');
|
|
test_math_used('max(1ch + 1%)', 'calc(1ch + 1%)');
|
|
test_math_used('max(1rem + 1%)', 'calc(1rem + 1%)');
|
|
test_math_used('max(1vh + 1%)', 'calc(1vh + 1%)');
|
|
test_math_used('max(1vw + 1%)', 'calc(1vw + 1%)');
|
|
test_math_used('max(1vmin + 1%)', 'calc(1vmin + 1%)');
|
|
test_math_used('max(1vmax + 1%)', 'calc(1vmax + 1%)');
|
|
|
|
// Comparisons between lengths and percentages
|
|
test_math_used('min(20px, 10%)', '20px');
|
|
test_math_used('min(1em, 10%)', '20px');
|
|
test_math_used('max(20px, 10%)', '40px');
|
|
test_math_used('max(1em, 10%)', '40px');
|
|
|
|
document.getElementById('container').style.width = '100px';
|
|
test_math_used('min(20px, 10%)', '10px', {msgExtra:'width=100px'});
|
|
test_math_used('min(1em, 10%)', '10px', {msgExtra:'width=100px'});
|
|
test_math_used('max(20px, 10%)', '20px', {msgExtra:'width=100px'});
|
|
test_math_used('max(1em, 10%)', '20px', {msgExtra:'width=100px'});
|
|
document.getElementById('container').style.width = '400px';
|
|
|
|
// Comparisons between different mixings
|
|
test_math_used('min(30px + 10%, 60px + 5%)', '70px');
|
|
test_math_used('max(2em + 10%, 1em + 20%)', '100px');
|
|
|
|
// General calculations
|
|
test_math_used('calc(min(1.5em, 10%) + 10px)', '40px');
|
|
test_math_used('calc(min(1.5em, 10%) - 10px)', '20px');
|
|
test_math_used('calc(min(1.5em, 10%) * 2)', '60px');
|
|
test_math_used('calc(min(1.5em, 10%) / 2)', '15px');
|
|
test_math_used('calc(max(1em, 15%) + 10px)', '70px');
|
|
test_math_used('calc(max(1em, 15%) - 10px)', '50px');
|
|
test_math_used('calc(max(1em, 15%) * 2)', '120px');
|
|
test_math_used('calc(max(1em, 15%) / 2)', '30px');
|
|
test_math_used('calc(min(1.5em, 10%) + max(1em, 15%))', '90px');
|
|
test_math_used('calc(min(1.5em, 10%) - max(1em, 15%))', '-30px');
|
|
</script>
|