CPCompatibility: Return nil for style properties without a DOM

CPBrowserStyleProperty created a test element without checking for a DOM,
throwing a ReferenceError outside a browser. Because initializing an
animator proxy calls this function, -animator could not be used in the
test suite. CPBrowserStyleProperty now returns nil when no DOM is
available.
This commit is contained in:
David Richardson committed 2026-11-23 17:20:18 -06:00
1 parent b792073dcf
commit 49e0407ef4
2 files changed
+21

No files matched your search

+10
View File
@@ -412,6 +412,16 @@ function CPBrowserStyleProperty(aProperty)
{
var lowerProperty = aProperty.toLowerCase();
/*
Without a DOM there is no style to test, so no property is supported.
2026-11-23: the function created a test element without checking for a DOM. Outside a
browser, the first call threw a ReferenceError; the first use of an animator proxy
makes that call, so -animator could not be used in the test suite.
*/
if (!CPDOMAvailable)
return nil;
if (PLATFORM_STYLE_JS_PROPERTIES[lowerProperty] === undefined)
{
var r = nil;
+11
View File
@@ -51,6 +51,17 @@ var SafariUserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebK
[self fail:@"CPCompatibility.j threw while loading under a WebKit user agent: " + loadException];
}
/*
The test suite runs without a DOM, so it states that a style property lookup outside a
browser finds no property and does not throw.
*/
- (void)testAStylePropertyLookupWithoutADOMFindsNoProperty
{
[self assert:NO equals:CPDOMAvailable message:@"the test suite runs without a DOM"];
[self assertNull:CPBrowserStyleProperty(@"animation") message:@"no style property is found"];
[self assertNull:CPBrowserCSSProperty(@"animation") message:@"no CSS property is found"];
}
@end
function compatibilityExecutable()