Auto merge of #21976 - notriddle:iframe-target-form-race, r=jdm

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.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #21886
- [x] There are tests for these changes

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21976)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-10-29 15:29:31 -04:00 committed by GitHub
commit 2f8dc65519
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 62 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