fix: properly bubble up cookie creation failure message (#37597)

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot]
2023-03-16 17:52:43 +01:00
committed by GitHub
parent 62aad2481f
commit 3c5cd4c2eb
3 changed files with 22 additions and 7 deletions

View File

@@ -846,6 +846,16 @@ describe('net module', () => {
expect(cookies[0].name).to.equal('cookie2');
});
it('throws when an invalid domain is passed', async () => {
const sess = session.fromPartition(`cookie-tests-${Math.random()}`);
await expect(sess.cookies.set({
url: 'https://electronjs.org',
domain: 'wssss.iamabaddomain.fun',
name: 'cookie1'
})).to.eventually.be.rejectedWith(/Failed to set cookie with an invalid domain attribute/);
});
it('should be able correctly filter out cookies that are session', async () => {
const sess = session.fromPartition(`cookie-tests-${Math.random()}`);

View File

@@ -129,7 +129,7 @@ describe('session module', () => {
await expect(
cookies.set({ url: '', name, value })
).to.eventually.be.rejectedWith('Failed to get cookie domain');
).to.eventually.be.rejectedWith('Failed to set cookie with an invalid domain attribute');
});
it('yields an error when setting a cookie with an invalid URL', async () => {
@@ -139,7 +139,7 @@ describe('session module', () => {
await expect(
cookies.set({ url: 'asdf', name, value })
).to.eventually.be.rejectedWith('Failed to get cookie domain');
).to.eventually.be.rejectedWith('Failed to set cookie with an invalid domain attribute');
});
it('should overwrite previous cookies', async () => {