Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit 0592242

Browse files
committed
Update dialog handling for beforeunload
A dialog box of type beforeunload seems to only be dismissable if we accept. This is the same solution as what playwright are doing.
1 parent 94271d2 commit 0592242

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

common/frame_session.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,10 @@ func (fs *FrameSession) onEventJavascriptDialogOpening(event *cdppage.EventJavas
273273
fs.session.ID(), fs.targetID, event.URL, event.Type)
274274

275275
action := cdppage.HandleJavaScriptDialog(false)
276+
if event.Type == cdppage.DialogTypeBeforeunload {
277+
action = cdppage.HandleJavaScriptDialog(true)
278+
}
279+
276280
if err := action.Do(cdp.WithExecutor(fs.ctx, fs.session)); err != nil {
277281
fs.logger.Errorf("FrameSession:onEventJavascriptDialogOpening", "failed to dismiss dialog box: %v", err)
278282
}

0 commit comments

Comments
 (0)