serenity icon indicating copy to clipboard operation
serenity copied to clipboard

LibWeb: Don't crash in offset_parent() if no ancestor element found

Open tcl3 opened this issue 11 months ago • 0 comments

The specification says the final step of this algorithm is to return null. Previously, the browser would crash if the content of an iframe was appended to the document before its offsetParent property was queried.

Fixes this WPT test (and probably others): the-xhtml-syntax/parsing-xhtml-documents/adopt-while-parsing-001

This fix also prevents these WPT tests from crashing WebContent, although it doesn't fix them:

I believe a more complete solution would be to implement offsetParent from this specification. This would allow us to handle calling offsetParent for elements within a shadow root, which may fix the above 5 tests.

In the meantime, I think this change is still worth making, as it stops WebContent from crashing even if it doesn't always work as expected.

tcl3 avatar Feb 29 '24 22:02 tcl3