Properly cleanup FrameManager._frameIdToExecutionContextId. (#73)

This commit is contained in:
Aleksey 2017-07-11 21:52:09 -07:00 committed by Andrey Lushnikov
parent ff838d8e83
commit b77ae4b77c

View File

@ -45,7 +45,6 @@ class FrameManager extends EventEmitter {
this._client.on('Page.frameNavigated', event => this._onFrameNavigated(event.frame));
this._client.on('Page.frameDetached', event => this._onFrameDetached(event.frameId));
this._client.on('Runtime.executionContextCreated', event => this._onExecutionContextCreated(event.context));
this._client.on('Runtime.executionContextDestroyed', event => this._onExecutionContextDestroyed(event.executionContextId));
}
/**
@ -109,10 +108,6 @@ class FrameManager extends EventEmitter {
this._frameIdToExecutionContextId.set(context.auxData.frameId, context.id);
}
_onExecutionContextDestroyed(executionContextId) {
this._frameIdToExecutionContextId.delete(executionContextId);
}
/**
* @param {!Frame} frame
* @param {string} newFrameId
@ -123,6 +118,7 @@ class FrameManager extends EventEmitter {
for (let child of frame.childFrames())
this._removeFramesRecursively(child);
this._frames.delete(frame._id, frame);
this._frameIdToExecutionContextId.delete(frame._id);
frame._id = newFrameId;
frame._adoptPayload(newFramePayload);
this._frames.set(newFrameId, frame);
@ -152,6 +148,7 @@ class FrameManager extends EventEmitter {
this._removeFramesRecursively(child);
frame._detach();
this._frames.delete(frame._id);
this._frameIdToExecutionContextId.delete(frame._id);
this.emit(FrameManager.Events.FrameDetached, frame);
}