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.
This commit is contained in:
Michael Howell 2018-10-17 20:50:43 +00:00
parent aa9591137a
commit eafcd91760
4 changed files with 61 additions and 10 deletions

View file

@ -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