MM-51850 - Calls: Fix for crash after closing popout (#2647)
This commit is contained in:

committed by
GitHub

parent
a6f153b55a
commit
4fe66b298d
@@ -531,6 +531,23 @@ describe('main/windows/callsWidgetWindow', () => {
|
|||||||
expect(popOut.webContents.on).toHaveBeenCalledWith('will-redirect', widgetWindow.onWillRedirect);
|
expect(popOut.webContents.on).toHaveBeenCalledWith('will-redirect', widgetWindow.onWillRedirect);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('onPopOutClosed', () => {
|
||||||
|
const widgetWindow = new CallsWidgetWindow(mainWindow, mainView, widgetConfig);
|
||||||
|
expect(widgetWindow.popOut).toBeNull();
|
||||||
|
|
||||||
|
const popOut = new EventEmitter();
|
||||||
|
popOut.webContents = {
|
||||||
|
on: jest.fn(),
|
||||||
|
id: 'webContentsId',
|
||||||
|
};
|
||||||
|
|
||||||
|
widgetWindow.onPopOutCreate(popOut);
|
||||||
|
expect(widgetWindow.popOut).toBe(popOut);
|
||||||
|
|
||||||
|
popOut.emit('closed');
|
||||||
|
expect(widgetWindow.popOut).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
it('getWebContentsId', () => {
|
it('getWebContentsId', () => {
|
||||||
baseWindow.webContents = {
|
baseWindow.webContents = {
|
||||||
...baseWindow.webContents,
|
...baseWindow.webContents,
|
||||||
|
@@ -243,6 +243,7 @@ export default class CallsWidgetWindow extends EventEmitter {
|
|||||||
|
|
||||||
private onPopOutCreate = (win: BrowserWindow) => {
|
private onPopOutCreate = (win: BrowserWindow) => {
|
||||||
this.popOut = win;
|
this.popOut = win;
|
||||||
|
this.popOut.on('closed', this.onPopOutClosed);
|
||||||
|
|
||||||
// Let the webContentsEventManager handle links that try to open a new window.
|
// Let the webContentsEventManager handle links that try to open a new window.
|
||||||
webContentsEventManager.addWebContentsEventListeners(this.popOut.webContents);
|
webContentsEventManager.addWebContentsEventListeners(this.popOut.webContents);
|
||||||
@@ -251,6 +252,12 @@ export default class CallsWidgetWindow extends EventEmitter {
|
|||||||
this.popOut.webContents.on('will-redirect', this.onWillRedirect);
|
this.popOut.webContents.on('will-redirect', this.onWillRedirect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private onPopOutClosed = () => {
|
||||||
|
log.debug('CallsWidgetWindow.onPopOutClosed');
|
||||||
|
this.popOut?.removeAllListeners('closed');
|
||||||
|
this.popOut = null;
|
||||||
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
private onWillRedirect = (event: Event, url: string) => {
|
private onWillRedirect = (event: Event, url: string) => {
|
||||||
// There's no reason we would allow a redirect from the call's popout. Eventually we may, so revise then.
|
// There's no reason we would allow a redirect from the call's popout. Eventually we may, so revise then.
|
||||||
@@ -273,7 +280,7 @@ export default class CallsWidgetWindow extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getPopOutWebContentsId() {
|
public getPopOutWebContentsId() {
|
||||||
return this.popOut?.webContents.id;
|
return this.popOut?.webContents?.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getURL() {
|
public getURL() {
|
||||||
|
Reference in New Issue
Block a user