Bug 1915918 [wpt PR 47897] - Fixes test cases to allow unit cancellation in calc() to produce number values, a=testonly

Automatic update from web-platform-tests
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.
--

wpt-commits: 6712652b8d03ef38b5d34d40464f1e13774595bb
wpt-pr: 47897
This commit is contained in:
Sam Weinig 2024-08-31 21:43:23 +00:00 committed by moz-wptsync-bot
parent 4a592d0c75
commit 4cf9a51b31
2 changed files with 8 additions and 2 deletions

View File

@ -47,6 +47,7 @@ assert_valid("<length>", "0");
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))");
@ -255,7 +256,6 @@ assert_invalid("<length>", "var(--moo)");
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))");

View File

@ -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) {
@ -58,6 +57,13 @@ test(() => {
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);