LibWeb/HTML: Correctly set base elements frozen base url
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

This commit implements the fallback to the documents fallback base url
if the href of the first base element is a data or javascript url.

Additionally the frozen base url is set, if a base element becomes the
first base element with an href content attribute because the previous
one got removed.
This commit is contained in:
Glenn Skrzypczak 2025-05-02 23:25:38 +02:00 committed by Shannon Booth
parent 4ed9f6fcc0
commit 6b84cd8d11
Notes: github-actions[bot] 2025-06-23 06:57:47 +00:00
7 changed files with 103 additions and 12 deletions

View file

@ -1135,10 +1135,10 @@ Vector<CSS::BackgroundLayerData> const* Document::background_layers() const
void Document::update_base_element(Badge<HTML::HTMLBaseElement>)
{
GC::Ptr<HTML::HTMLBaseElement const> base_element_with_href = nullptr;
GC::Ptr<HTML::HTMLBaseElement const> base_element_with_target = nullptr;
GC::Ptr<HTML::HTMLBaseElement> base_element_with_href = nullptr;
GC::Ptr<HTML::HTMLBaseElement> base_element_with_target = nullptr;
for_each_in_subtree_of_type<HTML::HTMLBaseElement>([&base_element_with_href, &base_element_with_target](HTML::HTMLBaseElement const& base_element_in_tree) {
for_each_in_subtree_of_type<HTML::HTMLBaseElement>([&base_element_with_href, &base_element_with_target](HTML::HTMLBaseElement& base_element_in_tree) {
if (!base_element_with_href && base_element_in_tree.has_attribute(HTML::AttributeNames::href)) {
base_element_with_href = &base_element_in_tree;
if (base_element_with_target)
@ -1157,12 +1157,12 @@ void Document::update_base_element(Badge<HTML::HTMLBaseElement>)
m_first_base_element_with_target_in_tree_order = base_element_with_target;
}
GC::Ptr<HTML::HTMLBaseElement const> Document::first_base_element_with_href_in_tree_order() const
GC::Ptr<HTML::HTMLBaseElement> Document::first_base_element_with_href_in_tree_order() const
{
return m_first_base_element_with_href_in_tree_order;
}
GC::Ptr<HTML::HTMLBaseElement const> Document::first_base_element_with_target_in_tree_order() const
GC::Ptr<HTML::HTMLBaseElement> Document::first_base_element_with_target_in_tree_order() const
{
return m_first_base_element_with_target_in_tree_order;
}