feat: session.resolveHost (#37690)
* feat: session.resolveHost Expose Chromium's host resolution API through the Session object. * Update shell/browser/api/electron_api_session.cc Co-authored-by: Jeremy Rose <nornagon@nornagon.net> * address feedback * fix tests * address feedback * Add options * Update shell/browser/api/electron_api_session.cc Co-authored-by: Cheng Zhao <github@zcbenz.com> * Update shell/browser/net/resolve_host_function.cc Co-authored-by: Cheng Zhao <github@zcbenz.com> * lint * return object * add missing file * fix crash * handle scope * links --------- Co-authored-by: Fedor Indutny <indutny@signal.org> Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Co-authored-by: Jeremy Rose <nornagon@nornagon.net> Co-authored-by: Cheng Zhao <github@zcbenz.com>
This commit is contained in:
parent
db27b9f433
commit
6bfef67aae
13 changed files with 477 additions and 0 deletions
|
@ -487,6 +487,53 @@ describe('session module', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('ses.resolveHost(host)', () => {
|
||||
let customSession: Electron.Session;
|
||||
|
||||
beforeEach(async () => {
|
||||
customSession = session.fromPartition('resolvehost');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
customSession = null as any;
|
||||
});
|
||||
|
||||
it('resolves ipv4.localhost2', async () => {
|
||||
const { endpoints } = await customSession.resolveHost('ipv4.localhost2');
|
||||
expect(endpoints).to.be.a('array');
|
||||
expect(endpoints).to.have.lengthOf(1);
|
||||
expect(endpoints[0].family).to.equal('ipv4');
|
||||
expect(endpoints[0].address).to.equal('10.0.0.1');
|
||||
});
|
||||
|
||||
it('fails to resolve AAAA record for ipv4.localhost2', async () => {
|
||||
await expect(customSession.resolveHost('ipv4.localhost2', {
|
||||
queryType: 'AAAA'
|
||||
}))
|
||||
.to.eventually.be.rejectedWith(/net::ERR_NAME_NOT_RESOLVED/);
|
||||
});
|
||||
|
||||
it('resolves ipv6.localhost2', async () => {
|
||||
const { endpoints } = await customSession.resolveHost('ipv6.localhost2');
|
||||
expect(endpoints).to.be.a('array');
|
||||
expect(endpoints).to.have.lengthOf(1);
|
||||
expect(endpoints[0].family).to.equal('ipv6');
|
||||
expect(endpoints[0].address).to.equal('::1');
|
||||
});
|
||||
|
||||
it('fails to resolve A record for ipv6.localhost2', async () => {
|
||||
await expect(customSession.resolveHost('notfound.localhost2', {
|
||||
queryType: 'A'
|
||||
}))
|
||||
.to.eventually.be.rejectedWith(/net::ERR_NAME_NOT_RESOLVED/);
|
||||
});
|
||||
|
||||
it('fails to resolve notfound.localhost2', async () => {
|
||||
await expect(customSession.resolveHost('notfound.localhost2'))
|
||||
.to.eventually.be.rejectedWith(/net::ERR_NAME_NOT_RESOLVED/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ses.getBlobData()', () => {
|
||||
const scheme = 'cors-blob';
|
||||
const protocol = session.defaultSession.protocol;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue