commit 27f7f716a231d6ff4d8b62f8e5e957e6a53a35ff parent 5c91a7fca3b13088861b62385d20e3d08a57c049 Author: Jan Varga <jan.varga@gmail.com> Date: Tue, 4 Nov 2025 13:22:29 +0000 Bug 1990419 - Improve StylePropertyMap::Set to handle unknown properties; r=emilio,firefox-style-system-reviewers,dshin This patch refines StylePropertyMap::Set by checking for unknown properties. This improves spec compliance, but the main goal is to ensure that the corresponding property ID is available for use in a following patch. Some WPTs related to StylePropertyMap::Set now pass, while many others appear to pass only because certain properties are not yet supported, such as "baseline-shift". Differential Revision: https://phabricator.services.mozilla.com/D270609 Diffstat:
15 files changed, 9 insertions(+), 261 deletions(-)
diff --git a/layout/style/typedom/StylePropertyMap.cpp b/layout/style/typedom/StylePropertyMap.cpp @@ -14,6 +14,7 @@ #include "mozilla/dom/CSSStyleValue.h" #include "mozilla/dom/StylePropertyMapBinding.h" #include "nsCOMPtr.h" +#include "nsCSSProps.h" #include "nsDOMCSSDeclaration.h" #include "nsQueryObject.h" #include "nsString.h" @@ -39,6 +40,14 @@ void StylePropertyMap::Set( const nsACString& aProperty, const Sequence<OwningCSSStyleValueOrUTF8String>& aValues, ErrorResult& aRv) { + // Step 2. + + nsCSSPropertyID propID = nsCSSProps::LookupProperty(aProperty); + if (propID == eCSSProperty_UNKNOWN) { + aRv.ThrowTypeError("Invalid property: "_ns + aProperty); + return; + } + if (aValues.Length() != 1) { aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); return; diff --git a/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/declared/set.tentative.html.ini b/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/declared/set.tentative.html.ini @@ -1,13 +1,4 @@ [set.tentative.html] - [Setting a StylePropertyMap with an unsupported property name throws TypeError] - expected: FAIL - - [Setting a StylePropertyMap with an null property name throws TypeError] - expected: FAIL - - [Setting a StylePropertyMap with a descriptor throws TypeError] - expected: FAIL - [Setting a StylePropertyMap with an invalid CSSStyleValue throws TypeError] expected: FAIL diff --git a/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/inline/set.tentative.html.ini b/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/inline/set.tentative.html.ini @@ -1,13 +1,4 @@ [set.tentative.html] - [Setting a StylePropertyMap with an unsupported property name throws TypeError] - expected: FAIL - - [Setting a StylePropertyMap with an null property name throws TypeError] - expected: FAIL - - [Setting a StylePropertyMap with a descriptor throws TypeError] - expected: FAIL - [Setting a StylePropertyMap with an invalid CSSStyleValue throws TypeError] expected: FAIL diff --git a/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/alignment-baseline.html.ini b/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/alignment-baseline.html.ini @@ -38,24 +38,3 @@ [Can set 'alignment-baseline' to the 'top' keyword: ] expected: FAIL - - [Setting 'alignment-baseline' to a length: throws TypeError] - expected: FAIL - - [Setting 'alignment-baseline' to a percent: throws TypeError] - expected: FAIL - - [Setting 'alignment-baseline' to a time: throws TypeError] - expected: FAIL - - [Setting 'alignment-baseline' to an angle: throws TypeError] - expected: FAIL - - [Setting 'alignment-baseline' to a flexible length: throws TypeError] - expected: FAIL - - [Setting 'alignment-baseline' to a number: throws TypeError] - expected: FAIL - - [Setting 'alignment-baseline' to a transform: throws TypeError] - expected: FAIL diff --git a/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/baseline-shift.html.ini b/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/baseline-shift.html.ini @@ -17,18 +17,3 @@ [Can set 'baseline-shift' to a length: ] expected: FAIL - - [Setting 'baseline-shift' to a time: throws TypeError] - expected: FAIL - - [Setting 'baseline-shift' to an angle: throws TypeError] - expected: FAIL - - [Setting 'baseline-shift' to a flexible length: throws TypeError] - expected: FAIL - - [Setting 'baseline-shift' to a number: throws TypeError] - expected: FAIL - - [Setting 'baseline-shift' to a transform: throws TypeError] - expected: FAIL diff --git a/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/column-height.html.ini b/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/column-height.html.ini @@ -11,21 +11,3 @@ [Can set 'column-height' to a length: ] expected: FAIL - - [Setting 'column-height' to a percent: throws TypeError] - expected: FAIL - - [Setting 'column-height' to a time: throws TypeError] - expected: FAIL - - [Setting 'column-height' to an angle: throws TypeError] - expected: FAIL - - [Setting 'column-height' to a flexible length: throws TypeError] - expected: FAIL - - [Setting 'column-height' to a number: throws TypeError] - expected: FAIL - - [Setting 'column-height' to a transform: throws TypeError] - expected: FAIL diff --git a/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/fill-color.html.ini b/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/fill-color.html.ini @@ -9,27 +9,6 @@ [Can set 'fill-color' to the 'currentcolor' keyword: ] expected: FAIL - [Setting 'fill-color' to a length: throws TypeError] - expected: FAIL - - [Setting 'fill-color' to a percent: throws TypeError] - expected: FAIL - - [Setting 'fill-color' to a time: throws TypeError] - expected: FAIL - - [Setting 'fill-color' to an angle: throws TypeError] - expected: FAIL - - [Setting 'fill-color' to a flexible length: throws TypeError] - expected: FAIL - - [Setting 'fill-color' to a number: throws TypeError] - expected: FAIL - - [Setting 'fill-color' to a transform: throws TypeError] - expected: FAIL - ['fill-color' does not support 'red'] expected: FAIL diff --git a/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/font-presentation.html.ini b/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/font-presentation.html.ini @@ -14,24 +14,3 @@ [Can set 'font-presentation' to the 'emoji' keyword: ] expected: FAIL - - [Setting 'font-presentation' to a length: throws TypeError] - expected: FAIL - - [Setting 'font-presentation' to a percent: throws TypeError] - expected: FAIL - - [Setting 'font-presentation' to a time: throws TypeError] - expected: FAIL - - [Setting 'font-presentation' to an angle: throws TypeError] - expected: FAIL - - [Setting 'font-presentation' to a flexible length: throws TypeError] - expected: FAIL - - [Setting 'font-presentation' to a number: throws TypeError] - expected: FAIL - - [Setting 'font-presentation' to a transform: throws TypeError] - expected: FAIL diff --git a/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/font-size.html.ini b/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/font-size.html.ini @@ -90,21 +90,6 @@ [Can set 'font-min-size' to a percent: ] expected: FAIL - [Setting 'font-min-size' to a time: throws TypeError] - expected: FAIL - - [Setting 'font-min-size' to an angle: throws TypeError] - expected: FAIL - - [Setting 'font-min-size' to a flexible length: throws TypeError] - expected: FAIL - - [Setting 'font-min-size' to a number: throws TypeError] - expected: FAIL - - [Setting 'font-min-size' to a transform: throws TypeError] - expected: FAIL - [Can set 'font-max-size' to CSS-wide keywords: ] expected: FAIL @@ -146,18 +131,3 @@ [Can set 'font-max-size' to a percent: ] expected: FAIL - - [Setting 'font-max-size' to a time: throws TypeError] - expected: FAIL - - [Setting 'font-max-size' to an angle: throws TypeError] - expected: FAIL - - [Setting 'font-max-size' to a flexible length: throws TypeError] - expected: FAIL - - [Setting 'font-max-size' to a number: throws TypeError] - expected: FAIL - - [Setting 'font-max-size' to a transform: throws TypeError] - expected: FAIL diff --git a/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/orphans.html.ini b/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/orphans.html.ini @@ -8,21 +8,3 @@ [Can set 'orphans' to a number: ] expected: FAIL - - [Setting 'orphans' to a length: throws TypeError] - expected: FAIL - - [Setting 'orphans' to a percent: throws TypeError] - expected: FAIL - - [Setting 'orphans' to a time: throws TypeError] - expected: FAIL - - [Setting 'orphans' to an angle: throws TypeError] - expected: FAIL - - [Setting 'orphans' to a flexible length: throws TypeError] - expected: FAIL - - [Setting 'orphans' to a transform: throws TypeError] - expected: FAIL diff --git a/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/speak.html.ini b/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/speak.html.ini @@ -14,24 +14,3 @@ [Can set 'speak' to the 'always' keyword: ] expected: FAIL - - [Setting 'speak' to a length: throws TypeError] - expected: FAIL - - [Setting 'speak' to a percent: throws TypeError] - expected: FAIL - - [Setting 'speak' to a time: throws TypeError] - expected: FAIL - - [Setting 'speak' to an angle: throws TypeError] - expected: FAIL - - [Setting 'speak' to a flexible length: throws TypeError] - expected: FAIL - - [Setting 'speak' to a number: throws TypeError] - expected: FAIL - - [Setting 'speak' to a transform: throws TypeError] - expected: FAIL diff --git a/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/text-decoration-skip.html.ini b/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/text-decoration-skip.html.ini @@ -21,27 +21,6 @@ [Can set 'text-decoration-skip' to the 'spaces' keyword: ] expected: FAIL - [Setting 'text-decoration-skip' to a length: throws TypeError] - expected: FAIL - - [Setting 'text-decoration-skip' to a percent: throws TypeError] - expected: FAIL - - [Setting 'text-decoration-skip' to a time: throws TypeError] - expected: FAIL - - [Setting 'text-decoration-skip' to an angle: throws TypeError] - expected: FAIL - - [Setting 'text-decoration-skip' to a flexible length: throws TypeError] - expected: FAIL - - [Setting 'text-decoration-skip' to a number: throws TypeError] - expected: FAIL - - [Setting 'text-decoration-skip' to a transform: throws TypeError] - expected: FAIL - ['text-decoration-skip' does not support 'objects spaces'] expected: FAIL diff --git a/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/text-size-adjust.html.ini b/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/text-size-adjust.html.ini @@ -14,21 +14,3 @@ [Can set 'text-size-adjust' to a percent: ] expected: FAIL - - [Setting 'text-size-adjust' to a length: throws TypeError] - expected: FAIL - - [Setting 'text-size-adjust' to a time: throws TypeError] - expected: FAIL - - [Setting 'text-size-adjust' to an angle: throws TypeError] - expected: FAIL - - [Setting 'text-size-adjust' to a flexible length: throws TypeError] - expected: FAIL - - [Setting 'text-size-adjust' to a number: throws TypeError] - expected: FAIL - - [Setting 'text-size-adjust' to a transform: throws TypeError] - expected: FAIL diff --git a/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/white-space.html.ini b/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/white-space.html.ini @@ -98,27 +98,6 @@ [Can set 'white-space-trim' to the 'discard-inner' keyword: ] expected: FAIL - [Setting 'white-space-trim' to a length: throws TypeError] - expected: FAIL - - [Setting 'white-space-trim' to a percent: throws TypeError] - expected: FAIL - - [Setting 'white-space-trim' to a time: throws TypeError] - expected: FAIL - - [Setting 'white-space-trim' to an angle: throws TypeError] - expected: FAIL - - [Setting 'white-space-trim' to a flexible length: throws TypeError] - expected: FAIL - - [Setting 'white-space-trim' to a number: throws TypeError] - expected: FAIL - - [Setting 'white-space-trim' to a transform: throws TypeError] - expected: FAIL - ['white-space-trim' does not support 'discard-before discard-after'] expected: FAIL diff --git a/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/widows.html.ini b/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/widows.html.ini @@ -8,21 +8,3 @@ [Can set 'widows' to a number: ] expected: FAIL - - [Setting 'widows' to a length: throws TypeError] - expected: FAIL - - [Setting 'widows' to a percent: throws TypeError] - expected: FAIL - - [Setting 'widows' to a time: throws TypeError] - expected: FAIL - - [Setting 'widows' to an angle: throws TypeError] - expected: FAIL - - [Setting 'widows' to a flexible length: throws TypeError] - expected: FAIL - - [Setting 'widows' to a transform: throws TypeError] - expected: FAIL