Skip to content

Commit

Permalink
Fixes test cases to allow unit cancellation in calc() to produce numb…
Browse files Browse the repository at this point in the history
…er values (#47897)

Updates test cases that assume that `calc(1px / 1px)` does not produce a number value.

See discussions in w3c/csswg-drafts#10733 and w3c/csswg-drafts#10752.
  • Loading branch information
weinig authored and pull[bot] committed Sep 5, 2024
1 parent 52a5671 commit 1245760
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
assert_valid("<length>", "10px /*:)*/");
assert_valid("<length>", " calc(-2px)");
assert_valid("<length>", "calc(2px*4 + 10px)");
assert_valid("<length>", "calc(5px * 3px / 6px)");
assert_valid("<length>", "7.1e-4cm");
assert_valid("<length>", "calc(7in - 12px)");
assert_valid("<length>", "calc(15px + (sign(100vh - 10px) * 5px))");
Expand Down Expand Up @@ -255,7 +256,6 @@
assert_invalid("<length>", "10");
assert_invalid("<length>", "10%");
assert_invalid("<length>", "calc(5px + 10%)");
assert_invalid("<length>", "calc(5px * 3px / 6px)");
assert_invalid("<length>", "10em");
assert_invalid("<length>", "calc(4px + 3em)");
assert_invalid("<length>", "calc(4px + calc(8 * 2em))");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <number>'},
{ coord: new CSSMathProduct(CSS.px(1), new CSSMathInvert(CSS.px(1))), desc: 'an invalid division by px/px'},
];

for (const {coord, desc} of gInvalidCoordTestCases) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 1245760

Please sign in to comment.