chromium/third_party/blink/web_tests/css3/calc/number-parsing.html

<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
function assertParsedValue(property, input, expected) {
  var style = document.createElement('div').style;
  style.setProperty(property, input);
  assert_equals(style.getPropertyValue(property), expected, property + ': ' + input);
}

test(function() {
  assertParsedValue('-webkit-box-ordinal-group', 'calc(6 + 4)', 'calc(10)');
}, 'Ensure using calc() for CSS numbers with + on -webkit-box-ordinal-group does not crash or produce incorrect values.');
test(function() {
  assertParsedValue('-webkit-box-ordinal-group', 'calc(0)', 'calc(0)');
}, 'Ensure using calc() for CSS number 0 on -webkit-box-ordinal-group does not crash or produce incorrect values.');
test(function() {
  assertParsedValue('-webkit-column-span', 'calc(2 - 1)', '');
}, 'Ensure using calc() for CSS numbers with - on -webkit-column-span does not crash or produce incorrect values.');
test(function() {
  assertParsedValue('-webkit-column-span', 'calc(1 + 2)', '');
}, 'Ensure using calc() for CSS numbers with + on -webkit-column-span does not crash or produce incorrect values.');
test(function() {
  assertParsedValue('-webkit-column-width', 'calc(1em - 1px)', 'calc(1em - 1px)');
}, 'Ensure using calc() for CSS lengths with - on -webkit-column-width does not crash or produce incorrect values.');
test(function() {
  assertParsedValue('transition-timing-function', 'cubic-bezier(calc(1 + 2), 0, 1, 1)', '');
}, 'Ensure using calc() for CSS numbers with + on transition-timing-function does not crash or produce incorrect values.');
test(function() {
  assertParsedValue('transition-timing-function', 'cubic-bezier(calc(1 / 2), calc(1 - 1), calc(2 - 1), calc(2 * 3))', 'cubic-bezier(0.5, 0, 1, 6)');
}, 'Ensure using calc() for CSS numbers with / on transition-timing-function does not crash or produce incorrect values.');
test(function() {
  assertParsedValue('transition-timing-function', 'steps(calc(1 + 2), start)', 'steps(3, start)');
}, 'Ensure using calc() for CSS numbers with + on transition-timing-function does not crash or produce incorrect values.');
test(function() {
  assertParsedValue('grid-row-start', 'calc(1 + 2) test', '3 test');
}, 'Ensure using calc() for CSS numbers with + on grid-row-start does not crash or produce incorrect values.');
test(function() {
  assertParsedValue('grid-row-start', 'calc(1 / 2) test', '1 test');
}, 'Ensure using calc() for CSS numbers with / on grid-row-start does not crash or produce incorrect values.');
test(function() {
  assertParsedValue('font-weight', 'calc(100 + 200)', 'calc(300)');
}, 'Ensure using calc() for CSS numbers with + on font-weight does not crash or produce incorrect values.');
test(function() {
  assertParsedValue('flex', 'calc(1 + 2) calc(3 + 4)', '3 7 0%');
}, 'Ensure using calc() for CSS numbers with + on flex does not crash or produce incorrect values.');
test(function() {
  assertParsedValue('-webkit-filter', 'saturate(calc(4 / 2))', 'saturate(calc(2))');
}, 'Ensure using calc() for CSS numbers with / on saturate() does not crash or produce incorrect values.');
test(function() {
  assertParsedValue('-webkit-filter', 'invert(calc(4 / 2))', 'invert(calc(1))');
}, 'Ensure using calc() for CSS numbers with / on invert() resulting bigger than 1 does not crash or produce incorrect values.');
test(function() {
  assertParsedValue('-webkit-filter', 'invert(calc(2 / 4))', 'invert(calc(0.5))');
}, 'Ensure using calc() for CSS numbers with / on invert() resulting smaller than 1 does not crash or produce incorrect values.');
test(function() {
  assertParsedValue('-webkit-filter', 'brightness(calc(4 / 2))', 'brightness(calc(2))');
}, 'Ensure using calc() for CSS numbers with / on brightness() does not crash or produce incorrect values.');
</script>