LibWeb: Don't use the internal window object when parsing HTML fragments

Instead, use the window object from the context element. This fixes an
issue where activating event handlers during fragment parsing would try
to set up callbacks using the internal window object's ESO.

This caused a verify_cast crash on Google Maps, since the internal realm
doesn't have an associated ESO. Perhaps it should, but in this specific
case, it makes more sense for fragment parsing to fully adopt the
context provided.
This commit is contained in:
Andreas Kling 2022-09-06 01:12:44 +02:00
parent 4c665c3749
commit 88f2f50c55
Notes: sideshowbarker 2024-07-17 07:23:25 +09:00

View file

@ -3369,7 +3369,7 @@ DOM::Document& HTMLParser::document()
Vector<JS::Handle<DOM::Node>> HTMLParser::parse_html_fragment(DOM::Element& context_element, StringView markup)
{
auto temp_document = DOM::Document::create(Bindings::main_thread_internal_window_object());
auto temp_document = DOM::Document::create(context_element.window());
auto parser = HTMLParser::create(*temp_document, markup, "utf-8");
parser->m_context_element = JS::make_handle(context_element);
parser->m_parsing_fragment = true;