LibWeb: Explicitly set Document's origin

As part of the effort of removing the default constructor of
Origin, since document has the origin set after construction,
port Document's origin over to an Optional<Origin>.

This exposes that we were never setting the origin of the document
during fragment parsing. For now, to maintain previous behaviour,
let's explicitly set it to an opaque origin.
This commit is contained in:
Shannon Booth 2025-06-15 19:04:02 +12:00 committed by Jelle Raaijmakers
parent de79eb4410
commit 5deb8ba2f8
Notes: github-actions[bot] 2025-06-17 18:55:25 +00:00
3 changed files with 7 additions and 2 deletions

View file

@ -4570,6 +4570,11 @@ Vector<GC::Root<DOM::Node>> HTMLParser::parse_html_fragment(DOM::Element& contex
// This is required for Document::parse_url() to work inside iframe srcdoc documents.
temp_document->set_about_base_url(context_element.document().about_base_url());
// AD-HOC: The origin is not otherwise set for the document, but it may be accessed during parsing
// script. For now, let's just use an opaque origin, but it is likely that the spec is
// missing setting this origin.
temp_document->set_origin(URL::Origin {});
// 2. If context's node document is in quirks mode, then set document's mode to "quirks".
if (context_element.document().in_quirks_mode())
temp_document->set_quirks_mode(DOM::QuirksMode::Yes);