From 64bf2a624fe1bddea227cab83725ecaa80d41391 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Tue, 12 Sep 2023 15:01:44 -0700 Subject: [PATCH] test: fix webkit test on Darwin (#27029) --- .../browsercontext-viewport-mobile.spec.ts | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/tests/library/browsercontext-viewport-mobile.spec.ts b/tests/library/browsercontext-viewport-mobile.spec.ts index 96725bbfbb..96832da254 100644 --- a/tests/library/browsercontext-viewport-mobile.spec.ts +++ b/tests/library/browsercontext-viewport-mobile.spec.ts @@ -16,7 +16,6 @@ */ import { browserTest as it, expect } from '../config/browserTest'; -import os from 'os'; it.describe('mobile viewport', () => { it.skip(({ browserName }) => browserName === 'firefox'); @@ -191,7 +190,7 @@ it.describe('mobile viewport', () => { await context.close(); }); - it('view scale should reset after navigation', async ({ browser, browserName, isLinux, isWindows, isMac, headless }) => { + it('view scale should reset after navigation', async ({ browser, browserName }) => { it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/26876' }); const context = await browser.newContext({ viewport: { width: 390, height: 664 }, @@ -225,23 +224,12 @@ it.describe('mobile viewport', () => { }); await page.goto('http://localhost/button.html'); await page.getByText('Click me').click({ force: true }); - let expected = [{ x: 41, y: 18 }]; - if (browserName === 'webkit') { - if (isLinux) { - if (headless) - expected = [{ x: 50, y: 20 }]; - else - expected = [{ x: 45, y: 20 }]; - } else if (isWindows) { - expected = [{ x: 40, y: 20 }]; - } else if (isMac) { - if (parseInt(os.release(), 10) === 21) - expected = [{ x: 40, y: 17 }]; - else - expected = [{ x: 37, y: 15 }]; - } - } - expect(await page.evaluate(() => (window as any).clicks)).toEqual(expected); + const box = await page.locator('button').boundingBox(); + const clicks = await page.evaluate(() => (window as any).clicks); + expect(clicks.length).toBe(1); + const [{ x, y }] = clicks; + const isClickInsideButton = box.x <= x && x <= box.x + box.width && box.y <= y && y <= box.y + box.height; + expect(isClickInsideButton).toBe(true); await context.close(); }); });