Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MM-62241] Fix screen sharing from Calls popout window #3258

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"main.menus.app.view.developerModeDisableUserActivityMonitor": "Disable User Activity Monitor",
"main.menus.app.view.devToolsAppWrapper": "Developer Tools for Application Wrapper",
"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.devToolsSubMenu": "Developer Tools",
"main.menus.app.view.downloads": "Downloads",
Expand Down
16 changes: 16 additions & 0 deletions src/main/menus/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ describe('main/menus/app', () => {

it('should show menu item if widget window is open', () => {
CallsWidgetWindow.isOpen = jest.fn(() => true);
CallsWidgetWindow.isPopoutOpen = jest.fn(() => false);
const menu = createTemplate(config);

const appMenu = menu.find((item) => item.label === 'main.menus.app.view');
Expand All @@ -371,4 +372,19 @@ describe('main/menus/app', () => {
const menuItem = devToolsSubMenu.submenu.find((item) => item.label === 'main.menus.app.view.devToolsCurrentCallWidget');
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);
});
});
9 changes: 9 additions & 0 deletions src/main/menus/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,15 @@ export function createTemplate(config: Config, updateManager: UpdateManager) {
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()) {
Expand Down
8 changes: 7 additions & 1 deletion src/main/windows/callsWidgetWindow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jest.mock('main/views/viewManager', () => ({
jest.mock('../utils', () => ({
openScreensharePermissionsSettingsMacOS: jest.fn(),
resetScreensharePermissionsMacOS: jest.fn(),
getLocalPreload: jest.fn(),
getLocalPreload: jest.fn((file) => file),
composeUserAgent: jest.fn(),
}));

Expand Down Expand Up @@ -362,6 +362,12 @@ describe('main/windows/callsWidgetWindow', () => {
urlUtils.isCallsPopOutURL.mockReturnValue(false);
expect(callsWidgetWindow.onPopOutOpen({url: 'http://localhost:8065/notpopouturl'})).toHaveProperty('action', 'deny');
});

it('should pop out and make sure preload is set', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

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', () => {
Expand Down
15 changes: 15 additions & 0 deletions src/main/windows/callsWidgetWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ export class CallsWidgetWindow {
return Boolean(this.win && !this.win.isDestroyed());
}

public isPopoutOpen() {
return Boolean(this.popOut && !this.popOut.isDestroyed());
}

/**
* Helper functions
*/
Expand All @@ -105,6 +109,10 @@ export class CallsWidgetWindow {
this.win?.webContents.openDevTools({mode: 'detach'});
};

public openPopoutDevTools = () => {
this.popOut?.webContents.openDevTools({mode: 'detach'});
};

getViewURL = () => {
return this.mainView?.view.server.url;
};
Expand Down Expand Up @@ -277,6 +285,9 @@ export class CallsWidgetWindow {
action: 'allow' as const,
overrideBrowserWindowOptions: {
autoHideMenuBar: true,
webPreferences: {
preload: getLocalPreload('externalAPI.js'),
},
},
};
}
Expand All @@ -301,7 +312,11 @@ export class CallsWidgetWindow {
const contextMenu = new ContextMenu({}, this.popOut);
contextMenu.reload();

// Update menu to show the developer tools option for this window.
ipcMain.emit(UPDATE_SHORTCUT_MENU);

this.popOut.on('closed', () => {
ipcMain.emit(UPDATE_SHORTCUT_MENU);
delete this.popOut;
contextMenu.dispose();
});
Expand Down
Loading