mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix(webdriver): wait for response if the response has not completed once navigation has finished (#12018)
This commit is contained in:
parent
11a6d7e58d
commit
6d8831a9c3
@ -40,6 +40,8 @@ import {debugError, fromEmitterEvent, timeout} from '../common/util.js';
|
||||
|
||||
import {BidiCdpSession} from './CDPSession.js';
|
||||
import type {BrowsingContext} from './core/BrowsingContext.js';
|
||||
import type {Navigation} from './core/Navigation.js';
|
||||
import type {Request} from './core/Request.js';
|
||||
import {BidiDeserializer} from './Deserializer.js';
|
||||
import {BidiDialog} from './Dialog.js';
|
||||
import type {BidiElementHandle} from './ElementHandle.js';
|
||||
@ -360,8 +362,34 @@ export class BidiFrame extends Frame {
|
||||
})
|
||||
)
|
||||
),
|
||||
map(() => {
|
||||
return navigation;
|
||||
switchMap(() => {
|
||||
if (navigation.request) {
|
||||
function requestFinished$(
|
||||
request: Request
|
||||
): Observable<Navigation> {
|
||||
// Reduces flakiness if the response events arrive after
|
||||
// the load event.
|
||||
// Usually, the response or error is already there at this point.
|
||||
if (request.response || request.error) {
|
||||
return of(navigation);
|
||||
}
|
||||
if (request.redirect) {
|
||||
return requestFinished$(request.redirect);
|
||||
}
|
||||
return fromEmitterEvent(request, 'success')
|
||||
.pipe(
|
||||
raceWith(fromEmitterEvent(request, 'error')),
|
||||
raceWith(fromEmitterEvent(request, 'redirect'))
|
||||
)
|
||||
.pipe(
|
||||
switchMap(() => {
|
||||
return requestFinished$(request);
|
||||
})
|
||||
);
|
||||
}
|
||||
return requestFinished$(navigation.request);
|
||||
}
|
||||
return of(navigation);
|
||||
})
|
||||
);
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user