chore: waitForNavigation should fail if navigation aborts or fails (#11914)

This commit is contained in:
jrandolf 2024-02-15 09:16:46 +01:00 committed by GitHub
parent 634d5b805d
commit bd4d0febf0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -309,7 +309,19 @@ export class BidiFrame extends Frame {
fromEmitterEvent(this.browsingContext, 'navigation').pipe(
switchMap(({navigation}) => {
return this.#waitForLoad$(options).pipe(
raceWith(fromEmitterEvent(navigation, 'fragment')),
raceWith(
fromEmitterEvent(navigation, 'fragment'),
fromEmitterEvent(navigation, 'failed').pipe(
map(({url}) => {
throw new Error(`Navigation failed: ${url}`);
})
),
fromEmitterEvent(navigation, 'aborted').pipe(
map(({url}) => {
throw new Error(`Navigation aborted: ${url}`);
})
)
),
map(() => {
return navigation;
})