aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmliframeelement.rs
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2018-10-17 20:50:43 +0000
committerMichael Howell <michael@notriddle.com>2018-10-19 00:21:06 +0000
commiteafcd91760afbd0287b31aa6215c9528f6275b0d (patch)
treeeab41f475159daf9fa1a5b56a412a2e8c8fa6eba /components/script/dom/htmliframeelement.rs
parentaa9591137a0a583c4b4718f4038545a860fbaeee (diff)
downloadservo-eafcd91760afbd0287b31aa6215c9528f6275b0d.tar.gz
servo-eafcd91760afbd0287b31aa6215c9528f6275b0d.zip
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.
Diffstat (limited to 'components/script/dom/htmliframeelement.rs')
-rw-r--r--components/script/dom/htmliframeelement.rs20
1 files changed, 10 insertions, 10 deletions
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::<Element>().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