Bug 1575992 [wpt PR 18622] - Add parser and evaluation WPT <length-percentage> involving min/max(), a=testonly
☠☠ backed out by f0cc770df971 ☠ ☠
authorXiaocheng Hu <xiaochengh@chromium.org>
Tue, 27 Aug 2019 04:46:07 +0000
changeset 554098 8394d3fc54bcb83ba4426dad2e642343baeac0de
parent 554097 a73abcc509f778c81b482197de8a3a48a70f6fda
child 554099 a61cb494a0bf642833f039cfbd37f9c84e8e8b13
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1575992, 18622, 978682, 1766843, 690030
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1575992 [wpt PR 18622] - Add parser and evaluation WPT <length-percentage> involving min/max(), a=testonly Automatic update from web-platform-tests Add parser and evaluation WPT <length-percentage> involving min/max() Bug: 978682 Change-Id: I5e377df4121a1ef1992a30fbeff822712b52b8ca Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1766843 Reviewed-by: Rune Lillesveen <futhark@chromium.org> Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Cr-Commit-Position: refs/heads/master@{#690030} -- wpt-commits: 86af37591b7df11a1b667874a0d818684c4dfeb6 wpt-pr: 18622
testing/web-platform/tests/css/css-values/minmax-length-percent-computed.html
testing/web-platform/tests/css/css-values/minmax-length-percent-invalid.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-values/minmax-length-percent-computed.html
@@ -0,0 +1,84 @@
+<!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/computed-testcommon.js"></script>
+<div id="container" style="font-size: 20px; width: 400px">
+  <div id="target"></div>
+  <div id="reference"></div>
+</div>
+<script>
+const property = 'margin-left';
+
+function test_length_percent_equals(value, expected) {
+  const reference = document.getElementById('reference');
+  reference.style[property] = '';
+  reference.style[property] = expected;
+  const computed = getComputedStyle(reference)[property];
+  test_computed_value(property, value, computed);
+}
+
+// Identity tests
+test_length_percent_equals('min(1px + 1%)', 'calc(1px + 1%)');
+test_length_percent_equals('min(1cm + 1%)', 'calc(1cm + 1%)');
+test_length_percent_equals('min(1mm + 1%)', 'calc(1mm + 1%)');
+test_length_percent_equals('min(1Q + 1%)', 'calc(1Q + 1%)');
+test_length_percent_equals('min(1in + 1%)', 'calc(1in + 1%)');
+test_length_percent_equals('min(1pc + 1%)', 'calc(1pc + 1%)');
+test_length_percent_equals('min(1pt + 1%)', 'calc(1pt + 1%)');
+test_length_percent_equals('min(1em + 1%)', 'calc(1em + 1%)');
+test_length_percent_equals('min(1ex + 1%)', 'calc(1ex + 1%)');
+test_length_percent_equals('min(1ch + 1%)', 'calc(1ch + 1%)');
+test_length_percent_equals('min(1rem + 1%)', 'calc(1rem + 1%)');
+test_length_percent_equals('min(1vh + 1%)', 'calc(1vh + 1%)');
+test_length_percent_equals('min(1vw + 1%)', 'calc(1vw + 1%)');
+test_length_percent_equals('min(1vmin + 1%)', 'calc(1vmin + 1%)');
+test_length_percent_equals('min(1vmax + 1%)', 'calc(1vmax + 1%)');
+test_length_percent_equals('max(1px + 1%)', 'calc(1px + 1%)');
+test_length_percent_equals('max(1cm + 1%)', 'calc(1cm + 1%)');
+test_length_percent_equals('max(1mm + 1%)', 'calc(1mm + 1%)');
+test_length_percent_equals('max(1Q + 1%)', 'calc(1Q + 1%)');
+test_length_percent_equals('max(1in + 1%)', 'calc(1in + 1%)');
+test_length_percent_equals('max(1pc + 1%)', 'calc(1pc + 1%)');
+test_length_percent_equals('max(1pt + 1%)', 'calc(1pt + 1%)');
+test_length_percent_equals('max(1em + 1%)', 'calc(1em + 1%)');
+test_length_percent_equals('max(1ex + 1%)', 'calc(1ex + 1%)');
+test_length_percent_equals('max(1ch + 1%)', 'calc(1ch + 1%)');
+test_length_percent_equals('max(1rem + 1%)', 'calc(1rem + 1%)');
+test_length_percent_equals('max(1vh + 1%)', 'calc(1vh + 1%)');
+test_length_percent_equals('max(1vw + 1%)', 'calc(1vw + 1%)');
+test_length_percent_equals('max(1vmin + 1%)', 'calc(1vmin + 1%)');
+test_length_percent_equals('max(1vmax + 1%)', 'calc(1vmax + 1%)');
+
+// Comparisons between lengths and percentages
+test_length_percent_equals('min(20px, 10%)', '20px');
+test_length_percent_equals('min(1em, 10%)', '20px');
+test_length_percent_equals('max(20px, 10%)', '40px');
+test_length_percent_equals('max(1em, 10%)', '40px');
+
+document.getElementById('container').style.width = '100px';
+test_length_percent_equals('min(20px, 10%)', '10px');
+test_length_percent_equals('min(1em, 10%)', '10px');
+test_length_percent_equals('max(20px, 10%)', '20px');
+test_length_percent_equals('max(1em, 10%)', '20px');
+document.getElementById('container').style.width = '400px';
+
+// Comparisons between different mixings
+test_length_percent_equals('min(30px + 10%, 60px + 5%)', '70px');
+test_length_percent_equals('max(2em + 10%, 1em + 20%)', '100px');
+
+// General calculations
+test_length_percent_equals('calc(min(1.5em, 10%) + 10px)', '40px');
+test_length_percent_equals('calc(min(1.5em, 10%) - 10px)', '20px');
+test_length_percent_equals('calc(min(1.5em, 10%) * 2)', '60px');
+test_length_percent_equals('calc(min(1.5em, 10%) / 2)', '15px');
+test_length_percent_equals('calc(max(1em, 15%) + 10px)', '70px');
+test_length_percent_equals('calc(max(1em, 15%) - 10px)', '50px');
+test_length_percent_equals('calc(max(1em, 15%) * 2)', '120px');
+test_length_percent_equals('calc(max(1em, 15%) / 2)', '30px');
+test_length_percent_equals('calc(min(1.5em, 10%) + max(1em, 15%))', '90px');
+test_length_percent_equals('calc(min(1.5em, 10%) - max(1em, 15%))', '-30px');
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-values/minmax-length-percent-invalid.html
@@ -0,0 +1,36 @@
+<!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/parsing-testcommon.js"></script>
+<script>
+function test_invalid_length_percent(value) {
+  test_invalid_value('margin-left', value);
+}
+
+// Type checking only. Syntax checking is done by other test files.
+// <length-percentage> accepts mixing lengths and percentages only.
+test_invalid_length_percent('min(1px, 0)');
+test_invalid_length_percent('min(1px, 0s)');
+test_invalid_length_percent('min(1px, 0Hz)');
+test_invalid_length_percent('min(1px, 0dpi)');
+test_invalid_length_percent('min(1px, 0fr)');
+test_invalid_length_percent('min(1%, 0)');
+test_invalid_length_percent('min(1%, 0s)');
+test_invalid_length_percent('min(1%, 0Hz)');
+test_invalid_length_percent('min(1%, 0dpi)');
+test_invalid_length_percent('min(1%, 0fr)');
+test_invalid_length_percent('max(1px, 0)');
+test_invalid_length_percent('max(1px, 0s)');
+test_invalid_length_percent('max(1px, 0Hz)');
+test_invalid_length_percent('max(1px, 0dpi)');
+test_invalid_length_percent('max(1px, 0fr)');
+test_invalid_length_percent('max(1%, 0)');
+test_invalid_length_percent('max(1%, 0s)');
+test_invalid_length_percent('max(1%, 0Hz)');
+test_invalid_length_percent('max(1%, 0dpi)');
+test_invalid_length_percent('max(1%, 0fr)');
+</script>