Bug 1774589 - Fix a couple css-values tests while at it. r=boris
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 18 Aug 2022 08:49:31 +0000
changeset 627591 fc449cf7d4767518722cc99892a710256d013e4c
parent 627590 02eccb00040425f26618ac7c766a2e9d02a64d63
child 627592 a71f1814b2d7fbebc1964e69b8f2e694f6324927
push id40144
push usernfay@mozilla.com
push dateThu, 18 Aug 2022 15:45:20 +0000
treeherdermozilla-central@6e2c5eb109ce [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersboris
bugs1774589
milestone105.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 1774589 - Fix a couple css-values tests while at it. r=boris While I was looking at this, let's fix some incorrect tests. The changes to expect simplification come from https://drafts.csswg.org/css-values-4/#calc-simplification: Internal representations of math functions are eagerly simplified to the extent possible, using standard algebraic simplifications (distributing multiplication over sums, combining similar units, etc.) The changes to tests that expected 0% / 0px / etc are just wrong because the test harness treat 0 as the "default" used value, and fails. These fail in all browsers. Depends on D154831 Differential Revision: https://phabricator.services.mozilla.com/D154832
testing/web-platform/meta/css/css-values/clamp-length-serialize.html.ini
testing/web-platform/meta/css/css-values/minmax-length-computed.html.ini
testing/web-platform/meta/css/css-values/minmax-length-percent-serialize.html.ini
testing/web-platform/meta/css/css-values/minmax-percentage-computed.html.ini
testing/web-platform/meta/css/css-values/minmax-time-computed.html.ini
testing/web-platform/tests/css/css-values/clamp-length-serialize.html
testing/web-platform/tests/css/css-values/minmax-length-computed.html
testing/web-platform/tests/css/css-values/minmax-length-percent-serialize.html
testing/web-platform/tests/css/css-values/minmax-percentage-computed.html
testing/web-platform/tests/css/css-values/minmax-time-computed.html
deleted file mode 100644
--- a/testing/web-platform/meta/css/css-values/clamp-length-serialize.html.ini
+++ /dev/null
@@ -1,7 +0,0 @@
-[clamp-length-serialize.html]
-  [e.style['letter-spacing'\] = "clamp(1px, 2px, clamp(2px, 3px, 4px))" should set the property value]
-    expected: FAIL
-
-  [e.style['letter-spacing'\] = "clamp(1px, 2px, 3px)" should set the property value]
-    expected: FAIL
-
deleted file mode 100644
--- a/testing/web-platform/meta/css/css-values/minmax-length-computed.html.ini
+++ /dev/null
@@ -1,3 +0,0 @@
-[minmax-length-computed.html]
-  [calc(min(1em, 21px) - max(0.9em, 20px)) should be used-value-equivalent to 0px]
-    expected: FAIL
deleted file mode 100644
--- a/testing/web-platform/meta/css/css-values/minmax-length-percent-serialize.html.ini
+++ /dev/null
@@ -1,31 +0,0 @@
-[minmax-length-percent-serialize.html]
-  ['min(1% + 1px)' as a computed value should serialize as 'min(1% + 1px)'.]
-    expected: FAIL
-
-  ['calc(min(10% + 1px) + max(1em + 10%) + min(10% + 20px))' as a computed value should serialize as 'calc(min(10% + 1px) + max(10% + 16px) + min(10% + 20px))'.]
-    expected: FAIL
-
-  ['max(1px + 1%)' as a specified value should serialize as 'max(1% + 1px)'.]
-    expected: FAIL
-
-  ['calc(1em + max(10% + 20px) + 5% + min(1em + 10%) + 10px)' as a computed value should serialize as 'calc(5% + 26px + max(10% + 20px) + min(10% + 16px))'.]
-    expected: FAIL
-
-  ['max(1px + 1%)' as a computed value should serialize as 'max(1% + 1px)'.]
-    expected: FAIL
-
-  ['min(1% + 1px)' as a specified value should serialize as 'min(1% + 1px)'.]
-    expected: FAIL
-
-  ['calc(min(10% + 1px) + max(1em + 10%) + min(10% + 20px))' as a specified value should serialize as 'calc(min(10% + 1px) + max(10% + 1em) + min(10% + 20px))'.]
-    expected: FAIL
-
-  ['min(1px + 1%)' as a specified value should serialize as 'min(1% + 1px)'.]
-    expected: FAIL
-
-  ['min(1px + 1%)' as a computed value should serialize as 'min(1% + 1px)'.]
-    expected: FAIL
-
-  ['calc(1em + max(10% + 20px) + 5% + min(1em + 10%) + 10px)' as a specified value should serialize as 'calc(5% + 1em + 10px + max(10% + 20px) + min(10% + 1em))'.]
-    expected: FAIL
-
deleted file mode 100644
--- a/testing/web-platform/meta/css/css-values/minmax-percentage-computed.html.ini
+++ /dev/null
@@ -1,3 +0,0 @@
-[minmax-percentage-computed.html]
-  [calc(min(10%, 20%) - max(10%, 5%)) should be used-value-equivalent to 0%]
-    expected: FAIL
deleted file mode 100644
--- a/testing/web-platform/meta/css/css-values/minmax-time-computed.html.ini
+++ /dev/null
@@ -1,9 +0,0 @@
-[minmax-time-computed.html]
-  [calc(min(0.5s, 600ms) - 500ms) should be used-value-equivalent to 0s]
-    expected: FAIL
-
-  [calc(max(0.5s, 400ms) - 500ms) should be used-value-equivalent to 0s]
-    expected: FAIL
-
-  [calc(min(0.5s, 600ms) - max(500ms, 0.4s)) should be used-value-equivalent to 0s]
-    expected: FAIL
--- a/testing/web-platform/tests/css/css-values/clamp-length-serialize.html
+++ b/testing/web-platform/tests/css/css-values/clamp-length-serialize.html
@@ -4,12 +4,12 @@
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script src="../support/parsing-testcommon.js"></script>
 <script>
 function test_valid_length(value, expected) {
   test_valid_value('letter-spacing', value, expected);
 }
 
-test_valid_length('clamp(1px, 2px, 3px)', 'clamp(1px, 2px, 3px)');
-test_valid_length('clamp(1px, 2px, clamp(2px, 3px, 4px))', 'clamp(1px, 2px, clamp(2px, 3px, 4px))');
+test_valid_length('clamp(1px, 2px, 3px)', 'calc(2px)');
+test_valid_length('clamp(1px, 2px, clamp(2px, 3px, 4px))', 'calc(2px)');
 
 </script>
--- a/testing/web-platform/tests/css/css-values/minmax-length-computed.html
+++ b/testing/web-platform/tests/css/css-values/minmax-length-computed.html
@@ -105,10 +105,10 @@ test_length_equals('calc(min(1em, 21px) 
 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');
+test_length_equals('calc(min(1em + 1px, 22px) - max(0.9em, 20px))', '1px');
 </script>
--- a/testing/web-platform/tests/css/css-values/minmax-length-percent-serialize.html
+++ b/testing/web-platform/tests/css/css-values/minmax-length-percent-serialize.html
@@ -27,30 +27,37 @@ test_serialization(
     'max(1px)',
     'calc(1px)',
     '1px',
     '1px');
 
 // If not, keep as the function.
 test_serialization(
     'min(1% + 1px)',
-    'min(1% + 1px)',
-    'min(1% + 1px)',
+    'calc(1% + 1px)',
+    'calc(1% + 1px)',
     '2px');
 test_serialization(
     'min(1px + 1%)',
-    'min(1% + 1px)',
-    'min(1% + 1px)',
+    'calc(1% + 1px)',
+    'calc(1% + 1px)',
     '2px');
 test_serialization(
     'max(1px + 1%)',
-    'max(1% + 1px)',
-    'max(1% + 1px)',
+    'calc(1% + 1px)',
+    'calc(1% + 1px)',
     '2px');
 
+// Arguments are simplified eagerly as per spec:
+test_serialization(
+    'min(1px, 2px)',
+    'calc(1px)',
+    '1px',
+    '1px');
+
 // Arguments are simplified, but not reordered.
 test_serialization(
     'min(20px, 10%)',
     'min(20px, 10%)',
     'min(20px, 10%)',
     '10px');
 test_serialization(
     'min(1em, 10%)',
@@ -99,21 +106,21 @@ test_serialization(
     'max(10% + 30px, 5% + 5em)',
     'max(10% + 30px, 5% + 80px)',
     '85px');
 
 // min()/max() are valid inside a calc(),
 // and retain their relative order
 test_serialization(
     'calc(min(10% + 1px) + max(1em + 10%) + min(10% + 20px))',
-    'calc(min(10% + 1px) + max(10% + 1em) + min(10% + 20px))',
-    'calc(min(10% + 1px) + max(10% + 16px) + min(10% + 20px))',
+    'calc(30% + 1em + 21px)',
+    'calc(30% + 37px)',
     '67px');
 
 // min()/max() can be combined with plain units as well.
 // While min()/max() maintain their own ordering,
 // ordinary units will re-sort around them.
 test_serialization(
     'calc(1em + max(10% + 20px) + 5% + min(1em + 10%) + 10px)',
-    'calc(5% + 1em + 10px + max(10% + 20px) + min(10% + 1em))',
-    'calc(5% + 26px + max(10% + 20px) + min(10% + 16px))',
+    'calc(25% + 2em + 30px)',
+    'calc(25% + 62px)',
     '87px');
 </script>
--- a/testing/web-platform/tests/css/css-values/minmax-percentage-computed.html
+++ b/testing/web-platform/tests/css/css-values/minmax-percentage-computed.html
@@ -24,10 +24,10 @@ test_math_used('calc(min(10%, 20%) + 5%)
 test_math_used('calc(min(10%, 20%) - 5%)', '5%');
 test_math_used('calc(min(10%, 20%) * 2)', '20%');
 test_math_used('calc(min(10%, 20%) / 2)', '5%');
 test_math_used('calc(max(10%, 20%) + 5%)', '25%');
 test_math_used('calc(max(10%, 20%) - 5%)', '15%');
 test_math_used('calc(max(10%, 20%) * 2)', '40%');
 test_math_used('calc(max(10%, 20%) / 2)', '10%');
 test_math_used('calc(min(10%, 20%) + max(10%, 5%))', '20%');
-test_math_used('calc(min(10%, 20%) - max(10%, 5%))', '0%');
+test_math_used('calc(min(11%, 20%) - max(10%, 5%))', '1%');
 </script>
--- a/testing/web-platform/tests/css/css-values/minmax-time-computed.html
+++ b/testing/web-platform/tests/css/css-values/minmax-time-computed.html
@@ -29,20 +29,20 @@ test_time_equals('min(1s, 1100ms)', '1s'
 test_time_equals('max(0.9s, 1000ms)', '1000ms');
 
 // Nestings
 test_time_equals('min(2s, max(1s, 1500ms))', '1500ms');
 test_time_equals('max(1000ms, min(2000ms, 1.5s))', '1.5s');
 
 // General calculations
 test_time_equals('calc(min(0.5s, 600ms) + 500ms)', '1s');
-test_time_equals('calc(min(0.5s, 600ms) - 500ms)', '0s');
+test_time_equals('calc(min(0.6s, 700ms) - 500ms)', '0.1s');
 test_time_equals('calc(min(0.5s, 600ms) * 2)', '1s');
 test_time_equals('calc(min(0.5s, 600ms) / 2)', '0.25s');
 test_time_equals('calc(max(0.5s, 400ms) + 500ms)', '1s');
-test_time_equals('calc(max(0.5s, 400ms) - 500ms)', '0s');
+test_time_equals('calc(max(0.5s, 400ms) - 400ms)', '0.1s');
 test_time_equals('calc(max(0.5s, 400ms) * 2)', '1s');
 test_time_equals('calc(max(0.5s, 400ms) / 2)', '0.25s');
 test_time_equals('calc(min(0.5s, 600ms) + max(500ms, 0.4s))', '1s');
-test_time_equals('calc(min(0.5s, 600ms) - max(500ms, 0.4s))', '0s');
+test_time_equals('calc(min(0.6s, 700ms) - max(500ms, 0.4s))', '0.1s');
 test_time_equals('min(1s + 100ms, 500ms * 3)', '1.1s');
 test_time_equals('calc(min(1s, 2s) + max(3s, 4s) + 10s)', '15s');
 </script>