window.close() stop working after window.location.assign()
Categories
(Core :: DOM: Window and Location, defect)
Tracking
()
People
(Reporter: chenkaichn, Unassigned)
Details
Attachments
(1 file)
976 bytes,
text/x-python-script
|
Details |
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36
Steps to reproduce:
Here's a demo app using flask which can help reproduce the bug. Steps to repro
- Save code below to to flask-app.py, and start the app with "flask --app flask-app run"
- Open the app from the url in the console, like http://127.0.0.1:5000
- Click on the "Open popup assign" button, it will open a popup
- In the popup, click the "Assign Location" button, it will redirect to google.com
- Open the dev console for popup window, run window.close(). The popup refuse to close
The demo app also shows a similar case using window.location.replace which doesn't break window.close().
I also attached video for the demo.
from flask import Flask
app = Flask(name)
@app.route("/")
def index():
return """
<script>
function openPopup1() {
window.open("/popup1", "Popup1", "height=600,width=450,top=100,left=1055");
}
function openPopup2() {
window.open("/popup2", "Popup2", "height=600,width=450,top=100,left=1055");
}
</script>
<button onclick="openPopup1()"> Open popup assign </button>
<button onclick="openPopup2()"> Open popup replace </button>
"""
@app.route("/popup1")
def popup_first():
return (
"<script> assignLocation = () =>"
" {window.location.assign('https://google.com');} </script>"
+ "<button onclick='assignLocation()'>Assign Location</button>"
)
@app.route("/popup2")
def popup_second():
return (
"<script> assignLocation = () =>"
" {window.location.replace('https://google.com');} </script>"
+ "<button onclick='assignLocation()'>Replace Location </button>"
)
Actual results:
Popup window opened by Javascript can't be closed after window.location.assign call.
Expected results:
It should still be closed by window.close() as the window is opened by Javascript. Both Chrome and Safari closes it in such scenario.
Reporter | ||
Comment 1•1 year ago
|
||
Reporter | ||
Comment 2•1 year ago
|
||
I included the code in an attachment for better format, and here's the link to the video demo https://youtu.be/ClOqtx6rFGY
Comment 3•1 year ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::DOM: Geolocation' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Updated•1 year ago
|
Updated•1 year ago
|
Comment 4•1 year ago
|
||
Confirmed on 117 and 119 Nightly. Attempting to call window.close()
from the console gives a "Scripts may not close windows that were not opened by script." warning message and fails to close the popup.
Updated•1 year ago
|
Description
•