test: do not trigger unhandled promise rejections (#22922)
This commit is contained in:
Родитель
e6f2605ad0
Коммит
14051ff945
|
@ -135,16 +135,16 @@ describe('webRequest module', () => {
|
||||||
await ajax(defaultURL + 'serverRedirect');
|
await ajax(defaultURL + 'serverRedirect');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with file:// protocol', (done) => {
|
it('works with file:// protocol', async () => {
|
||||||
ses.webRequest.onBeforeRequest((details, callback) => {
|
ses.webRequest.onBeforeRequest((details, callback) => {
|
||||||
callback({ cancel: true });
|
callback({ cancel: true });
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
ajax(url.format({
|
const fileURL = url.format({
|
||||||
pathname: path.join(fixturesPath, 'blank.html').replace(/\\/g, '/'),
|
pathname: path.join(fixturesPath, 'blank.html').replace(/\\/g, '/'),
|
||||||
protocol: 'file',
|
protocol: 'file',
|
||||||
slashes: true
|
slashes: true
|
||||||
}));
|
});
|
||||||
|
await expect(ajax(fileURL)).to.eventually.be.rejectedWith('404');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -207,22 +207,24 @@ describe('webRequest module', () => {
|
||||||
await ajax(defaultURL);
|
await ajax(defaultURL);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with file:// protocol', (done) => {
|
it('works with file:// protocol', async () => {
|
||||||
const requestHeaders = {
|
const requestHeaders = {
|
||||||
Test: 'header'
|
Test: 'header'
|
||||||
};
|
};
|
||||||
|
let onSendHeadersCalled = false;
|
||||||
ses.webRequest.onBeforeSendHeaders((details, callback) => {
|
ses.webRequest.onBeforeSendHeaders((details, callback) => {
|
||||||
callback({ requestHeaders: requestHeaders });
|
callback({ requestHeaders: requestHeaders });
|
||||||
});
|
});
|
||||||
ses.webRequest.onSendHeaders((details) => {
|
ses.webRequest.onSendHeaders((details) => {
|
||||||
expect(details.requestHeaders).to.deep.equal(requestHeaders);
|
expect(details.requestHeaders).to.deep.equal(requestHeaders);
|
||||||
done();
|
onSendHeadersCalled = true;
|
||||||
});
|
});
|
||||||
ajax(url.format({
|
await ajax(url.format({
|
||||||
pathname: path.join(fixturesPath, 'blank.html').replace(/\\/g, '/'),
|
pathname: path.join(fixturesPath, 'blank.html').replace(/\\/g, '/'),
|
||||||
protocol: 'file',
|
protocol: 'file',
|
||||||
slashes: true
|
slashes: true
|
||||||
}));
|
}));
|
||||||
|
expect(onSendHeadersCalled).to.be.true();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче