From 5af058d2b6beb49b5234571eaf7861bca83245aa Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Mon, 1 Jan 2024 16:31:14 +0000 Subject: [PATCH] LibWeb: Only reload iframe on src/srcdoc attribute changes, not all Fixes Cloudflare Turnstile suddenly going blank and stopping when it changes the style attribute after doing some setup on the iframe. --- .../iframe-reload-on-src-or-srcdoc-change.txt | 10 ++ ...iframe-reload-on-src-or-srcdoc-change.html | 97 +++++++++++++++++++ .../LibWeb/HTML/HTMLIFrameElement.cpp | 13 ++- 3 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 Tests/LibWeb/Text/expected/HTML/iframe-reload-on-src-or-srcdoc-change.txt create mode 100644 Tests/LibWeb/Text/input/HTML/iframe-reload-on-src-or-srcdoc-change.html diff --git a/Tests/LibWeb/Text/expected/HTML/iframe-reload-on-src-or-srcdoc-change.txt b/Tests/LibWeb/Text/expected/HTML/iframe-reload-on-src-or-srcdoc-change.txt new file mode 100644 index 0000000000..f9e6a03dcd --- /dev/null +++ b/Tests/LibWeb/Text/expected/HTML/iframe-reload-on-src-or-srcdoc-change.txt @@ -0,0 +1,10 @@ + 1 +2 +4 +5 +6 +8 +9 +11 +12 +DONE diff --git a/Tests/LibWeb/Text/input/HTML/iframe-reload-on-src-or-srcdoc-change.html b/Tests/LibWeb/Text/input/HTML/iframe-reload-on-src-or-srcdoc-change.html new file mode 100644 index 0000000000..a514730b9b --- /dev/null +++ b/Tests/LibWeb/Text/input/HTML/iframe-reload-on-src-or-srcdoc-change.html @@ -0,0 +1,97 @@ + + + diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index ed6b75c5bb..dd9a7d0600 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -39,8 +39,17 @@ JS::GCPtr HTMLIFrameElement::create_layout_node(NonnullRefPtr const& value) { HTMLElement::attribute_changed(name, value); - if (m_content_navigable) - process_the_iframe_attributes(); + + // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-iframe-element:process-the-iframe-attributes-2 + // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-iframe-element:process-the-iframe-attributes-3 + // Whenever an iframe element with a non-null content navigable has its srcdoc attribute set, changed, or removed, + // the user agent must process the iframe attributes. + // Similarly, whenever an iframe element with a non-null content navigable but with no srcdoc attribute specified + // has its src attribute set, changed, or removed, the user agent must process the iframe attributes. + if (m_content_navigable) { + if (name == AttributeNames::srcdoc || (name == AttributeNames::src && !has_attribute(AttributeNames::srcdoc))) + process_the_iframe_attributes(); + } } // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-iframe-element:the-iframe-element-6