From 79ec3c916ed7baf23ecded810feabf62e25e326d Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Fri, 22 May 2020 17:20:42 -0700 Subject: [PATCH] test: unflake more cookie tests (#2346) --- test/defaultbrowsercontext.spec.js | 10 ++++++++-- test/headful.spec.js | 6 +++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/test/defaultbrowsercontext.spec.js b/test/defaultbrowsercontext.spec.js index 206cb51a77..5b187dc540 100644 --- a/test/defaultbrowsercontext.spec.js +++ b/test/defaultbrowsercontext.spec.js @@ -38,9 +38,11 @@ describe('launchPersistentContext()', function() { it('context.cookies() should work', async state => { const { page, server } = await launch(state); await page.goto(server.EMPTY_PAGE); - await page.evaluate(() => { + const documentCookie = await page.evaluate(() => { document.cookie = 'username=John Doe'; + return document.cookie; }); + expect(documentCookie).toBe('username=John Doe'); expect(await page.context().cookies()).toEqual([{ name: 'username', value: 'John Doe', @@ -105,7 +107,11 @@ describe('launchPersistentContext()', function() { iframe.src = src; return promise; }, server.CROSS_PROCESS_PREFIX + '/grid.html'); - await page.frames()[1].evaluate(`document.cookie = 'username=John Doe'`); + const documentCookie = await page.frames()[1].evaluate(() => { + document.cookie = 'username=John Doe'; + return document.cookie; + }); + expect(documentCookie).toBe('username=John Doe'); await page.waitForTimeout(2000); const allowsThirdParty = CHROMIUM || FFOX; const cookies = await context.cookies(server.CROSS_PROCESS_PREFIX + '/grid.html'); diff --git a/test/headful.spec.js b/test/headful.spec.js index 2779bd8d7f..061aaf7df9 100644 --- a/test/headful.spec.js +++ b/test/headful.spec.js @@ -92,7 +92,11 @@ describe('Headful', function() { iframe.src = src; return promise; }, server.CROSS_PROCESS_PREFIX + '/grid.html'); - await page.frames()[1].evaluate(`document.cookie = 'username=John Doe'`); + const documentCookie = await page.frames()[1].evaluate(() => { + document.cookie = 'username=John Doe'; + return document.cookie; + }); + expect(documentCookie).toBe('username=John Doe'); await page.waitForTimeout(2000); const allowsThirdParty = CHROMIUM || FFOX; const cookies = await page.context().cookies(server.CROSS_PROCESS_PREFIX + '/grid.html');