1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:37:35 +00:00

Userland+Ladybird: Always specify url to be about:srcdoc in load_html()

After moving to navigables, we started reusing the code that populates
session history entries with the srcdoc attribute value from iframes
in `Page::load_html()` for loading HTML.

This change addresses a crash in `determine_the_origin` which occurred
because this method expected the URL to be `about:srcdoc` if we also
provided HTML content (previously, it was the URL passed along with the
HTML content into `load_html()`).
This commit is contained in:
Aliaksandr Kalenik 2023-09-17 17:12:17 +02:00 committed by Andreas Kling
parent 8e832a174e
commit 3c675e3f25
18 changed files with 31 additions and 32 deletions

View file

@ -47,9 +47,9 @@ void Page::load(const AK::URL& url)
(void)top_level_traversable()->navigate(url, *top_level_traversable()->active_document());
}
void Page::load_html(StringView html, const AK::URL& url)
void Page::load_html(StringView html)
{
(void)top_level_traversable()->navigate(url, *top_level_traversable()->active_document(), String::from_utf8(html).release_value_but_fixme_should_propagate_errors());
(void)top_level_traversable()->navigate("about:srcdoc"sv, *top_level_traversable()->active_document(), String::from_utf8(html).release_value_but_fixme_should_propagate_errors());
}
bool Page::has_ongoing_navigation() const

View file

@ -60,7 +60,7 @@ public:
void load(const AK::URL&);
void load_html(StringView, const AK::URL&);
void load_html(StringView);
bool has_ongoing_navigation() const;

View file

@ -86,15 +86,14 @@ void ViewImplementation::load(AK::URL const& url)
client().async_load_url(url);
}
void ViewImplementation::load_html(StringView html, AK::URL const& url)
void ViewImplementation::load_html(StringView html)
{
m_url = url;
client().async_load_html(html, url);
client().async_load_html(html);
}
void ViewImplementation::load_empty_document()
{
load_html(""sv, {});
load_html(""sv);
}
void ViewImplementation::zoom_in()
@ -328,7 +327,7 @@ void ViewImplementation::handle_web_content_process_crash()
auto escaped_url = escape_html_entities(m_url.to_deprecated_string());
builder.appendff("The web page <a href=\"{}\">{}</a> has crashed.<br><br>You can reload the page to try again.", escaped_url, escaped_url);
builder.append("</body></html>"sv);
load_html(builder.to_deprecated_string(), m_url);
load_html(builder.to_deprecated_string());
}
ErrorOr<void> ViewImplementation::take_screenshot(ScreenshotType type)

View file

@ -52,7 +52,7 @@ public:
void server_did_change_selection(Badge<WebContentClient>);
void load(AK::URL const&);
void load_html(StringView, AK::URL const&);
void load_html(StringView);
void load_empty_document();
void zoom_in();