diff --git a/src/main/windows/windowManager.test.js b/src/main/windows/windowManager.test.js index f9ae84d9..77751b2f 100644 --- a/src/main/windows/windowManager.test.js +++ b/src/main/windows/windowManager.test.js @@ -165,17 +165,24 @@ describe('main/windows/windowManager', () => { const window = { on: jest.fn(), once: jest.fn(), + webContents: { + setWindowOpenHandler: jest.fn(), + }, }; createMainWindow.mockReturnValue(window); windowManager.showMainWindow(); expect(windowManager.mainWindow).toBe(window); expect(window.on).toHaveBeenCalled(); + expect(window.webContents.setWindowOpenHandler).toHaveBeenCalled(); }); it('should open deep link when provided', () => { const window = { on: jest.fn(), once: jest.fn(), + webContents: { + setWindowOpenHandler: jest.fn(), + }, }; createMainWindow.mockReturnValue(window); windowManager.showMainWindow('mattermost://server-1.com/subpath'); diff --git a/src/main/windows/windowManager.ts b/src/main/windows/windowManager.ts index 2f79935d..317b560a 100644 --- a/src/main/windows/windowManager.ts +++ b/src/main/windows/windowManager.ts @@ -215,6 +215,9 @@ export class WindowManager { this.mainWindow.on('enter-full-screen', () => this.sendToRenderer('enter-full-screen')); this.mainWindow.on('leave-full-screen', () => this.sendToRenderer('leave-full-screen')); + // Should not allow the main window to generate a window of its own + this.mainWindow.webContents.setWindowOpenHandler(() => ({action: 'deny'})); + if (process.env.MM_DEBUG_SETTINGS) { this.mainWindow.webContents.openDevTools({mode: 'detach'}); }