test: validate headless reading cookies written by headful (#1266)

This test ensures that Chrome Headless can successfully read cookies written
by Chrome Headful.

References #921
This commit is contained in:
Andrey Lushnikov 2017-11-03 00:02:41 -07:00 committed by GitHub
parent cee3081a41
commit f08f33458f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -9,6 +9,10 @@ cache:
yarn: true yarn: true
directories: directories:
- node_modules - node_modules
# allow headful tests
before_install:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
install: install:
- yarn install - yarn install
# puppeteer's install script downloads Chrome # puppeteer's install script downloads Chrome

View File

@ -165,6 +165,26 @@ describe('Puppeteer', function() {
await browser2.close(); await browser2.close();
rm(userDataDir); rm(userDataDir);
})); }));
xit('headless should be able to read cookies written by headful', SX(async function() {
const userDataDir = fs.mkdtempSync(path.join(__dirname, 'test-user-data-dir'));
const options = Object.assign({userDataDir}, defaultBrowserOptions);
// Write a cookie in headful chrome
options.headless = false;
const headfulBrowser = await puppeteer.launch(options);
const headfulPage = await headfulBrowser.newPage();
await headfulPage.goto(EMPTY_PAGE);
await headfulPage.evaluate(() => document.cookie = 'foo=true; expires=Fri, 31 Dec 9999 23:59:59 GMT');
await headfulBrowser.close();
// Read the cookie from headless chrome
options.headless = true;
const headlessBrowser = await puppeteer.launch(options);
const headlessPage = await headlessBrowser.newPage();
await headlessPage.goto(EMPTY_PAGE);
const cookie = await headlessPage.evaluate(() => document.cookie);
await headlessBrowser.close();
rm(userDataDir);
expect(cookie).toBe('foo=true');
}));
}); });
describe('Puppeteer.connect', function() { describe('Puppeteer.connect', function() {
it('should be able to connect multiple times to the same browser', SX(async function() { it('should be able to connect multiple times to the same browser', SX(async function() {