Fix media permissions failure on Calls window (#2550)

This commit is contained in:
Claudio Costa
2023-02-10 11:13:31 -06:00
committed by GitHub
parent 8dbdb0a75e
commit 562ef14aef
4 changed files with 65 additions and 0 deletions

View File

@@ -358,5 +358,26 @@ describe('main/windows/callsWidgetWindow', () => {
expect(popOut.focus).toHaveBeenCalled();
expect(popOut.restore).toHaveBeenCalled();
});
it('getWebContentsId', () => {
baseWindow.webContents = {
...baseWindow.webContents,
id: 'testID',
};
const widgetWindow = new CallsWidgetWindow(mainWindow, mainView, widgetConfig);
expect(widgetWindow.getWebContentsId()).toBe('testID');
});
it('getURL', () => {
baseWindow.webContents = {
...baseWindow.webContents,
id: 'testID',
getURL: jest.fn(() => 'http://localhost:8065/'),
};
const widgetWindow = new CallsWidgetWindow(mainWindow, mainView, widgetConfig);
expect(widgetWindow.getURL().toString()).toBe('http://localhost:8065/');
});
});
});

View File

@@ -24,6 +24,7 @@ import {
CALLS_PLUGIN_ID,
} from 'common/utils/constants';
import Utils from 'common/utils/util';
import urlUtils from 'common/utils/url';
import {
CALLS_JOINED_CALL,
CALLS_POPOUT_FOCUS,
@@ -210,5 +211,13 @@ export default class CallsWidgetWindow extends EventEmitter {
}
this.popOut.focus();
}
public getWebContentsId() {
return this.win.webContents.id;
}
public getURL() {
return urlUtils.parseURL(this.win.webContents.getURL());
}
}

View File

@@ -1183,4 +1183,35 @@ describe('main/windows/windowManager', () => {
expect(windowManager.switchServer).toHaveBeenCalledWith('server-2');
});
});
describe('getServerURLFromWebContentsId', () => {
const view = {
name: 'server-1_tab-messaging',
serverInfo: {
remoteInfo: {
siteURL: 'http://server-1.com',
},
},
};
const windowManager = new WindowManager();
windowManager.viewManager = {
views: new Map([
['server-1_tab-messaging', view],
]),
findViewByWebContent: jest.fn(),
};
it('should return calls widget URL', () => {
CallsWidgetWindow.mockImplementation(() => {
return {
on: jest.fn(),
getURL: jest.fn(() => 'http://localhost:8065'),
getWebContentsId: jest.fn(() => 'callsID'),
};
});
windowManager.createCallsWidgetWindow(null, 'server-1_tab-messaging', {callID: 'test'});
expect(windowManager.getServerURLFromWebContentsId('callsID')).toBe(windowManager.callsWidgetWindow.getURL());
});
});
});

View File

@@ -862,6 +862,10 @@ export class WindowManager {
}
getServerURLFromWebContentsId = (id: number) => {
if (this.callsWidgetWindow && id === this.callsWidgetWindow.getWebContentsId()) {
return this.callsWidgetWindow.getURL();
}
const viewName = this.getViewNameByWebContentsId(id);
if (!viewName) {
return undefined;