emit on page, even if we don't know what's the correct one

This commit is contained in:
Simon Knott 2025-01-27 14:28:27 +01:00
parent 694931a44d
commit 4887ca6750
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC

View file

@ -229,11 +229,11 @@ export class BrowserContext extends ChannelOwner<channels.BrowserContextChannel>
}
private _onRouteListener = ({ route, browserRequest }: { route: network.Route, browserRequest?: network.Request }) => {
const page = browserRequest?._safePage();
if (page)
page._onRoute(route);
else
this._onRoute(route);
const subject =
browserRequest?._safePage()
?? this.pages()[0] // Fallback to the first page if no page is associated with the request. This should be the `page` fixture.
?? this;
subject._onRoute(route);
};
async _onWebSocketRoute(webSocketRoute: network.WebSocketRoute) {