test: add cookie tests (#4365)

This commit is contained in:
Andrey Lushnikov 2019-04-30 00:35:41 -07:00 committed by GitHub
parent 27c9f754b1
commit 1de9906260
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,7 +16,7 @@
module.exports.addTests = function({testRunner, expect}) { module.exports.addTests = function({testRunner, expect}) {
const {describe, xdescribe, fdescribe} = testRunner; const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit} = testRunner; const {it, fit, xit, it_fails_ffox} = testRunner;
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner; const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
describe('Page.cookies', function() { describe('Page.cookies', function() {
@ -41,6 +41,36 @@ module.exports.addTests = function({testRunner, expect}) {
session: true session: true
}]); }]);
}); });
it('should properly report httpOnly cookie', async({page, server}) => {
server.setRoute('/empty.html', (req, res) => {
res.setHeader('Set-Cookie', ';HttpOnly; Path=/');
res.end();
});
await page.goto(server.EMPTY_PAGE);
const cookies = await page.cookies();
expect(cookies.length).toBe(1);
expect(cookies[0].httpOnly).toBe(true);
});
it_fails_ffox('should properly report "Strict" sameSite cookie', async({page, server}) => {
server.setRoute('/empty.html', (req, res) => {
res.setHeader('Set-Cookie', ';SameSite=Strict');
res.end();
});
await page.goto(server.EMPTY_PAGE);
const cookies = await page.cookies();
expect(cookies.length).toBe(1);
expect(cookies[0].sameSite).toBe('Strict');
});
it_fails_ffox('should properly report "Lax" sameSite cookie', async({page, server}) => {
server.setRoute('/empty.html', (req, res) => {
res.setHeader('Set-Cookie', ';SameSite=Lax');
res.end();
});
await page.goto(server.EMPTY_PAGE);
const cookies = await page.cookies();
expect(cookies.length).toBe(1);
expect(cookies[0].sameSite).toBe('Lax');
});
it('should get multiple cookies', async({page, server}) => { it('should get multiple cookies', async({page, server}) => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
await page.evaluate(() => { await page.evaluate(() => {