From 12457604a52475114a66415bcba38b4fadd3514d Mon Sep 17 00:00:00 2001 From: Sam Weinig Date: Fri, 30 Aug 2024 15:40:57 -0700 Subject: [PATCH] Fixes test cases to allow unit cancellation in calc() to produce number values (#47897) Updates test cases that assume that `calc(1px / 1px)` does not produce a number value. See discussions in https://github.com/w3c/csswg-drafts/issues/10733 and https://github.com/w3c/csswg-drafts/issues/10752. --- .../register-property-syntax-parsing.html | 2 +- .../stylevalue-subclasses/cssScale.tentative.html | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/css/css-properties-values-api/register-property-syntax-parsing.html b/css/css-properties-values-api/register-property-syntax-parsing.html index d11daabafc5b89b..793ef21ba1d3f87 100644 --- a/css/css-properties-values-api/register-property-syntax-parsing.html +++ b/css/css-properties-values-api/register-property-syntax-parsing.html @@ -47,6 +47,7 @@ assert_valid("", "10px /*:)*/"); assert_valid("", " calc(-2px)"); assert_valid("", "calc(2px*4 + 10px)"); +assert_valid("", "calc(5px * 3px / 6px)"); assert_valid("", "7.1e-4cm"); assert_valid("", "calc(7in - 12px)"); assert_valid("", "calc(15px + (sign(100vh - 10px) * 5px))"); @@ -255,7 +256,6 @@ assert_invalid("", "10"); assert_invalid("", "10%"); assert_invalid("", "calc(5px + 10%)"); -assert_invalid("", "calc(5px * 3px / 6px)"); assert_invalid("", "10em"); assert_invalid("", "calc(4px + 3em)"); assert_invalid("", "calc(4px + calc(8 * 2em))"); diff --git a/css/css-typed-om/stylevalue-subclasses/cssScale.tentative.html b/css/css-typed-om/stylevalue-subclasses/cssScale.tentative.html index e5efb938764c03c..691cf4c519cbcde 100644 --- a/css/css-typed-om/stylevalue-subclasses/cssScale.tentative.html +++ b/css/css-typed-om/stylevalue-subclasses/cssScale.tentative.html @@ -11,7 +11,6 @@ const gInvalidCoordTestCases = [ { coord: CSS.deg(1), desc: 'an angle CSSUnitValue'}, { coord: new CSSMathSum(CSS.px(1)), desc: 'a CSSMathValue that doesn\'t match '}, - { coord: new CSSMathProduct(CSS.px(1), new CSSMathInvert(CSS.px(1))), desc: 'an invalid division by px/px'}, ]; for (const {coord, desc} of gInvalidCoordTestCases) { @@ -58,6 +57,13 @@ assert_false(result.is2D); }, 'CSSScale can be constructed from CSSMathValue coordinates'); +test(() => { + const result = new CSSScale(new CSSMathProduct(CSS.px(1), new CSSMathInvert(CSS.px(1))), 3.14); + assert_style_value_equals(result.x, new CSSMathProduct(CSS.px(1), new CSSMathInvert(CSS.px(1)))); + assert_style_value_equals(result.y, CSS.number(3.14)); + assert_style_value_equals(result.z, CSS.number(1)); +}, 'CSSScale can be constructed from unit canceling length value coordinates'); + for (const attr of ['x', 'y', 'z']) { test(() => { let result = new CSSScale(0, 0, 0);