fix(webkit): swallow requests from detached frames (#6242)

This commit is contained in:
Joel Einbinder 2021-05-03 12:34:09 -07:00 committed by GitHub
parent fd4253991f
commit 6219042c74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -898,7 +898,12 @@ export class WKPage implements PageDelegate {
redirectedFrom = request.request;
}
}
const frame = this._page._frameManager.frame(event.frameId)!;
const frame = redirectedFrom ? redirectedFrom.frame() : this._page._frameManager.frame(event.frameId);
// sometimes we get stray network events for detached frames
// TODO(einbinder) why?
if (!frame)
return;
// TODO(einbinder) this will fail if we are an XHR document request
const isNavigationRequest = event.type === 'Document';
const documentId = isNavigationRequest ? event.loaderId : undefined;
@ -919,8 +924,10 @@ export class WKPage implements PageDelegate {
_onRequestIntercepted(event: Protocol.Network.requestInterceptedPayload) {
const request = this._requestIdToRequest.get(event.requestId);
if (!request)
if (!request) {
this._session.sendMayFail('Network.interceptRequestWithError', {errorType: 'Cancellation', requestId: event.requestId});
return;
}
if (!request._allowInterception) {
// Intercepted, although we do not intend to allow interception.
// Just continue.