Expose Desktop API in Calls popout window (#3258)
This commit is contained in:
@@ -97,6 +97,7 @@
|
|||||||
"main.menus.app.view.developerModeDisableUserActivityMonitor": "Disable User Activity Monitor",
|
"main.menus.app.view.developerModeDisableUserActivityMonitor": "Disable User Activity Monitor",
|
||||||
"main.menus.app.view.devToolsAppWrapper": "Developer Tools for Application Wrapper",
|
"main.menus.app.view.devToolsAppWrapper": "Developer Tools for Application Wrapper",
|
||||||
"main.menus.app.view.devToolsCurrentCallWidget": "Developer Tools for Call Widget",
|
"main.menus.app.view.devToolsCurrentCallWidget": "Developer Tools for Call Widget",
|
||||||
|
"main.menus.app.view.devToolsCurrentCallWidgetPopout": "Developer Tools for Call Widget Popout",
|
||||||
"main.menus.app.view.devToolsCurrentServer": "Developer Tools for Current Server",
|
"main.menus.app.view.devToolsCurrentServer": "Developer Tools for Current Server",
|
||||||
"main.menus.app.view.devToolsSubMenu": "Developer Tools",
|
"main.menus.app.view.devToolsSubMenu": "Developer Tools",
|
||||||
"main.menus.app.view.downloads": "Downloads",
|
"main.menus.app.view.downloads": "Downloads",
|
||||||
|
@@ -360,6 +360,7 @@ describe('main/menus/app', () => {
|
|||||||
|
|
||||||
it('should show menu item if widget window is open', () => {
|
it('should show menu item if widget window is open', () => {
|
||||||
CallsWidgetWindow.isOpen = jest.fn(() => true);
|
CallsWidgetWindow.isOpen = jest.fn(() => true);
|
||||||
|
CallsWidgetWindow.isPopoutOpen = jest.fn(() => false);
|
||||||
const menu = createTemplate(config);
|
const menu = createTemplate(config);
|
||||||
|
|
||||||
const appMenu = menu.find((item) => item.label === 'main.menus.app.view');
|
const appMenu = menu.find((item) => item.label === 'main.menus.app.view');
|
||||||
@@ -371,4 +372,19 @@ describe('main/menus/app', () => {
|
|||||||
const menuItem = devToolsSubMenu.submenu.find((item) => item.label === 'main.menus.app.view.devToolsCurrentCallWidget');
|
const menuItem = devToolsSubMenu.submenu.find((item) => item.label === 'main.menus.app.view.devToolsCurrentCallWidget');
|
||||||
expect(menuItem).not.toBe(undefined);
|
expect(menuItem).not.toBe(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should show additional menu item if widget popout is open', () => {
|
||||||
|
CallsWidgetWindow.isOpen = jest.fn(() => true);
|
||||||
|
CallsWidgetWindow.isPopoutOpen = jest.fn(() => true);
|
||||||
|
const menu = createTemplate(config);
|
||||||
|
|
||||||
|
const appMenu = menu.find((item) => item.label === 'main.menus.app.view');
|
||||||
|
expect(appMenu).not.toBe(undefined);
|
||||||
|
|
||||||
|
const devToolsSubMenu = appMenu.submenu.find((item) => item.label === 'main.menus.app.view.devToolsSubMenu');
|
||||||
|
expect(devToolsSubMenu).not.toBe(undefined);
|
||||||
|
|
||||||
|
const menuItem = devToolsSubMenu.submenu.find((item) => item.label === 'main.menus.app.view.devToolsCurrentCallWidgetPopout');
|
||||||
|
expect(menuItem).not.toBe(undefined);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -179,6 +179,15 @@ export function createTemplate(config: Config, updateManager: UpdateManager) {
|
|||||||
CallsWidgetWindow.openDevTools();
|
CallsWidgetWindow.openDevTools();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (CallsWidgetWindow.isPopoutOpen()) {
|
||||||
|
devToolsSubMenu.push({
|
||||||
|
label: localizeMessage('main.menus.app.view.devToolsCurrentCallWidgetPopout', 'Developer Tools for Call Widget Popout'),
|
||||||
|
click() {
|
||||||
|
CallsWidgetWindow.openPopoutDevTools();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DeveloperMode.enabled()) {
|
if (DeveloperMode.enabled()) {
|
||||||
|
@@ -79,7 +79,7 @@ jest.mock('main/views/viewManager', () => ({
|
|||||||
jest.mock('../utils', () => ({
|
jest.mock('../utils', () => ({
|
||||||
openScreensharePermissionsSettingsMacOS: jest.fn(),
|
openScreensharePermissionsSettingsMacOS: jest.fn(),
|
||||||
resetScreensharePermissionsMacOS: jest.fn(),
|
resetScreensharePermissionsMacOS: jest.fn(),
|
||||||
getLocalPreload: jest.fn(),
|
getLocalPreload: jest.fn((file) => file),
|
||||||
composeUserAgent: jest.fn(),
|
composeUserAgent: jest.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -369,6 +369,12 @@ describe('main/windows/callsWidgetWindow', () => {
|
|||||||
urlUtils.isCallsPopOutURL.mockReturnValue(false);
|
urlUtils.isCallsPopOutURL.mockReturnValue(false);
|
||||||
expect(callsWidgetWindow.onPopOutOpen({url: 'http://localhost:8065/notpopouturl'})).toHaveProperty('action', 'deny');
|
expect(callsWidgetWindow.onPopOutOpen({url: 'http://localhost:8065/notpopouturl'})).toHaveProperty('action', 'deny');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should pop out and make sure preload is set', () => {
|
||||||
|
urlUtils.isCallsPopOutURL.mockReturnValue(true);
|
||||||
|
expect(callsWidgetWindow.onPopOutOpen({url: 'http://localhost:8065/popouturl'})).toHaveProperty('action', 'allow');
|
||||||
|
expect(callsWidgetWindow.onPopOutOpen({url: 'http://localhost:8065/popouturl'})).toHaveProperty('overrideBrowserWindowOptions.webPreferences.preload', 'externalAPI.js');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('handlePopOutFocus', () => {
|
describe('handlePopOutFocus', () => {
|
||||||
|
@@ -97,6 +97,10 @@ export class CallsWidgetWindow {
|
|||||||
return Boolean(this.win && !this.win.isDestroyed());
|
return Boolean(this.win && !this.win.isDestroyed());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public isPopoutOpen() {
|
||||||
|
return Boolean(this.popOut && !this.popOut.isDestroyed());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper functions
|
* Helper functions
|
||||||
*/
|
*/
|
||||||
@@ -105,6 +109,10 @@ export class CallsWidgetWindow {
|
|||||||
this.win?.webContents.openDevTools({mode: 'detach'});
|
this.win?.webContents.openDevTools({mode: 'detach'});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public openPopoutDevTools = () => {
|
||||||
|
this.popOut?.webContents.openDevTools({mode: 'detach'});
|
||||||
|
};
|
||||||
|
|
||||||
getViewURL = () => {
|
getViewURL = () => {
|
||||||
return this.mainView?.view.server.url;
|
return this.mainView?.view.server.url;
|
||||||
};
|
};
|
||||||
@@ -292,6 +300,9 @@ export class CallsWidgetWindow {
|
|||||||
action: 'allow' as const,
|
action: 'allow' as const,
|
||||||
overrideBrowserWindowOptions: {
|
overrideBrowserWindowOptions: {
|
||||||
autoHideMenuBar: true,
|
autoHideMenuBar: true,
|
||||||
|
webPreferences: {
|
||||||
|
preload: getLocalPreload('externalAPI.js'),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -318,7 +329,11 @@ export class CallsWidgetWindow {
|
|||||||
const contextMenu = new ContextMenu({}, this.popOut);
|
const contextMenu = new ContextMenu({}, this.popOut);
|
||||||
contextMenu.reload();
|
contextMenu.reload();
|
||||||
|
|
||||||
|
// Update menu to show the developer tools option for this window.
|
||||||
|
ipcMain.emit(UPDATE_SHORTCUT_MENU);
|
||||||
|
|
||||||
this.popOut.on('closed', () => {
|
this.popOut.on('closed', () => {
|
||||||
|
ipcMain.emit(UPDATE_SHORTCUT_MENU);
|
||||||
delete this.popOut;
|
delete this.popOut;
|
||||||
contextMenu.dispose();
|
contextMenu.dispose();
|
||||||
this.setWidgetWindowStacking({onTop: true});
|
this.setWidgetWindowStacking({onTop: true});
|
||||||
|
Reference in New Issue
Block a user