chore: fix ff tests with new events mode (#18708)

This commit is contained in:
Pavel Feldman 2022-11-10 12:59:27 -08:00 committed by GitHub
parent 6d456d30dc
commit ac25fdd74b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -89,8 +89,13 @@ export class BrowserContextDispatcher extends Dispatcher<BrowserContext, channel
this.addObjectListener(CRBrowserContext.CREvents.ServiceWorker, serviceWorker => this._dispatchEvent('serviceWorker', { worker: new WorkerDispatcher(this, serviceWorker) }));
}
this.addObjectListener(BrowserContext.Events.Request, (request: Request) => {
// Create dispatcher, if:
// - There are listeners to the requests.
// - We are redirected from a reported request so that redirectedTo was updated on client.
// - We are a navigation request and dispatcher will be reported as a part of the goto return value and newDocument param anyways.
// By the time requestFinished is triggered to update the request, we should have a request on the client already.
const redirectFromDispatcher = request.redirectedFrom() && existingDispatcher(request.redirectedFrom());
if (!redirectFromDispatcher && !this._shouldDispatchNetworkEvent(request, 'request'))
if (!redirectFromDispatcher && !this._shouldDispatchNetworkEvent(request, 'request') && !request.isNavigationRequest())
return;
const requestDispatcher = RequestDispatcher.from(this, request);
this._dispatchEvent('request', {