From 94d72c174a93f1b21ebda2bde2ae071a5b943bbc Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Mon, 8 Apr 2024 18:22:06 +0200 Subject: [PATCH] LibWeb: Allow executing scripts for iframes with src=about:blank Fixes https://github.com/SerenityOS/serenity/issues/23836 --- .../run-script-from-about-blank-iframe.txt | 1 + .../run-script-from-about-blank-iframe.html | 16 ++++++++++++++++ Userland/Libraries/LibWeb/DOM/Document.h | 1 + .../Libraries/LibWeb/HTML/NavigableContainer.cpp | 7 ++++++- 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/navigation/run-script-from-about-blank-iframe.txt create mode 100644 Tests/LibWeb/Text/input/navigation/run-script-from-about-blank-iframe.html diff --git a/Tests/LibWeb/Text/expected/navigation/run-script-from-about-blank-iframe.txt b/Tests/LibWeb/Text/expected/navigation/run-script-from-about-blank-iframe.txt new file mode 100644 index 00000000000..7c96b3ea8b4 --- /dev/null +++ b/Tests/LibWeb/Text/expected/navigation/run-script-from-about-blank-iframe.txt @@ -0,0 +1 @@ + message from test iframe diff --git a/Tests/LibWeb/Text/input/navigation/run-script-from-about-blank-iframe.html b/Tests/LibWeb/Text/input/navigation/run-script-from-about-blank-iframe.html new file mode 100644 index 00000000000..45a505d751a --- /dev/null +++ b/Tests/LibWeb/Text/input/navigation/run-script-from-about-blank-iframe.html @@ -0,0 +1,16 @@ + + + + + + diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index c880b27ee1b..c49f757afc1 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -583,6 +583,7 @@ public: void ensure_animation_timer(); bool ready_to_run_scripts() const { return m_ready_to_run_scripts; } + void set_ready_to_run_scripts() { m_ready_to_run_scripts = true; } JS::GCPtr latest_entry() const { return m_latest_entry; } void set_latest_entry(JS::GCPtr e) { m_latest_entry = e; } diff --git a/Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp b/Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp index b3ab20ece98..f850befa2d1 100644 --- a/Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp +++ b/Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp @@ -219,7 +219,12 @@ Optional 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) { - perform_url_and_history_update_steps(*m_content_navigable->active_document(), url); + 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.