Can't close window if website cancels beforeunload event

Author: yishnCreated Jul 25, 2017Updated Sep 20, 2023
Labelsbug

Description

Normal browsers show a confirmation dialog if the website tries to cancel the beforeunload event. The user can decide for himself whether to close the window anyway or stay on it. Nativefier simply doesn't close the window if the event is cancelled and it becomes impossible to close the window without force.

Steps to reproduce issue

xml
<!-- Serve at http://localhost:8080 -->
<!DOCTYPE html>
<html>
<body>
<script>
    window.addEventListener('beforeunload', evt => {
        evt.returnValue = 'Cancel'
        return 'Cancel'
    })
</script>
</body>
</html>

Details

  • Are you nativefying a public website? No
  • Feature request? Have you looked at nativefier --help to see if an existing option could fit your needs? Yes
  • Full nativefier command used to build your app: nativefier http://localhost:8080
  • Version of Nativefier (run nativefier --version): v7.4.2
  • Version of node.js (run node --version): v8.1.4
  • OS: Windows 10
  • Error message / stack trace (if any): None