Skip to content

Conversation

@winst0niuss
Copy link
Contributor

Fixes #2752

When closing the browser, if a page has a beforeunload event handler, Taiko would crash with the error:
There is no handler registered for beforeunload popup displayed on the page

This PR adds a flag-based mechanism to automatically accept beforeunload dialogs during browser closure, preventing the crash while still allowing explicit beforeunload handling during normal operation.

Changes

  • Added isClosingBrowser flag in pageHandler.js to track browser closure state
  • Modified addJavascriptDialogOpeningListener() to auto-accept beforeunload dialogs when closing
  • Updated closeConnection() in connection.js to set/reset the flag
  • Used fire-and-forget pattern (no await) to avoid blocking on Windows

When closing the browser, if a page has a beforeunload event handler,
Taiko would crash with 'There is no handler registered for beforeunload popup'.

This fix adds a flag to automatically accept beforeunload dialogs during
browser closure, preventing the crash while still allowing explicit
beforeunload handling during normal operation.

Fixes getgauge#2752

Signed-off-by: winst0niuss <chumachenko.vadym@gmail.com>
@winst0niuss winst0niuss mentioned this pull request Nov 24, 2025
@zabil zabil merged commit 21c8f27 into getgauge:master Nov 26, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

CloseBrowser crashes when page throws the leave site pop up after calling closeBrowser()

2 participants