LibWeb: Mark initial about:blank as ready to run scripts after creation

This matches how other browsers behave.

Fixes https://github.com/SerenityOS/serenity/issues/23892
This commit is contained in:
Aliaksandr Kalenik 2024-04-11 17:27:11 +02:00 committed by Andreas Kling
parent 649f70db65
commit a73bf1607f
4 changed files with 20 additions and 4 deletions

View file

@ -0,0 +1 @@
message from test iframe

View file

@ -0,0 +1,17 @@
<!DOCTYPE html>
<script src="../include.js"></script>
<body>
<!-- Other browsers seem to display the message below regardless of what src is (valid or not) -->
<iframe id="target" srcdoc="iframe content"></iframe>
<script>
asyncTest((done) => {
const script = target.contentDocument.createElement("script");
script.innerHTML = `parent.postMessage("message from test iframe", "*");`;
target.contentDocument.body.appendChild(script);
window.addEventListener("message", event => {
println(event.data);
done();
});
});
</script>
</body>

View file

@ -227,6 +227,8 @@ WebIDL::ExceptionOr<BrowsingContext::BrowsingContextAndDocument> BrowsingContext
// is initial about:blank: true
document->set_is_initial_about_blank(true);
// Spec issue: https://github.com/whatwg/html/issues/10261
document->set_ready_to_run_scripts();
// about base URL: creatorBaseURL
document->set_about_base_url(creator_base_url);

View file

@ -220,11 +220,7 @@ Optional<URL::URL> NavigableContainer::shared_attribute_processing_steps_for_ifr
// 4. If url matches about:blank and initialInsertion is true, then perform the URL and history update steps given element's content navigable's active document and url.
if (url_matches_about_blank(url) && initial_insertion) {
auto& document = *m_content_navigable->active_document();
perform_url_and_history_update_steps(document, url);
// Spec issue: https://github.com/whatwg/html/issues/10261
document.set_ready_to_run_scripts();
}
// 5. Return url.