File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -65,8 +65,11 @@ export class DialogManager extends SessionManager {
6565 context : log . context
6666 } )
6767 } catch ( err ) {
68- // ignore error if dialog is already closed
69- if ( err instanceof Error && err . message . includes ( 'no such alert' ) ) {
68+ // ignore race conditions when the dialog/context is gone before auto-dismiss runs
69+ if (
70+ err instanceof Error &&
71+ ( err . message . includes ( 'no such alert' ) || err . message . includes ( 'no such frame' ) )
72+ ) {
7073 return
7174 }
7275 throw err
Original file line number Diff line number Diff line change @@ -62,4 +62,21 @@ describe('DialogManager', () => {
6262
6363 await expect ( userPromptHandler ( log ) ) . rejects . toThrow ( msg )
6464 } )
65+
66+ it ( 'should ignore "no such frame" error when context is gone' , async ( ) => {
67+ const log = { context : 'some-context' } as any
68+ browser . browsingContextHandleUserPrompt . mockRejectedValue (
69+ new Error ( 'no such frame - Context some-context not found' )
70+ )
71+
72+ const calls = browser . on . mock . calls
73+ const userPromptHandler = calls . find ( ( call : unknown [ ] ) => call [ 0 ] === 'browsingContext.userPromptOpened' ) ?. [ 1 ]
74+
75+ expect ( userPromptHandler ) . toBeDefined ( )
76+ await expect ( userPromptHandler ( log ) ) . resolves . toBeUndefined ( )
77+ expect ( browser . browsingContextHandleUserPrompt ) . toHaveBeenCalledWith ( {
78+ accept : false ,
79+ context : 'some-context'
80+ } )
81+ } )
6582} )
You can’t perform that action at this time.
0 commit comments