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