diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs
index 3c37c97af4c..c44ed04b265 100644
--- a/components/script/dom/htmliframeelement.rs
+++ b/components/script/dom/htmliframeelement.rs
@@ -217,6 +217,16 @@ impl HTMLIFrameElement {
let window = window_from_node(self);
+ // https://html.spec.whatwg.org/multipage/#attr-iframe-name
+ // Note: the spec says to set the name 'when the nested browsing context is created'.
+ // The current implementation sets the name on the window,
+ // when the iframe attributes are first processed.
+ if mode == ProcessingMode::FirstTime {
+ if let Some(window) = self.GetContentWindow() {
+ window.set_name(self.name.borrow().clone())
+ }
+ }
+
// https://github.com/whatwg/html/issues/490
if mode == ProcessingMode::FirstTime &&
!self.upcast::().has_attribute(&local_name!("src"))
@@ -233,16 +243,6 @@ impl HTMLIFrameElement {
return;
}
- // https://html.spec.whatwg.org/multipage/#attr-iframe-name
- // Note: the spec says to set the name 'when the nested browsing context is created'.
- // The current implementation sets the name on the window,
- // when the iframe attributes are first processed.
- if mode == ProcessingMode::FirstTime {
- if let Some(window) = self.GetContentWindow() {
- window.set_name(self.name.borrow().clone())
- }
- }
-
let url = self.get_url();
// TODO: check ancestor browsing contexts for same URL
diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json
index 8a1d43ea750..7a77bc1e10b 100644
--- a/tests/wpt/metadata/MANIFEST.json
+++ b/tests/wpt/metadata/MANIFEST.json
@@ -292331,6 +292331,11 @@
{}
]
],
+ "html/semantics/forms/form-submission-target/form-target-iframe-helper.py": [
+ [
+ {}
+ ]
+ ],
"html/semantics/forms/introduction-1/contains.json": [
[
{}
@@ -366881,6 +366886,12 @@
{}
]
],
+ "html/semantics/forms/form-submission-target/form-target-iframe.html": [
+ [
+ "/html/semantics/forms/form-submission-target/form-target-iframe.html",
+ {}
+ ]
+ ],
"html/semantics/forms/historical.html": [
[
"/html/semantics/forms/historical.html",
@@ -615852,6 +615863,14 @@
"d05364387e62dfedc857628af833c3558ee3d1db",
"testharness"
],
+ "html/semantics/forms/form-submission-target/form-target-iframe-helper.py": [
+ "291221a9f6ba8876a022021c53c38ff28a3fd893",
+ "support"
+ ],
+ "html/semantics/forms/form-submission-target/form-target-iframe.html": [
+ "8fd4d69c28ab1f569ae96453d02f48158124b4f9",
+ "testharness"
+ ],
"html/semantics/forms/historical.html": [
"6873ecd251741fb8436a377081d5a6d3de53b7ab",
"testharness"
diff --git a/tests/wpt/web-platform-tests/html/semantics/forms/form-submission-target/form-target-iframe-helper.py b/tests/wpt/web-platform-tests/html/semantics/forms/form-submission-target/form-target-iframe-helper.py
new file mode 100644
index 00000000000..291221a9f6b
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/forms/form-submission-target/form-target-iframe-helper.py
@@ -0,0 +1,3 @@
+def main(request, response):
+ return ([("Content-Type", "text/plain")],
+ "OK")
diff --git a/tests/wpt/web-platform-tests/html/semantics/forms/form-submission-target/form-target-iframe.html b/tests/wpt/web-platform-tests/html/semantics/forms/form-submission-target/form-target-iframe.html
new file mode 100644
index 00000000000..2309ca67bb5
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/forms/form-submission-target/form-target-iframe.html
@@ -0,0 +1,29 @@
+
+Form targetted at iframe
+
+
+
+