chore: implement partial ElementHandle.prototype.boundingBox
(#10660)
This commit is contained in:
parent
7de91f16b4
commit
04369db145
@ -19,6 +19,7 @@ import * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
|
|||||||
import {
|
import {
|
||||||
AutofillData,
|
AutofillData,
|
||||||
ElementHandle as BaseElementHandle,
|
ElementHandle as BaseElementHandle,
|
||||||
|
BoundingBox,
|
||||||
ClickOptions,
|
ClickOptions,
|
||||||
} from '../../api/ElementHandle.js';
|
} from '../../api/ElementHandle.js';
|
||||||
import {KeyPressOptions, KeyboardTypeOptions} from '../../api/Input.js';
|
import {KeyPressOptions, KeyboardTypeOptions} from '../../api/Input.js';
|
||||||
@ -85,6 +86,28 @@ export class ElementHandle<
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override async boundingBox(): Promise<BoundingBox | null> {
|
||||||
|
if (this.frame.parentFrame()) {
|
||||||
|
throw new Error(
|
||||||
|
'Elements within nested iframes are currently not supported.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const box = await this.frame.isolatedRealm().evaluate(element => {
|
||||||
|
const rect = (element as unknown as Element).getBoundingClientRect();
|
||||||
|
if (!rect.left && !rect.top && !rect.width && !rect.height) {
|
||||||
|
// TODO(jrandolf): Detect if the element is truly not visible.
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
x: rect.left,
|
||||||
|
y: rect.top,
|
||||||
|
width: rect.width,
|
||||||
|
height: rect.height,
|
||||||
|
};
|
||||||
|
}, this);
|
||||||
|
return box;
|
||||||
|
}
|
||||||
|
|
||||||
// ///////////////////
|
// ///////////////////
|
||||||
// // Input methods //
|
// // Input methods //
|
||||||
// ///////////////////
|
// ///////////////////
|
||||||
|
@ -545,6 +545,30 @@
|
|||||||
"parameters": ["webDriverBiDi"],
|
"parameters": ["webDriverBiDi"],
|
||||||
"expectations": ["PASS"]
|
"expectations": ["PASS"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"testIdPattern": "[elementhandle.spec] ElementHandle specs ElementHandle.boundingBox should force a layout",
|
||||||
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
"parameters": ["webDriverBiDi"],
|
||||||
|
"expectations": ["PASS"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"testIdPattern": "[elementhandle.spec] ElementHandle specs ElementHandle.boundingBox should return null for invisible elements",
|
||||||
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
"parameters": ["webDriverBiDi"],
|
||||||
|
"expectations": ["PASS"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"testIdPattern": "[elementhandle.spec] ElementHandle specs ElementHandle.boundingBox should work",
|
||||||
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
"parameters": ["webDriverBiDi"],
|
||||||
|
"expectations": ["PASS"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"testIdPattern": "[elementhandle.spec] ElementHandle specs ElementHandle.boundingBox should work with SVG nodes",
|
||||||
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
"parameters": ["webDriverBiDi"],
|
||||||
|
"expectations": ["PASS"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[elementhandle.spec] ElementHandle specs ElementHandle.click should not work for TextNodes",
|
"testIdPattern": "[elementhandle.spec] ElementHandle specs ElementHandle.click should not work for TextNodes",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
@ -947,6 +971,12 @@
|
|||||||
"parameters": ["webDriverBiDi"],
|
"parameters": ["webDriverBiDi"],
|
||||||
"expectations": ["PASS"]
|
"expectations": ["PASS"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"testIdPattern": "[mouse.spec] Mouse should resize the textarea",
|
||||||
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
"parameters": ["webDriverBiDi"],
|
||||||
|
"expectations": ["PASS"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[mouse.spec] Mouse should trigger hover state",
|
"testIdPattern": "[mouse.spec] Mouse should trigger hover state",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
@ -1859,6 +1889,12 @@
|
|||||||
"parameters": ["cdp", "firefox"],
|
"parameters": ["cdp", "firefox"],
|
||||||
"expectations": ["FAIL"]
|
"expectations": ["FAIL"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"testIdPattern": "[elementhandle.spec] ElementHandle specs ElementHandle.boundingBox should force a layout",
|
||||||
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
"parameters": ["firefox", "webDriverBiDi"],
|
||||||
|
"expectations": ["FAIL"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[elementhandle.spec] ElementHandle specs ElementHandle.boundingBox should handle nested frames",
|
"testIdPattern": "[elementhandle.spec] ElementHandle specs ElementHandle.boundingBox should handle nested frames",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
@ -1877,6 +1913,12 @@
|
|||||||
"parameters": ["cdp", "firefox"],
|
"parameters": ["cdp", "firefox"],
|
||||||
"expectations": ["FAIL", "PASS"]
|
"expectations": ["FAIL", "PASS"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"testIdPattern": "[elementhandle.spec] ElementHandle specs ElementHandle.boundingBox should work",
|
||||||
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
"parameters": ["firefox", "webDriverBiDi"],
|
||||||
|
"expectations": ["FAIL"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[elementhandle.spec] ElementHandle specs ElementHandle.boxModel should return null for invisible elements",
|
"testIdPattern": "[elementhandle.spec] ElementHandle specs ElementHandle.boxModel should return null for invisible elements",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
@ -2471,6 +2513,12 @@
|
|||||||
"parameters": ["cdp", "firefox"],
|
"parameters": ["cdp", "firefox"],
|
||||||
"expectations": ["SKIP"]
|
"expectations": ["SKIP"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"testIdPattern": "[mouse.spec] Mouse should resize the textarea",
|
||||||
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
"parameters": ["firefox", "webDriverBiDi"],
|
||||||
|
"expectations": ["FAIL"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[mouse.spec] Mouse should select the text with mouse",
|
"testIdPattern": "[mouse.spec] Mouse should select the text with mouse",
|
||||||
"platforms": ["win32"],
|
"platforms": ["win32"],
|
||||||
|
@ -170,9 +170,10 @@ export function getExpectationUpdates(
|
|||||||
// If an error occurs during a hook
|
// If an error occurs during a hook
|
||||||
// the error not have a file associated with it
|
// the error not have a file associated with it
|
||||||
if (!failure.file) {
|
if (!failure.file) {
|
||||||
|
console.error('Hook failed:', failure.err);
|
||||||
addEntry({
|
addEntry({
|
||||||
expectation: {
|
expectation: {
|
||||||
testIdPattern: 'Hook failed!',
|
testIdPattern: failure.fullTitle,
|
||||||
platforms: context.platforms,
|
platforms: context.platforms,
|
||||||
parameters: context.parameters,
|
parameters: context.parameters,
|
||||||
expectations: [],
|
expectations: [],
|
||||||
|
Loading…
Reference in New Issue
Block a user