[MM-50409] Stop the main window from creating its own uncontrolled child windows (#2549)
This commit is contained in:
@@ -165,17 +165,24 @@ describe('main/windows/windowManager', () => {
|
|||||||
const window = {
|
const window = {
|
||||||
on: jest.fn(),
|
on: jest.fn(),
|
||||||
once: jest.fn(),
|
once: jest.fn(),
|
||||||
|
webContents: {
|
||||||
|
setWindowOpenHandler: jest.fn(),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
createMainWindow.mockReturnValue(window);
|
createMainWindow.mockReturnValue(window);
|
||||||
windowManager.showMainWindow();
|
windowManager.showMainWindow();
|
||||||
expect(windowManager.mainWindow).toBe(window);
|
expect(windowManager.mainWindow).toBe(window);
|
||||||
expect(window.on).toHaveBeenCalled();
|
expect(window.on).toHaveBeenCalled();
|
||||||
|
expect(window.webContents.setWindowOpenHandler).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should open deep link when provided', () => {
|
it('should open deep link when provided', () => {
|
||||||
const window = {
|
const window = {
|
||||||
on: jest.fn(),
|
on: jest.fn(),
|
||||||
once: jest.fn(),
|
once: jest.fn(),
|
||||||
|
webContents: {
|
||||||
|
setWindowOpenHandler: jest.fn(),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
createMainWindow.mockReturnValue(window);
|
createMainWindow.mockReturnValue(window);
|
||||||
windowManager.showMainWindow('mattermost://server-1.com/subpath');
|
windowManager.showMainWindow('mattermost://server-1.com/subpath');
|
||||||
|
@@ -215,6 +215,9 @@ export class WindowManager {
|
|||||||
this.mainWindow.on('enter-full-screen', () => this.sendToRenderer('enter-full-screen'));
|
this.mainWindow.on('enter-full-screen', () => this.sendToRenderer('enter-full-screen'));
|
||||||
this.mainWindow.on('leave-full-screen', () => this.sendToRenderer('leave-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) {
|
if (process.env.MM_DEBUG_SETTINGS) {
|
||||||
this.mainWindow.webContents.openDevTools({mode: 'detach'});
|
this.mainWindow.webContents.openDevTools({mode: 'detach'});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user