chromium/third_party/blink/web_tests/external/wpt/css/css-values/minmax-percentage-serialize.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/#percentages">
<link rel="help" href="https://drafts.csswg.org/css-values-4/#calc-serialize">
<link rel="author" title="Xiaocheng Hu" href="mailto:[email protected]">
<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);
}

test_serialization(
    'min(1%)',
    'calc(1%)',
    '1%',
    '1px');
test_serialization(
    'max(1%)',
    'calc(1%)',
    '1%',
    '1px');


// %s can't be simplified until we resolve them,
// since in some cases they can resolve against a negative value
// (so that 20% is less than 10%),
// and we don't want to try and distinguish between the properties
// where the resolving value is possibly-negative or always non-negative.
test_serialization(
    'min(1%, 2%, 3%)',
    'min(1%, 2%, 3%)',
    'min(1%, 2%, 3%)',
    '1px');
test_serialization(
    'min(3%, 2%, 1%)',
    'min(3%, 2%, 1%)',
    'min(3%, 2%, 1%)',
    '1px');
test_serialization(
    'min(-1%, 1%)',
    'min(-1%, 1%)',
    'min(-1%, 1%)',
    '-1px');
// -0% simplifies and serializes to 0%
// See https://github.com/w3c/csswg-drafts/issues/9750
test_serialization(
    'min(-0%, 0%)',
    'min(0%, 0%)',
    'min(0%, 0%)',
    '0px');
test_serialization(
    'max(1%, 2%, 3%)',
    'max(1%, 2%, 3%)',
    'max(1%, 2%, 3%)',
    '3px');
test_serialization(
    'max(3%, 2%, 1%)',
    'max(3%, 2%, 1%)',
    'max(3%, 2%, 1%)',
    '3px');
test_serialization(
    'max(-1%, 1%)',
    'max(-1%, 1%)',
    'max(-1%, 1%)',
    '1px');
test_serialization(
    'max(-0%, 0%)',
    'max(0%, 0%)',
    'max(0%, 0%)',
    '0px');

// Also ensure that this works against a possibly-negative resolving value...
test_serialization(
    'min(1%, 2%, 3%) 0px',
    'min(1%, 2%, 3%) 0px',
    'min(1%, 2%, 3%) 0px',
    '',
    {prop:'background-position'});

test_serialization(
    'calc(min(1%, 2%) + max(3%, 4%) + 10%)',
    'calc(10% + min(1%, 2%) + max(3%, 4%))',
    'calc(10% + min(1%, 2%) + max(3%, 4%))',
    '15px');

</script>