From 3f719072552b46b379547cac69b860ffbc0386e0 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Thu, 27 Feb 2025 21:36:33 +0100 Subject: [PATCH] LibWeb: Process navigations after initial about:blank navigation is done Otherwise finalization step of initial `about:blank` navigation might cancel user-initiated navigations by changing ongoing navigation id. This is implemented by marking navigable as ready to start processing navigation in SHTQ task, because we know for sure this task cannot be processed until finalization step of initial `about:blank` navigation is done. --- Libraries/LibWeb/HTML/HTMLIFrameElement.cpp | 8 +++++- ...ne-before-further-navigation-of-iframe.txt | 1 + ...e-before-further-navigation-of-iframe.html | 25 +++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/navigation/make-sure-about-blank-navigation-is-done-before-further-navigation-of-iframe.txt create mode 100644 Tests/LibWeb/Text/input/navigation/make-sure-about-blank-navigation-is-done-before-further-navigation-of-iframe.html diff --git a/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index 5c7bbf56d31..1d819e25f6d 100644 --- a/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include namespace Web::HTML { @@ -93,7 +94,12 @@ void HTMLIFrameElement::post_connection() // 3. Process the iframe attributes for insertedNode, with initialInsertion set to true. process_the_iframe_attributes(true); - set_content_navigable_has_session_history_entry_and_ready_for_navigation(); + if (auto navigable = content_navigable()) { + auto traversable = navigable->traversable_navigable(); + traversable->append_session_history_traversal_steps(GC::create_function(heap(), [this] { + set_content_navigable_has_session_history_entry_and_ready_for_navigation(); + })); + } }))); } diff --git a/Tests/LibWeb/Text/expected/navigation/make-sure-about-blank-navigation-is-done-before-further-navigation-of-iframe.txt b/Tests/LibWeb/Text/expected/navigation/make-sure-about-blank-navigation-is-done-before-further-navigation-of-iframe.txt new file mode 100644 index 00000000000..4effa19f4f7 --- /dev/null +++ b/Tests/LibWeb/Text/expected/navigation/make-sure-about-blank-navigation-is-done-before-further-navigation-of-iframe.txt @@ -0,0 +1 @@ +hello! diff --git a/Tests/LibWeb/Text/input/navigation/make-sure-about-blank-navigation-is-done-before-further-navigation-of-iframe.html b/Tests/LibWeb/Text/input/navigation/make-sure-about-blank-navigation-is-done-before-further-navigation-of-iframe.html new file mode 100644 index 00000000000..eb28c83447e --- /dev/null +++ b/Tests/LibWeb/Text/input/navigation/make-sure-about-blank-navigation-is-done-before-further-navigation-of-iframe.html @@ -0,0 +1,25 @@ + + + + + + + + + \ No newline at end of file