From 88f2f50c55e749a7b3ced7a9b13def3bfd88c9d6 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 6 Sep 2022 01:12:44 +0200 Subject: [PATCH] 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. --- Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp index e37e78b684..5885c21291 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp @@ -3369,7 +3369,7 @@ DOM::Document& HTMLParser::document() Vector> 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;