commit a2e94e7190047c2adbec6c12dd72f41274ad82aa parent 46e52c831cb2aff47a901d296c519b12848fca8d Author: Jan Varga <jan.varga@gmail.com> Date: Mon, 17 Nov 2025 08:03:45 +0000 Bug 1990419 - Improve StylePropertyMapReadOnly::Get to better handle unknown properties; r=emilio,firefox-style-system-reviewers This patch refines StylePropertyMapReadOnly::Get by checking for unknown properties explicitly. 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 StylePropertyMapReadOnly::Get now pass. Differential Revision: https://phabricator.services.mozilla.com/D271799 Diffstat:
3 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/layout/style/typedom/StylePropertyMapReadOnly.cpp b/layout/style/typedom/StylePropertyMapReadOnly.cpp @@ -17,6 +17,7 @@ #include "mozilla/dom/CSSStyleValue.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/StylePropertyMapReadOnlyBinding.h" +#include "nsCSSProps.h" #include "nsComputedDOMStyle.h" #include "nsCycleCollectionParticipant.h" #include "nsQueryObject.h" @@ -47,7 +48,6 @@ struct DeclarationTraits<InlineStyleDeclarations> { } if (!block->GetPropertyTypedValue(aProperty, result)) { - aRv.ThrowTypeError("Invalid CSS property"); return result; } @@ -74,7 +74,6 @@ struct DeclarationTraits<ComputedStyleDeclarations> { } if (!style->GetPropertyTypedValue(aProperty, result)) { - aRv.ThrowTypeError("Invalid CSS property"); return result; } @@ -123,6 +122,14 @@ void StylePropertyMapReadOnly::Get(const nsACString& aProperty, return; } + // Step 2. + + NonCustomCSSPropertyId propId = nsCSSProps::LookupProperty(aProperty); + if (propId == eCSSProperty_UNKNOWN) { + aRv.ThrowTypeError("Invalid property: "_ns + aProperty); + return; + } + // Step 3. const Declarations& declarations = mDeclarations; diff --git a/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/computed/get.html.ini b/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/computed/get.html.ini @@ -13,6 +13,3 @@ [Computed StylePropertyMap.get reflects updates in inline style] expected: FAIL - - [Getting a custom property not in the computed style returns undefined] - expected: FAIL diff --git a/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/computed/getAll.tentative.html.ini b/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/computed/getAll.tentative.html.ini @@ -1,7 +1,4 @@ [getAll.tentative.html] - [Calling StylePropertyMap.getAll with a custom property not in the property model returns an empty list] - expected: FAIL - [Calling StylePropertyMap.getAll with a valid property returns a single element list with the correct entry] expected: FAIL