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

@ -0,0 +1,3 @@
def main(request, response):
return ([("Content-Type", "text/plain")],
"OK")

View file

@ -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", 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", function() {
if (frame.contentWindow.location.href != "about:blank") {
assert_equals(frame.contentWindow.document.body.textContent, "OK");
t.done();
}
});
});
}, "Form targetted at iframe");
</script>
<body>