|
@@ -813,6 +813,71 @@ describe('net module', () => {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ it('should be able correctly filter out cookies that are secure', async () => {
|
|
|
+ const sess = session.fromPartition(`cookie-tests-${Math.random()}`);
|
|
|
+
|
|
|
+ await Promise.all([
|
|
|
+ sess.cookies.set({
|
|
|
+ url: 'https://electronjs.org',
|
|
|
+ domain: 'electronjs.org',
|
|
|
+ name: 'cookie1',
|
|
|
+ value: '1',
|
|
|
+ secure: true
|
|
|
+ }),
|
|
|
+ sess.cookies.set({
|
|
|
+ url: 'https://electronjs.org',
|
|
|
+ domain: 'electronjs.org',
|
|
|
+ name: 'cookie2',
|
|
|
+ value: '2',
|
|
|
+ secure: false
|
|
|
+ })
|
|
|
+ ]);
|
|
|
+
|
|
|
+ const secureCookies = await sess.cookies.get({
|
|
|
+ secure: true
|
|
|
+ });
|
|
|
+ expect(secureCookies).to.have.lengthOf(1);
|
|
|
+ expect(secureCookies[0].name).to.equal('cookie1');
|
|
|
+
|
|
|
+ const cookies = await sess.cookies.get({
|
|
|
+ secure: false
|
|
|
+ });
|
|
|
+ expect(cookies).to.have.lengthOf(1);
|
|
|
+ expect(cookies[0].name).to.equal('cookie2');
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should be able correctly filter out cookies that are session', async () => {
|
|
|
+ const sess = session.fromPartition(`cookie-tests-${Math.random()}`);
|
|
|
+
|
|
|
+ await Promise.all([
|
|
|
+ sess.cookies.set({
|
|
|
+ url: 'https://electronjs.org',
|
|
|
+ domain: 'electronjs.org',
|
|
|
+ name: 'cookie1',
|
|
|
+ value: '1'
|
|
|
+ }),
|
|
|
+ sess.cookies.set({
|
|
|
+ url: 'https://electronjs.org',
|
|
|
+ domain: 'electronjs.org',
|
|
|
+ name: 'cookie2',
|
|
|
+ value: '2',
|
|
|
+ expirationDate: Math.round(Date.now() / 1000) + 10000
|
|
|
+ })
|
|
|
+ ]);
|
|
|
+
|
|
|
+ const sessionCookies = await sess.cookies.get({
|
|
|
+ session: true
|
|
|
+ });
|
|
|
+ expect(sessionCookies).to.have.lengthOf(1);
|
|
|
+ expect(sessionCookies[0].name).to.equal('cookie1');
|
|
|
+
|
|
|
+ const cookies = await sess.cookies.get({
|
|
|
+ session: false
|
|
|
+ });
|
|
|
+ expect(cookies).to.have.lengthOf(1);
|
|
|
+ expect(cookies[0].name).to.equal('cookie2');
|
|
|
+ });
|
|
|
+
|
|
|
describe('when {"credentials":"omit"}', () => {
|
|
|
it('should not send cookies');
|
|
|
it('should not store cookies');
|