LibWeb: Set origin of new document in Document.parseHTMLUnsafe()

Previously, a crash would occur when accessing the origin of a document
created with this method.
This commit is contained in:
Tim Ledbetter 2025-07-05 10:21:22 +01:00 committed by Shannon Booth
commit b3fa54a791
Notes: github-actions[bot] 2025-07-06 01:41:08 +00:00

View file

@ -6330,6 +6330,10 @@ GC::Ref<Document> Document::parse_html_unsafe(JS::VM& vm, StringView html)
// 4. Parse HTML from a string given document and compliantHTML. // FIXME: Use compliantHTML.
document->parse_html_from_a_string(html);
// AD-HOC: Setting the origin to match that of the associated document matches the behavior of existing browsers.
auto& associated_document = as<HTML::Window>(realm.global_object()).associated_document();
document->set_origin(associated_document.origin());
// 5. Return document.
return document;
}