feat: add setter and getter apis to specify udp port range for webrtc (#39046)
* feat:Add setter and getter apis to specify udp port range for webrtc (issue#9042) * lint error fix for PR#39046 * feat: add setter and getter apis to specify udp port range for webrtc (issue#9042) , changed for codereview * fix lint error * fix lint errors in file api-web-contents-spec.ts * feat: add setter and getter apis to specify udp port range for webrtc (issue#9042) , changed for review from itsananderson * feat: add setter and getter apis to specify udp port range for webrtc (issue#9042) , changed for review from jkleinsc * fix lint error * feat: add setter and getter apis to specify udp port range for webrtc (issue#9042) , changed for review from codebyter
This commit is contained in:
parent
33000c4b42
commit
e14964ccd0
4 changed files with 109 additions and 0 deletions
|
@ -1309,6 +1309,47 @@ describe('webContents module', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('webrtc udp port range policy api', () => {
|
||||
let w: BrowserWindow;
|
||||
beforeEach(() => {
|
||||
w = new BrowserWindow({ show: false });
|
||||
});
|
||||
|
||||
afterEach(closeAllWindows);
|
||||
|
||||
it('check default webrtc udp port range is { min: 0, max: 0 }', () => {
|
||||
const settings = w.webContents.getWebRTCUDPPortRange();
|
||||
expect(settings).to.deep.equal({ min: 0, max: 0 });
|
||||
});
|
||||
|
||||
it('can set and get webrtc udp port range policy with correct arguments', () => {
|
||||
w.webContents.setWebRTCUDPPortRange({ min: 1, max: 65535 });
|
||||
const settings = w.webContents.getWebRTCUDPPortRange();
|
||||
expect(settings).to.deep.equal({ min: 1, max: 65535 });
|
||||
});
|
||||
|
||||
it('can not set webrtc udp port range policy with invalid arguments', () => {
|
||||
expect(() => {
|
||||
w.webContents.setWebRTCUDPPortRange({ min: 0, max: 65535 });
|
||||
}).to.throw("'min' and 'max' must be in the (0, 65535] range or [0, 0]");
|
||||
expect(() => {
|
||||
w.webContents.setWebRTCUDPPortRange({ min: 1, max: 65536 });
|
||||
}).to.throw("'min' and 'max' must be in the (0, 65535] range or [0, 0]");
|
||||
expect(() => {
|
||||
w.webContents.setWebRTCUDPPortRange({ min: 60000, max: 56789 });
|
||||
}).to.throw("'max' must be greater than or equal to 'min'");
|
||||
});
|
||||
|
||||
it('can reset webrtc udp port range policy to default with { min: 0, max: 0 }', () => {
|
||||
w.webContents.setWebRTCUDPPortRange({ min: 1, max: 65535 });
|
||||
const settings = w.webContents.getWebRTCUDPPortRange();
|
||||
expect(settings).to.deep.equal({ min: 1, max: 65535 });
|
||||
w.webContents.setWebRTCUDPPortRange({ min: 0, max: 0 });
|
||||
const defaultSetting = w.webContents.getWebRTCUDPPortRange();
|
||||
expect(defaultSetting).to.deep.equal({ min: 0, max: 0 });
|
||||
});
|
||||
});
|
||||
|
||||
describe('opener api', () => {
|
||||
afterEach(closeAllWindows);
|
||||
it('can get opener with window.open()', async () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue