[Webkit-unassigned] [Bug 255837] New: Calling `event.preventDefault()` for the `beforeunload` event does prevent the page from unloading.
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Sat Apr 22 22:06:11 PDT 2023
https://bugs.webkit.org/show_bug.cgi?id=255837
Bug ID: 255837
Summary: Calling `event.preventDefault()` for the
`beforeunload` event does prevent the page from
unloading.
Product: WebKit
Version: Safari 16
Hardware: All
OS: All
Status: NEW
Severity: Blocker
Priority: P2
Component: Page Loading
Assignee: webkit-unassigned at lists.webkit.org
Reporter: chewteeming01 at gmail.com
CC: beidson at apple.com
Created attachment 466050
--> https://bugs.webkit.org/attachment.cgi?id=466050&action=review
The HTML file contains a link that should be intercepted by the beforeunload event.
Summary:
Calling `event.preventDefault()` when listening to a `beforeunload` event on the `window` should rightly prompt the user if they want to stay or leave the page. This is currently broken in macOS Safari 16.4.
OS:
I have tested this issue on both iOS Safari 16.4.1 and macOS Safari Version 16.4 (18615.1.26.11.23).
Steps to reproduce:
An example page such as https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onbeforeunload will not work on iOS, but will still work on macOS (it only works on macOS because the unload event is contained in an iframe.)
I have attached a sample HTML file that can be opened in a Webkit browser. Clicking on the link should prompt the user with an alert. The code was copied from the example provided by W3Schools.
Actual results:
The browser navigates to the link normally.
Expected results:
The browser prompts the user with an alert to stay or leave the page before navigating to the new page.
Build Date & Hardware:
Apple M1 Pro
macOS 13.3.1 (22E261)
Additional information:
I first noticed this issue during some cross-browser tests for cancelling the `beforeunload` event. Only Safari was failing the tests at the time so I started to investigate. The PR with those cross-browser tests can be found here: https://github.com/sveltejs/kit/pull/9747
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20230423/d773b9d0/attachment.htm>
More information about the webkit-unassigned
mailing list