Skip to content

Commit a6474d5

Browse files
committed
chore: register frameless listeners separately (#4407)
1 parent d8d4f83 commit a6474d5

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/server/chromium/crPage.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,8 @@ class FrameSession {
352352
return this._targetId === this._crPage._targetId;
353353
}
354354

355-
private _addSessionListeners() {
356-
this._eventListeners = [
357-
helper.addEventListener(this._client, 'Inspector.targetCrashed', event => this._onTargetCrashed()),
355+
private _addRendererListeners() {
356+
this._eventListeners.push(...[
358357
helper.addEventListener(this._client, 'Log.entryAdded', event => this._onLogEntryAdded(event)),
359358
helper.addEventListener(this._client, 'Page.fileChooserOpened', event => this._onFileChooserOpened(event)),
360359
helper.addEventListener(this._client, 'Page.frameAttached', event => this._onFrameAttached(event.frameId, event.parentFrameId)),
@@ -364,9 +363,6 @@ class FrameSession {
364363
helper.addEventListener(this._client, 'Page.frameStoppedLoading', event => this._onFrameStoppedLoading(event.frameId)),
365364
helper.addEventListener(this._client, 'Page.javascriptDialogOpening', event => this._onDialog(event)),
366365
helper.addEventListener(this._client, 'Page.navigatedWithinDocument', event => this._onFrameNavigatedWithinDocument(event.frameId, event.url)),
367-
helper.addEventListener(this._client, 'Page.downloadWillBegin', event => this._onDownloadWillBegin(event)),
368-
helper.addEventListener(this._client, 'Page.downloadProgress', event => this._onDownloadProgress(event)),
369-
helper.addEventListener(this._client, 'Page.screencastFrame', event => this._onScreencastFrame(event)),
370366
helper.addEventListener(this._client, 'Runtime.bindingCalled', event => this._onBindingCalled(event)),
371367
helper.addEventListener(this._client, 'Runtime.consoleAPICalled', event => this._onConsoleAPI(event)),
372368
helper.addEventListener(this._client, 'Runtime.exceptionThrown', exception => this._handleException(exception.exceptionDetails)),
@@ -375,8 +371,17 @@ class FrameSession {
375371
helper.addEventListener(this._client, 'Runtime.executionContextsCleared', event => this._onExecutionContextsCleared()),
376372
helper.addEventListener(this._client, 'Target.attachedToTarget', event => this._onAttachedToTarget(event)),
377373
helper.addEventListener(this._client, 'Target.detachedFromTarget', event => this._onDetachedFromTarget(event)),
374+
]);
375+
}
376+
377+
private _addBrowserListeners() {
378+
this._eventListeners.push(...[
379+
helper.addEventListener(this._client, 'Inspector.targetCrashed', event => this._onTargetCrashed()),
380+
helper.addEventListener(this._client, 'Page.downloadWillBegin', event => this._onDownloadWillBegin(event)),
381+
helper.addEventListener(this._client, 'Page.downloadProgress', event => this._onDownloadProgress(event)),
382+
helper.addEventListener(this._client, 'Page.screencastFrame', event => this._onScreencastFrame(event)),
378383
helper.addEventListener(this._client, 'Page.windowOpen', event => this._onWindowOpen(event)),
379-
];
384+
]);
380385
}
381386

382387
async _initialize(hasUIWindow: boolean) {
@@ -388,13 +393,14 @@ class FrameSession {
388393
}
389394
let lifecycleEventsEnabled: Promise<any>;
390395
if (!this._isMainFrame())
391-
this._addSessionListeners();
396+
this._addRendererListeners();
397+
this._addBrowserListeners();
392398
const promises: Promise<any>[] = [
393399
this._client.send('Page.enable'),
394400
this._client.send('Page.getFrameTree').then(({frameTree}) => {
395401
if (this._isMainFrame()) {
396402
this._handleFrameTree(frameTree);
397-
this._addSessionListeners();
403+
this._addRendererListeners();
398404
}
399405
const localFrames = this._isMainFrame() ? this._page.frames() : [ this._page._frameManager.frame(this._targetId)! ];
400406
for (const frame of localFrames) {

0 commit comments

Comments
 (0)