From 3d14c1ff51a2e3804f57f5ddcec7bf4bbc96d54a Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Mon, 18 Oct 2021 10:45:47 -0700 Subject: [PATCH] test: newContext works when both screen and viewport specified (#9520) --- tests/browsercontext-viewport.spec.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/browsercontext-viewport.spec.ts b/tests/browsercontext-viewport.spec.ts index 2b430dca89..620bb6b110 100644 --- a/tests/browsercontext-viewport.spec.ts +++ b/tests/browsercontext-viewport.spec.ts @@ -105,6 +105,19 @@ browserTest('should support touch with null viewport', async ({ browser, server await context.close(); }); +it('should set both screen and viewport options', async ({ contextFactory, browserName }) => { + it.fail(browserName === 'firefox', 'Screen size is reset to viewport'); + const context = await contextFactory({ + screen: { 'width': 1280, 'height': 720 }, + viewport: { 'width': 1000, 'height': 600 }, + }); + const page = await context.newPage(); + const screen = await page.evaluate(() => ({ w: screen.width, h: screen.height })); + expect(screen).toEqual({ w: 1280, h: 720 }); + const inner = await page.evaluate(() => ({ w: window.innerWidth, h: window.innerHeight })); + expect(inner).toEqual({ w: 1000, h: 600 }); +}); + browserTest('should report null viewportSize when given null viewport', async ({ browser, server }) => { const context = await browser.newContext({ viewport: null }); const page = await context.newPage();