mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-07 02:31:01 +02:00
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.
This commit is contained in:
parent
65b8aec420
commit
62b88aa56e
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user