Skip to content

Commit 99773d9

Browse files
committed
fixed incorrect behaviour GetClickableLocation for invalid position.
1 parent 86e493f commit 99773d9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/webdriver/extension_qt/qwebkit_proxy.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1758,8 +1758,13 @@ Error* QWebkitProxy::GetClickableLocation(const ElementId& element, Point* locat
17581758
// client rect, and lastly the size of the element (via closure).
17591759
// SVG is one case that doesn't have a first client rect.
17601760
Rect rect;
1761+
17611762
scoped_ptr<Error> ignore_error(GetElementFirstClientRect(GetFrame(session_->current_frame()),element, &rect));
1762-
if (ignore_error.get()) {
1763+
1764+
// getFirstClientRect by atoms sometimes doesn't throw Error but returns invalid position outside element.
1765+
bool invalid_pos = (int)rect.y() < 0 || (int)rect.x() < 0;
1766+
1767+
if (ignore_error.get() || invalid_pos) {
17631768
Rect client_rect;
17641769

17651770
ignore_error.reset(ExecuteScriptAndParse(
@@ -1790,6 +1795,7 @@ Error* QWebkitProxy::GetClickableLocation(const ElementId& element, Point* locat
17901795
return error;
17911796

17921797
location->Offset(rect.width() / 2, rect.height() / 2);
1798+
17931799
return NULL;
17941800
}
17951801

0 commit comments

Comments
 (0)