From fd28e8d8017283050d069fbecf7aa14b73010313 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Fri, 8 Sep 2023 08:58:07 -0700 Subject: [PATCH] test: reset view scale after navigation (#26939) Failing test for #26876 --- .../browsercontext-viewport-mobile.spec.ts | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/library/browsercontext-viewport-mobile.spec.ts b/tests/library/browsercontext-viewport-mobile.spec.ts index 20cc7c4b15..642eeaebdf 100644 --- a/tests/library/browsercontext-viewport-mobile.spec.ts +++ b/tests/library/browsercontext-viewport-mobile.spec.ts @@ -189,4 +189,44 @@ it.describe('mobile viewport', () => { await page.waitForFunction('window.scrollY === 100'); await context.close(); }); + + it('view scale should reset after navigation', async ({ browser, browserName }) => { + it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/26876' }); + it.fixme(browserName === 'webkit'); + const context = await browser.newContext({ + viewport: { width: 390, height: 664 }, + isMobile: true, + }); + const page = await context.newPage(); + await page.goto(`data:text/html,`); + await page.route('**/button.html', route => { + void route.fulfill({ + body: ` + + + `, + contentType: 'text/html', + }); + }); + await page.goto('http://localhost/button.html'); + await page.getByText('Click me').click({ force: true }); + expect(await page.evaluate(() => (window as any).clicks)).toEqual( + browserName === 'chromium' ? [{ x: 41, y: 18 }] : [{ x: 37, y: 15 }]); + await context.close(); + }); });