The beforeunload dialog will only be shown if the frame attempting to display it has received a user gesture or user interaction (or if any embedded frame has received such a gesture). (There will be no change to the dispatch of the beforeunload event, just a change to whether the dialog is shown.)
Docs: https://developer.mozilla.org/en-US/docs/Web/API/BeforeUnloadEvent