From 6e00af3b2ecdbb9019e96387e6e9b6697c0e1913 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Wed, 1 Dec 2021 12:54:20 -0800 Subject: [PATCH] fix(click): revert layout shift logic (#10653) --- packages/playwright-core/src/server/dom.ts | 2 +- tests/hit-target.spec.ts | 4 ++++ tests/tap.spec.ts | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/playwright-core/src/server/dom.ts b/packages/playwright-core/src/server/dom.ts index 18545e677f..9a261d50a1 100644 --- a/packages/playwright-core/src/server/dom.ts +++ b/packages/playwright-core/src/server/dom.ts @@ -407,7 +407,7 @@ export class ElementHandle extends js.JSHandle { const point = roundPoint(maybePoint); progress.metadata.point = point; - if (process.env.PLAYWRIGHT_NO_LAYOUT_SHIFT_CHECK) + if (!process.env.PLAYWRIGHT_LAYOUT_SHIFT_CHECK) return this._finishPointerAction(progress, actionName, point, options, action); else return this._finishPointerActionDetectLayoutShift(progress, actionName, point, options, action); diff --git a/tests/hit-target.spec.ts b/tests/hit-target.spec.ts index 04f857e3eb..e0afbfc557 100644 --- a/tests/hit-target.spec.ts +++ b/tests/hit-target.spec.ts @@ -45,6 +45,8 @@ it('should block all events when hit target is wrong', async ({ page, server }) }); it('should block click when mousedown succeeds but mouseup fails', async ({ page, server }) => { + it.skip(!process.env.PLAYWRIGHT_LAYOUT_SHIFT_CHECK); + await page.goto(server.PREFIX + '/input/button.html'); await page.$eval('button', button => { button.addEventListener('mousedown', () => { @@ -82,6 +84,8 @@ it('should click when element detaches in mousedown', async ({ page, server }) = }); it('should not block programmatic events', async ({ page, server }) => { + it.skip(!process.env.PLAYWRIGHT_LAYOUT_SHIFT_CHECK); + await page.goto(server.PREFIX + '/input/button.html'); await page.$eval('button', button => { button.addEventListener('mousedown', () => { diff --git a/tests/tap.spec.ts b/tests/tap.spec.ts index ad080b059a..6536c7a45d 100644 --- a/tests/tap.spec.ts +++ b/tests/tap.spec.ts @@ -48,7 +48,7 @@ it('trial run should not tap', async ({ page }) => { await page.tap('#a'); const eventsHandle = await trackEvents(await page.$('#b')); await page.tap('#b', { trial: true }); - const expected = process.env.PLAYWRIGHT_NO_LAYOUT_SHIFT_CHECK ? [] : ['pointerover', 'pointerenter', 'pointerout', 'pointerleave']; + const expected = !process.env.PLAYWRIGHT_LAYOUT_SHIFT_CHECK ? [] : ['pointerover', 'pointerenter', 'pointerout', 'pointerleave']; expect(await eventsHandle.jsonValue()).toEqual(expected); });