mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: make a single visibility check (#12317)
This commit is contained in:
parent
e254f746ee
commit
e35e783a74
@ -1252,17 +1252,13 @@ export abstract class ElementHandle<
|
||||
): Promise<string | Buffer> {
|
||||
const {scrollIntoView = true, clip} = options;
|
||||
|
||||
let elementClip = await this.#nonEmptyVisibleBoundingBox();
|
||||
|
||||
const page = this.frame.page();
|
||||
|
||||
// Only scroll the element into view if the user wants it.
|
||||
if (scrollIntoView) {
|
||||
await this.scrollIntoViewIfNeeded();
|
||||
|
||||
// We measure again just in case.
|
||||
elementClip = await this.#nonEmptyVisibleBoundingBox();
|
||||
}
|
||||
const elementClip = await this.#nonEmptyVisibleBoundingBox();
|
||||
|
||||
const [pageLeft, pageTop] = await this.evaluate(() => {
|
||||
if (!window.visualViewport) {
|
||||
|
@ -306,14 +306,15 @@ describe('Screenshots', function () {
|
||||
|
||||
await page.setContent('<h1>remove this</h1>');
|
||||
using elementHandle = (await page.$('h1'))!;
|
||||
await page.evaluate((element: HTMLElement) => {
|
||||
await page.evaluate(element => {
|
||||
return element.remove();
|
||||
}, elementHandle);
|
||||
const screenshotError = await elementHandle.screenshot().catch(error => {
|
||||
return error;
|
||||
});
|
||||
expect(screenshotError.message).toBe(
|
||||
'Node is either not visible or not an HTMLElement'
|
||||
expect(screenshotError).toBeInstanceOf(Error);
|
||||
expect(screenshotError.message).toMatch(
|
||||
/Node is either not visible or not an HTMLElement|Node is detached from document/
|
||||
);
|
||||
});
|
||||
it('should not hang with zero width/height element', async () => {
|
||||
|
Loading…
Reference in New Issue
Block a user