Browse Source

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.
Andreas Kling 2 years ago
parent
commit
88f2f50c55
1 changed files with 1 additions and 1 deletions
  1. 1 1
      Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp

+ 1 - 1
Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp

@@ -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;