From eafcd91760afbd0287b31aa6215c9528f6275b0d Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Wed, 17 Oct 2018 20:50:43 +0000 Subject: [PATCH 1/3] Assign a name to iframes when loading the initial about:blank Before, it would assign the name too late, causing scripts (which will not wait for another tick) to accidentally spawn pop-up windows instead of loading into the iframe. --- components/script/dom/htmliframeelement.rs | 20 ++++++------- tests/wpt/metadata/MANIFEST.json | 19 ++++++++++++ .../form-target-iframe-helper.py | 3 ++ .../form-target-iframe.html | 29 +++++++++++++++++++ 4 files changed, 61 insertions(+), 10 deletions(-) create mode 100644 tests/wpt/web-platform-tests/html/semantics/forms/form-submission-target/form-target-iframe-helper.py create mode 100644 tests/wpt/web-platform-tests/html/semantics/forms/form-submission-target/form-target-iframe.html 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 + + + + From 7270333487ace93b260205e0fddc252299ee4718 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 23 Oct 2018 00:53:55 +0000 Subject: [PATCH 2/3] Skip pop-up centric WPT test It was already broken, since Servo doesn't support pop-up windows. The iframe changes just made it broken in a different way. --- tests/wpt/metadata/MANIFEST.json | 2 +- .../targeting-cross-origin-nested-browsing-contexts.html.ini | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json index 7a77bc1e10b..2c8c667b379 100644 --- a/tests/wpt/metadata/MANIFEST.json +++ b/tests/wpt/metadata/MANIFEST.json @@ -615868,7 +615868,7 @@ "support" ], "html/semantics/forms/form-submission-target/form-target-iframe.html": [ - "8fd4d69c28ab1f569ae96453d02f48158124b4f9", + "2309ca67bb58f20f06a4c0b6ed162f2d0c80217f", "testharness" ], "html/semantics/forms/historical.html": [ diff --git a/tests/wpt/metadata/html/browsers/windows/targeting-cross-origin-nested-browsing-contexts.html.ini b/tests/wpt/metadata/html/browsers/windows/targeting-cross-origin-nested-browsing-contexts.html.ini index 4ee3fbb8304..8e0a7b687de 100644 --- a/tests/wpt/metadata/html/browsers/windows/targeting-cross-origin-nested-browsing-contexts.html.ini +++ b/tests/wpt/metadata/html/browsers/windows/targeting-cross-origin-nested-browsing-contexts.html.ini @@ -1,4 +1,5 @@ [targeting-cross-origin-nested-browsing-contexts.html] type: testharness + disabled: https://github.com/servo/servo/issues/10056 [Targeting nested browsing contexts] expected: FAIL From 10442ae894004ac18847793bc11bfa1c4653cb79 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Mon, 29 Oct 2018 18:52:40 +0000 Subject: [PATCH 3/3] Use `t.step_func` and expected path checking --- tests/wpt/metadata/MANIFEST.json | 2 +- .../form-submission-target/form-target-iframe.html | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json index 2c8c667b379..e3dd81d755a 100644 --- a/tests/wpt/metadata/MANIFEST.json +++ b/tests/wpt/metadata/MANIFEST.json @@ -615868,7 +615868,7 @@ "support" ], "html/semantics/forms/form-submission-target/form-target-iframe.html": [ - "2309ca67bb58f20f06a4c0b6ed162f2d0c80217f", + "f37bc33f6f93ca94940ffeb0066945eb9aa020ee", "testharness" ], "html/semantics/forms/historical.html": [ 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 index 2309ca67bb5..f37bc33f6f9 100644 --- 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 @@ -4,7 +4,7 @@