onbeforeunload fires twice when closing a page with window.close()
Reported by
benjamin...@gmail.com,
Apr 20 2017
|
||||
Issue description
UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
Steps to reproduce the problem:
1. Create this page
<!doctype html>
<button onclick="window.open(window.location.href);">open</button>
<button onclick="window.close();">close</button>
<script>
window.onunload = function () {
console.log('onunload');
};
window.onbeforeunload = function () {
console.log('onbeforeunload');
}
</script>
2. Navigate to the page, and click the open button to open a new page via JS (to avoid getting the "Scripts may close only the windows that were opened by it." warning)
3. From the child page, put breakpoints in the onunload and onbeforeunload functions
4. From the child page, click the close button. It will hit the onbeforeunload function twice, writing "onbeforeunload" twice to the console before running the onunload function
What is the expected behavior?
It should only run the onbeforeunload function once, the same as it does if you close the window by clicking the X next to the tab name
What went wrong?
onbeforeunload ran twice instead of once
Did this work before? N/A
Chrome version: 57.0.2987.133 Channel: stable
OS Version: OS X 10.12.4
Flash Version:
,
Apr 24 2017
,
Apr 25 2017
DOM team maybe? Loading?
,
Aug 28 2017
tzik@, is this something you're familiar with? |
||||
►
Sign in to add a comment |
||||
Comment 1 by kojii@chromium.org
, Apr 21 2017