Improve getElementPosition() for handling elements within a shadow root
Some checks are pending
CodeQL / Analyze (javascript) (push) Waiting to run

This commit is contained in:
Namhyeon Go 2025-05-21 15:48:19 +09:00 committed by GitHub
parent 710acc4bbd
commit a81ccc0efa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -759,6 +759,31 @@ var ChromeObject = function() {
}
};
this.getDeepElementPosition = function(selectors) {
var result = this.getEvaluatedValue('(function() { var rect = __getDocument().' + this.getShadowRootSelector(selectors) + '.getBoundingClientRect(); return [parseInt(rect.left), parseInt(rect.top), parseInt(__getWindow().pageXOffset + rect.left), parseInt(__getWindow().pageYOffset + rect.top), parseInt(rect.width), parseInt(rect.height)].join(","); })();');
var pos = result.split(',');
if (pos.length == 6) {
return {
"x": parseInt(pos[0]),
"y": parseInt(pos[1]),
"a": parseInt(pos[2]),
"b": parseInt(pos[3]),
"w": parseInt(pos[4]),
"h": parseInt(pos[5])
};
} else {
return {
"x": -1,
"y": -1,
"a": -1,
"b": -1,
"g": -1,
"d": -1
};
}
};
this.getElementPositionByText = function(selector, searchText) {
var result;
var pos = -1;
@ -1423,7 +1448,7 @@ exports.startDebugInPrivate = function(url, proxy, profileName, debuggingPort, i
;
};
exports.VERSIONINFO = "Chrome Web Browser Debugging Interface (chrome.js) version 0.4.15";
exports.VERSIONINFO = "Chrome Web Browser Debugging Interface (chrome.js) version 0.4.16";
exports.AUTHOR = "abuse@catswords.net";
exports.global = global;
exports.require = global.require;