feat: expose the sameSite value for cookies (#22789)

* feat: expose the sameSite value for cookies

* Apply suggestions from code review

Co-Authored-By: Charles Kerr <ckerr@github.com>

* Apply suggestions from code review

Align with cookie samesite values for the extensions API

https://developer.chrome.com/extensions/cookies#type-SameSiteStatus

* chore: add tests for sameSite cookies get/set

* chore: update docs parser

* chore: update docs for MessageChannel and MessagePort to have correct process information

* chore: remove LOG warning

* chore: throw error if the string->samesite conversion fails

Co-authored-by: Charles Kerr <ckerr@github.com>
This commit is contained in:
Samuel Attard 2020-04-02 11:28:43 -07:00 committed by GitHub
parent 2ce8dff175
commit 1d158399a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 260 additions and 33 deletions

View file

@ -116,6 +116,24 @@ describe('session module', () => {
expect(c.value).to.equal(value);
});
for (const sameSite of <const>['unspecified', 'no_restriction', 'lax', 'strict']) {
it(`sets cookies with samesite=${sameSite}`, async () => {
const { cookies } = session.defaultSession;
const value = 'hithere';
await cookies.set({ url, value, sameSite });
const c = (await cookies.get({ url }))[0];
expect(c.name).to.be.empty();
expect(c.value).to.equal(value);
expect(c.sameSite).to.equal(sameSite);
});
}
it(`fails to set cookies with samesite=garbage`, async () => {
const { cookies } = session.defaultSession;
const value = 'hithere';
await expect(cookies.set({ url, value, sameSite: 'garbage' as any })).to.eventually.be.rejectedWith('Failed to convert \'garbage\' to an appropriate cookie same site value');
});
it('gets cookies without url', async () => {
const { cookies } = session.defaultSession;
const name = '1';