Safari 14 opens an extra blank window when submitting FORM
When we use window.open to open a new tab and then use FORM to redirect the new tab to a new link, if we set new tab's opener to null, then there will be an extra empty tab opened in Safari.
For example, we can save below HTML content to a HTML file and open it in Safari, then click the Test button, we can see this issue.
<html>
<head>
<title>Test</title>
</head>
<body>
<script>
function openlink() {
var newTab = window.open("", "abcd");
newTab.opener = null;
var form = document.createElement('form');
form.action="https://www.apple.com";
form.method="POST";
form.target="abcd";
form.id="form123";
document.body.appendChild(form);
form.submit();
}
</script>
<button onclick="openlink()">test</button>
</body>
</html>
The reasons I consider this as an issue are:
- Safari 11 doesn't have this issue. I don't have environments for Safari 12 and 13 so I cannot tell the extra version that this issue is introduced.
- It seems that Safari will do an extra check for newTab.opener before submitting the form. However, if we don't set newTab.opener to null, there will be security concerns about Tabnabbing, the target page can control the original page. So if hackers inject some scripts in the target page, they can control source page's content.
Please help review. Thanks.
MacBook Pro 15″, macOS 10.15