gecko-dev/testing/web-platform/tests/css/css-values/minmax-length-computed.html
Tab Atkins Jr 028e60736f Bug 1620728 [wpt PR 22127] - Cleanup min max, a=testonly
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
2020-03-11 14:31:03 +00:00

114 lines
4.6 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/#lengths">
<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">
<div id="target"></div>
</div>
<script>
const property = 'letter-spacing';
function test_length_equals(value, expected, msgExtra) {
test_math_used(value, expected, {msgExtra});
}
// Identity tests
test_length_equals('min(1px)', '1px');
test_length_equals('min(1cm)', '1cm');
test_length_equals('min(1mm)', '1mm');
test_length_equals('min(1Q)', '1Q');
test_length_equals('min(1in)', '1in');
test_length_equals('min(1pc)', '1pc');
test_length_equals('min(1pt)', '1pt');
test_length_equals('min(1em)', '1em');
test_length_equals('min(1ex)', '1ex');
test_length_equals('min(1ch)', '1ch');
test_length_equals('min(1rem)', '1rem');
test_length_equals('min(1vh)', '1vh');
test_length_equals('min(1vw)', '1vw');
test_length_equals('min(1vmin)', '1vmin');
test_length_equals('min(1vmax)', '1vmax');
test_length_equals('max(1px)', '1px');
test_length_equals('max(1cm)', '1cm');
test_length_equals('max(1mm)', '1mm');
test_length_equals('max(1Q)', '1Q');
test_length_equals('max(1in)', '1in');
test_length_equals('max(1pc)', '1pc');
test_length_equals('max(1pt)', '1pt');
test_length_equals('max(1em)', '1em');
test_length_equals('max(1ex)', '1ex');
test_length_equals('max(1ch)', '1ch');
test_length_equals('max(1rem)', '1rem');
test_length_equals('max(1vh)', '1vh');
test_length_equals('max(1vw)', '1vw');
test_length_equals('max(1vmin)', '1vmin');
test_length_equals('max(1vmax)', '1vmax');
// Comparisons between same units
test_length_equals('min(1px, 2px)', '1px');
test_length_equals('min(1cm, 2cm)', '1cm');
test_length_equals('min(1mm, 2mm)', '1mm');
test_length_equals('min(1Q, 2Q)', '1Q');
test_length_equals('min(1in, 2in)', '1in');
test_length_equals('min(1pc, 2pc)', '1pc');
test_length_equals('min(1pt, 2pt)', '1pt');
test_length_equals('min(1em, 2em)', '1em');
test_length_equals('min(1ex, 2ex)', '1ex');
test_length_equals('min(1ch, 2ch)', '1ch');
test_length_equals('min(1rem, 2rem)', '1rem');
test_length_equals('min(1vh, 2vh)', '1vh');
test_length_equals('min(1vw, 2vw)', '1vw');
test_length_equals('min(1vmin, 2vmin)', '1vmin');
test_length_equals('min(1vmax, 2vmax)', '1vmax');
test_length_equals('max(1px, 2px)', '2px');
test_length_equals('max(1cm, 2cm)', '2cm');
test_length_equals('max(1mm, 2mm)', '2mm');
test_length_equals('max(1Q, 2Q)', '2Q');
test_length_equals('max(1in, 2in)', '2in');
test_length_equals('max(1pc, 2pc)', '2pc');
test_length_equals('max(1pt, 2pt)', '2pt');
test_length_equals('max(1em, 2em)', '2em');
test_length_equals('max(1ex, 2ex)', '2ex');
test_length_equals('max(1ch, 2ch)', '2ch');
test_length_equals('max(1rem, 2rem)', '2rem');
test_length_equals('max(1vh, 2vh)', '2vh');
test_length_equals('max(1vw, 2vw)', '2vw');
test_length_equals('max(1vmin, 2vmin)', '2vmin');
test_length_equals('max(1vmax, 2vmax)', '2vmax');
// Comparisons between different absolute units
test_length_equals('min(95px, 1in)', '95px');
test_length_equals('max(95px, 1in)', '1in');
// Comparisons between absolute and relative units
test_length_equals('min(15px, 1em)', '15px');
test_length_equals('min(25px, 1em)', '20px');
test_length_equals('max(15px, 1em)', '20px');
test_length_equals('max(25px, 1em)', '25px');
document.getElementById('container').style.fontSize = '10px';
test_length_equals('min(15px, 1em)', '10px', 'fontSize=10px');
test_length_equals('max(15px, 2em)', '20px', 'fontSize=10px');
document.getElementById('container').style.fontSize = '20px';
// Nestings
test_length_equals('min(25px, max(15px, 1em))', '20px');
test_length_equals('max(15px, min(25px, 1em))', '20px');
// General calculations
test_length_equals('calc(min(1em, 21px) + 10px)', '30px');
test_length_equals('calc(min(1em, 21px) - 10px)', '10px');
test_length_equals('calc(min(1em, 21px) * 2', '40px');
test_length_equals('calc(min(1em, 21px) / 2', '10px');
test_length_equals('calc(max(1em, 19px) + 10px)', '30px');
test_length_equals('calc(max(1em, 19px) - 10px)', '10px');
test_length_equals('calc(max(1em, 19px) * 2', '40px');
test_length_equals('calc(max(1em, 19px) / 2', '10px');
test_length_equals('calc(min(1em, 21px) + max(0.9em, 20px))', '40px');
test_length_equals('calc(min(1em, 21px) - max(0.9em, 20px))', '0px');
</script>