refactor: Pass FrameManager to NetworkManager constructor (#4907)
This commit is contained in:
parent
73fd7ff822
commit
c2651c2b5c
@ -35,8 +35,7 @@ class FrameManager extends EventEmitter {
|
||||
super();
|
||||
this._client = client;
|
||||
this._page = page;
|
||||
this._networkManager = new NetworkManager(client, ignoreHTTPSErrors);
|
||||
this._networkManager.setFrameManager(this);
|
||||
this._networkManager = new NetworkManager(client, ignoreHTTPSErrors, this);
|
||||
this._timeoutSettings = timeoutSettings;
|
||||
/** @type {!Map<string, !Frame>} */
|
||||
this._frames = new Map();
|
||||
|
@ -20,12 +20,13 @@ const {Events} = require('./Events');
|
||||
class NetworkManager extends EventEmitter {
|
||||
/**
|
||||
* @param {!Puppeteer.CDPSession} client
|
||||
* @param {!Puppeteer.FrameManager} frameManager
|
||||
*/
|
||||
constructor(client, ignoreHTTPSErrors) {
|
||||
constructor(client, ignoreHTTPSErrors, frameManager) {
|
||||
super();
|
||||
this._client = client;
|
||||
this._ignoreHTTPSErrors = ignoreHTTPSErrors;
|
||||
this._frameManager = null;
|
||||
this._frameManager = frameManager;
|
||||
/** @type {!Map<string, !Request>} */
|
||||
this._requestIdToRequest = new Map();
|
||||
/** @type {!Map<string, !Protocol.Network.requestWillBeSentPayload>} */
|
||||
@ -60,13 +61,6 @@ class NetworkManager extends EventEmitter {
|
||||
await this._client.send('Security.setIgnoreCertificateErrors', {ignore: true});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {!Puppeteer.FrameManager} frameManager
|
||||
*/
|
||||
setFrameManager(frameManager) {
|
||||
this._frameManager = frameManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?{username: string, password: string}} credentials
|
||||
*/
|
||||
@ -234,7 +228,7 @@ class NetworkManager extends EventEmitter {
|
||||
redirectChain = request._redirectChain;
|
||||
}
|
||||
}
|
||||
const frame = event.frameId && this._frameManager ? this._frameManager.frame(event.frameId) : null;
|
||||
const frame = event.frameId ? this._frameManager.frame(event.frameId) : null;
|
||||
const request = new Request(this._client, frame, interceptionId, this._userRequestInterceptionEnabled, event, redirectChain);
|
||||
this._requestIdToRequest.set(event.requestId, request);
|
||||
this.emit(Events.NetworkManager.Request, request);
|
||||
|
Loading…
Reference in New Issue
Block a user