Skip to content

Is beforeunload fired in all cases? #8395

Open

Description

@domenic

Based on some initial tests in web-platform-tests/wpt#36488, in Chrome and Safari navigating or traversing to a javascript: URL does not fire beforeunload. Whereas in Firefox it does fire.

In the current spec all navigations and traversals fire beforeunload, whereas in the current state of the rewrite (#6315) only those which require a fetch will do so. So the following are the tricky cases:

  • javascript: URLs
  • srcdoc resources
  • embed/object
  • non-fetch scheme documents

Activity

  1. smaug---- commented on Oct 17, 2022

    @smaug----

    It would be rather surprising if beforeunload behavior was bound to fetch. beforeunload, as the name hints, is about unloading the current page before something replaces it.

  2. domenic commented on Oct 17, 2022

    @domenic
    MemberAuthor

    I can see that reasoning, but, (a) requiring waiting on cross-process messages for what would otherwise be very simple navigations is not great; and (b) beforeunload is generally bad, so the less of it we fire, the better IMO. If it's already not fired in 2/3 browsers in these cases, I'm inclined to spec that behavior.

    This is pending some test results for the non-javascript: cases, though.

  3. added a commit that references this issue on Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions