diff --git a/lib/FrameManager.js b/lib/FrameManager.js index 4f0fa6056dc72..fea03dc2c033e 100644 --- a/lib/FrameManager.js +++ b/lib/FrameManager.js @@ -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} */ this._frames = new Map(); diff --git a/lib/NetworkManager.js b/lib/NetworkManager.js index 42593f1cef673..30534ccd35452 100644 --- a/lib/NetworkManager.js +++ b/lib/NetworkManager.js @@ -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} */ this._requestIdToRequest = new Map(); /** @type {!Map} */ @@ -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);