(cherry picked from commit 4fe66b298d
)
This commit is contained in:
parent
595f0abf3d
commit
d92860c49d
|
@ -531,6 +531,23 @@ describe('main/windows/callsWidgetWindow', () => {
|
|||
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', () => {
|
||||
baseWindow.webContents = {
|
||||
...baseWindow.webContents,
|
||||
|
|
|
@ -243,6 +243,7 @@ export default class CallsWidgetWindow extends EventEmitter {
|
|||
|
||||
private onPopOutCreate = (win: BrowserWindow) => {
|
||||
this.popOut = win;
|
||||
this.popOut.on('closed', this.onPopOutClosed);
|
||||
|
||||
// Let the webContentsEventManager handle links that try to open a new window.
|
||||
webContentsEventManager.addWebContentsEventListeners(this.popOut.webContents);
|
||||
|
@ -251,6 +252,12 @@ export default class CallsWidgetWindow extends EventEmitter {
|
|||
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
|
||||
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.
|
||||
|
@ -273,7 +280,7 @@ export default class CallsWidgetWindow extends EventEmitter {
|
|||
}
|
||||
|
||||
public getPopOutWebContentsId() {
|
||||
return this.popOut?.webContents.id;
|
||||
return this.popOut?.webContents?.id;
|
||||
}
|
||||
|
||||
public getURL() {
|
||||
|
|
Loading…
Reference in a new issue