From 62b88aa56e536234bc2fb0e5ec5c13004a7874d7 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Thu, 14 May 2026 13:46:25 +0200 Subject: [PATCH] Use Puppeteer's `ElementHandle.boundingBox()` API in the integration tests The custom solution for obtaining the bounding box of a given element that we have now was necessary during the original introduction of the integration tests because at the time the `ElementHandle.boundingBox()` API in Puppeteer didn't work correctly in Chrome. However, `getRect`, where this is used, is a hot utility function because most tests call it multiple times, either directly or indirectly via other utility functions, and it turns out that the approach we use is slower than the native `ElementHandle.boundingBox()` API. Fortunately, most likely after a combination of Chrome/Puppeteer updates and the conversion to the formalized WebDriver BiDi protocol the custom solution is no longer necessary because all tests pass without it too, so this commit converts `getRect` to use `ElementHandle.boundingBox()` instead to speed up the tests. --- test/integration/test_utils.mjs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/integration/test_utils.mjs b/test/integration/test_utils.mjs index 4146fcd7e..2ef42d68e 100644 --- a/test/integration/test_utils.mjs +++ b/test/integration/test_utils.mjs @@ -268,13 +268,8 @@ function getSelector(id) { } async function getRect(page, selector) { - // In Chrome something is wrong when serializing a `DomRect`, - // so we extract the values and return them ourselves. await page.waitForSelector(selector, { visible: true }); - return page.$eval(selector, el => { - const { x, y, width, height } = el.getBoundingClientRect(); - return { x, y, width, height }; - }); + return (await page.$(selector)).boundingBox(); } function getQuerySelector(id) {