|
15 | 15 | * limitations under the License.
|
16 | 16 | */
|
17 | 17 |
|
18 |
| -const {FFOX, CHROMIUM, WEBKIT, MAC} = require('./utils').testOptions(browserType); |
| 18 | +const {FFOX, CHROMIUM, WEBKIT, MAC, LINUX} = require('./utils').testOptions(browserType); |
19 | 19 |
|
20 | 20 | describe('BrowserContext.cookies', function() {
|
21 | 21 | it('should return no cookies in pristine browser context', async({context, page, server}) => {
|
@@ -432,6 +432,38 @@ describe('BrowserContext.addCookies', function() {
|
432 | 432 |
|
433 | 433 | expect(await page.frames()[1].evaluate('document.cookie')).toBe('frame-cookie=value');
|
434 | 434 | });
|
| 435 | + it('should(not) block third party cookies', async({context, page, server}) => { |
| 436 | + await page.goto(server.EMPTY_PAGE); |
| 437 | + await page.evaluate(src => { |
| 438 | + let fulfill; |
| 439 | + const promise = new Promise(x => fulfill = x); |
| 440 | + const iframe = document.createElement('iframe'); |
| 441 | + document.body.appendChild(iframe); |
| 442 | + iframe.onload = fulfill; |
| 443 | + iframe.src = src; |
| 444 | + return promise; |
| 445 | + }, server.CROSS_PROCESS_PREFIX + '/grid.html'); |
| 446 | + await page.frames()[1].evaluate(`document.cookie = 'username=John Doe'`); |
| 447 | + await page.waitForTimeout(2000); |
| 448 | + const allowsThirdParty = CHROMIUM || FFOX; |
| 449 | + const cookies = await context.cookies(server.CROSS_PROCESS_PREFIX + '/grid.html'); |
| 450 | + if (allowsThirdParty) { |
| 451 | + expect(cookies).toEqual([ |
| 452 | + { |
| 453 | + "domain": "127.0.0.1", |
| 454 | + "expires": -1, |
| 455 | + "httpOnly": false, |
| 456 | + "name": "username", |
| 457 | + "path": "/", |
| 458 | + "sameSite": "None", |
| 459 | + "secure": false, |
| 460 | + "value": "John Doe" |
| 461 | + } |
| 462 | + ]); |
| 463 | + } else { |
| 464 | + expect(cookies).toEqual([]); |
| 465 | + } |
| 466 | + }); |
435 | 467 | });
|
436 | 468 |
|
437 | 469 | describe('BrowserContext.clearCookies', function() {
|
|
0 commit comments