mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
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:
commit
2f8dc65519
5 changed files with 62 additions and 10 deletions
|
@ -217,6 +217,16 @@ impl HTMLIFrameElement {
|
||||||
|
|
||||||
let window = window_from_node(self);
|
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
|
// https://github.com/whatwg/html/issues/490
|
||||||
if mode == ProcessingMode::FirstTime &&
|
if mode == ProcessingMode::FirstTime &&
|
||||||
!self.upcast::<Element>().has_attribute(&local_name!("src"))
|
!self.upcast::<Element>().has_attribute(&local_name!("src"))
|
||||||
|
@ -233,16 +243,6 @@ impl HTMLIFrameElement {
|
||||||
return;
|
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();
|
let url = self.get_url();
|
||||||
|
|
||||||
// TODO: check ancestor browsing contexts for same URL
|
// TODO: check ancestor browsing contexts for same URL
|
||||||
|
|
|
@ -293185,6 +293185,11 @@
|
||||||
{}
|
{}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
"html/semantics/forms/form-submission-target/form-target-iframe-helper.py": [
|
||||||
|
[
|
||||||
|
{}
|
||||||
|
]
|
||||||
|
],
|
||||||
"html/semantics/forms/introduction-1/contains.json": [
|
"html/semantics/forms/introduction-1/contains.json": [
|
||||||
[
|
[
|
||||||
{}
|
{}
|
||||||
|
@ -368139,6 +368144,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": [
|
||||||
[
|
[
|
||||||
"/html/semantics/forms/historical.html",
|
"/html/semantics/forms/historical.html",
|
||||||
|
@ -617924,6 +617935,14 @@
|
||||||
"d05364387e62dfedc857628af833c3558ee3d1db",
|
"d05364387e62dfedc857628af833c3558ee3d1db",
|
||||||
"testharness"
|
"testharness"
|
||||||
],
|
],
|
||||||
|
"html/semantics/forms/form-submission-target/form-target-iframe-helper.py": [
|
||||||
|
"291221a9f6ba8876a022021c53c38ff28a3fd893",
|
||||||
|
"support"
|
||||||
|
],
|
||||||
|
"html/semantics/forms/form-submission-target/form-target-iframe.html": [
|
||||||
|
"f37bc33f6f93ca94940ffeb0066945eb9aa020ee",
|
||||||
|
"testharness"
|
||||||
|
],
|
||||||
"html/semantics/forms/historical.html": [
|
"html/semantics/forms/historical.html": [
|
||||||
"6873ecd251741fb8436a377081d5a6d3de53b7ab",
|
"6873ecd251741fb8436a377081d5a6d3de53b7ab",
|
||||||
"testharness"
|
"testharness"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
[targeting-cross-origin-nested-browsing-contexts.html]
|
[targeting-cross-origin-nested-browsing-contexts.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
|
disabled: https://github.com/servo/servo/issues/10056
|
||||||
[Targeting nested browsing contexts]
|
[Targeting nested browsing contexts]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
def main(request, response):
|
||||||
|
return ([("Content-Type", "text/plain")],
|
||||||
|
"OK")
|
|
@ -0,0 +1,29 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>Form targetted at iframe</title>
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script>
|
||||||
|
async_test(function(t) {
|
||||||
|
window.addEventListener("load", t.step_func(function() {
|
||||||
|
var frame = document.createElement("iframe");
|
||||||
|
frame.name = "frame";
|
||||||
|
document.documentElement.appendChild(frame);
|
||||||
|
var form = document.createElement("form");
|
||||||
|
form.target = "frame";
|
||||||
|
form.action = "form-target-iframe-helper.py";
|
||||||
|
form.method = "POST";
|
||||||
|
var input = document.createElement("input");
|
||||||
|
input.name = "n";
|
||||||
|
form.appendChild(input);
|
||||||
|
document.documentElement.appendChild(form);
|
||||||
|
form.submit();
|
||||||
|
frame.addEventListener("load", t.step_func(function() {
|
||||||
|
if (frame.contentWindow.location.href.includes("form-target-iframe-helper.py")) {
|
||||||
|
assert_equals(frame.contentWindow.document.body.textContent, "OK");
|
||||||
|
t.done();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}));
|
||||||
|
}, "Form targetted at iframe");
|
||||||
|
</script>
|
||||||
|
<body>
|
Loading…
Add table
Add a link
Reference in a new issue