From a2c56d7a57dcc92226d30f184490ad915648a764 Mon Sep 17 00:00:00 2001 From: ShaneK Date: Tue, 28 Jul 2026 07:09:42 -0700 Subject: [PATCH] test(playwright): scope drag selection clear to firefox --- core/src/utils/test/playwright/drag-element.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/src/utils/test/playwright/drag-element.ts b/core/src/utils/test/playwright/drag-element.ts index febff65078e..285d5416c2f 100644 --- a/core/src/utils/test/playwright/drag-element.ts +++ b/core/src/utils/test/playwright/drag-element.ts @@ -39,7 +39,16 @@ export const dragElementBy = async ( // initiates text selection on mouse.down(). In Playwright, this selection // locks in before the gesture detector fires, blocking pointer events. // Clearing it here allows the drag gesture to proceed normally. - await page.evaluate(() => window.getSelection()?.removeAllRanges()); + // + // This is scoped to Firefox because the extra page.evaluate() is an awaited + // round-trip that adds variable latency between mouse.down() and the first + // mouse.move(). Chromium and WebKit don't need the selection clear, and on + // WebKit that latency perturbs the timing-derived gesture velocity, causing + // the item to settle a few pixels off and flaking screenshot comparisons + // (e.g. item-sliding safe-area tests). + if (page.context().browser()?.browserType().name() === 'firefox') { + await page.evaluate(() => window.getSelection()?.removeAllRanges()); + } // Drag the element. await moveElement(page, startX, startY, dragByX, dragByY);