Skip to content

Commit

Permalink
Fix sign() type checking.
Browse files Browse the repository at this point in the history
Make sure we don't parse units whose sign is not resolvable without a
basis (i.e. percentages when they're not allowed).

Also make sure that we type check the sum so that we don't parse bogus
operations.

Make the length resolution code not crash in release builds.

Differential Revision: https://phabricator.services.mozilla.com/D194500

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1866246
gecko-commit: 4b4afdd073f8bf99d995c26e1823b5b24feb07e4
gecko-reviewers: tlouw, firefox-style-system-reviewers, jwatt
  • Loading branch information
emilio authored and moz-wptsync-bot committed Nov 24, 2023
1 parent f91b458 commit 3d45287
Showing 1 changed file with 32 additions and 16 deletions.
48 changes: 32 additions & 16 deletions css/css-values/signs-abs-invalid.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@
<script src="../support/parsing-testcommon.js"></script>
<script>
function test_invalid_number(value) {
test_invalid_value('opacity', value);
test_invalid_value('font-weight', value);
}

function test_invalid_length_percentage(value) {
test_invalid_value('margin-left', value);
test_invalid_length(value);
}

function test_invalid_length(value) {
test_invalid_value('tab-size', value);
}

// Syntax checking
Expand All @@ -24,6 +33,13 @@
test_invalid_number('abs(1 2)');
test_invalid_number('abs(1, , 2)');
test_invalid_number('abs(1, 2)');
test_invalid_number('abs(1, 1%)');
test_invalid_number('abs(1, 0px)');
test_invalid_number('abs(1, 0s)');
test_invalid_number('abs(1, 0deg)');
test_invalid_number('abs(1, 0Hz)');
test_invalid_number('abs(1, 0dpi)');
test_invalid_number('abs(1, 0fr)');
test_invalid_number('sign()');
test_invalid_number('sign( )');
test_invalid_number('sign(,)');
Expand All @@ -36,6 +52,13 @@
test_invalid_number('sign(1 2)');
test_invalid_number('sign(1, , 2)');
test_invalid_number('sign(1, 2)');
test_invalid_number('sign(1, 1%)');
test_invalid_number('sign(1, 0px)');
test_invalid_number('sign(1, 0s)');
test_invalid_number('sign(1, 0deg)');
test_invalid_number('sign(1, 0Hz)');
test_invalid_number('sign(1, 0dpi)');
test_invalid_number('sign(1, 0fr)');

// Type checking
test_invalid_number('abs(0px)');
Expand All @@ -44,18 +67,11 @@
test_invalid_number('abs(0Hz)');
test_invalid_number('abs(0dpi)');
test_invalid_number('abs(0fr)');
test_invalid_number('abs(1, 1%)');
test_invalid_number('abs(1, 0px)');
test_invalid_number('abs(1, 0s)');
test_invalid_number('abs(1, 0deg)');
test_invalid_number('abs(1, 0Hz)');
test_invalid_number('abs(1, 0dpi)');
test_invalid_number('abs(1, 0fr)');
test_invalid_number('sign(1, 1%)');
test_invalid_number('sign(1, 0px)');
test_invalid_number('sign(1, 0s)');
test_invalid_number('sign(1, 0deg)');
test_invalid_number('sign(1, 0Hz)');
test_invalid_number('sign(1, 0dpi)');
test_invalid_number('sign(1, 0fr)');
</script>
test_invalid_number('abs(1%)');
test_invalid_number('sign(10px + 5rad)');
test_invalid_number('sign(10%)');
test_invalid_length('abs(10%)');
test_invalid_length('1px * sign(10%)');
test_invalid_length('1px * sign(1em + 10%)');
test_invalid_length_percentage('1px * sign(10px + 5rad)');
</script>

0 comments on commit 3d45287

Please sign in to comment.