browser(firefox): Page.scrollIntoViewIfNeeded throws for invisible elements (#2584)
This is similar to other browsers that report distinct errors for 'not connected' vs 'not visible' cases.
This commit is contained in:
parent
1bc04a088b
commit
9e7ea3ff7b
|
|
@ -1 +1 @@
|
|||
1108
|
||||
1109
|
||||
|
|
|
|||
|
|
@ -621,6 +621,17 @@ class PageAgent {
|
|||
const unsafeObject = this._frameData.get(frame).unsafeObject(objectId);
|
||||
if (!unsafeObject.isConnected)
|
||||
throw new Error('Node is detached from document');
|
||||
if (!unsafeObject.ownerDocument || !unsafeObject.ownerDocument.defaultView)
|
||||
throw new Error('Node is detached from document');
|
||||
const element = unsafeObject.nodeType === 1 ? unsafeObject : unsafeObject.parentElement;
|
||||
if (!element)
|
||||
throw new Error('Node is detached from document');
|
||||
const style = unsafeObject.ownerDocument.defaultView.getComputedStyle(element);
|
||||
if (!style || style.visibility === 'hidden')
|
||||
throw new Error('Node is not visible');
|
||||
const bounds = element.getBoundingClientRect();
|
||||
if (bounds.width <= 0 || bounds.height <= 0)
|
||||
throw new Error('Node is not visible');
|
||||
if (!rect)
|
||||
rect = { x: -1, y: -1, width: -1, height: -1};
|
||||
if (unsafeObject.scrollRectIntoViewIfNeeded)
|
||||
|
|
|
|||
Loading…
Reference in a new issue