Commit 45d9b0f1 authored by samuong's avatar samuong Committed by Commit bot

[chromedriver] Make GetElementLocationInView return the top-left coordinate rather than the center

Also fix testMoveToElementAndClick on Android.

BUG=

Review URL: https://codereview.chromium.org/817913004

Cr-Commit-Position: refs/heads/master@{#311556}
parent bfdc2080
...@@ -443,9 +443,10 @@ Status ExecuteGetElementLocationOnceScrolledIntoView( ...@@ -443,9 +443,10 @@ Status ExecuteGetElementLocationOnceScrolledIntoView(
const std::string& element_id, const std::string& element_id,
const base::DictionaryValue& params, const base::DictionaryValue& params,
scoped_ptr<base::Value>* value) { scoped_ptr<base::Value>* value) {
WebPoint offset(0, 0);
WebPoint location; WebPoint location;
Status status = ScrollElementIntoView( Status status = ScrollElementIntoView(
session, web_view, element_id, nullptr, &location); session, web_view, element_id, &offset, &location);
if (status.IsError()) if (status.IsError())
return status; return status;
value->reset(CreateValueFrom(location)); value->reset(CreateValueFrom(location));
......
...@@ -127,6 +127,11 @@ Status ToggleOptionElement( ...@@ -127,6 +127,11 @@ Status ToggleOptionElement(
WebView* web_view, WebView* web_view,
const std::string& element_id); const std::string& element_id);
// |offset| is an optional offset from the top-left of the first ClientRect
// that is returned by the element's getClientRects() function.
// If |offset| is null, the |location| returned will be the center of the
// ClientRect. If it is non-null, |location| will be offset by the specified
// value.
Status ScrollElementIntoView( Status ScrollElementIntoView(
Session* session, Session* session,
WebView* web_view, WebView* web_view,
......
...@@ -5,8 +5,11 @@ ...@@ -5,8 +5,11 @@
<title>A multi-line link</title> <title>A multi-line link</title>
</head> </head>
<body> <body>
<p style="max-width: 11em"> <p style="max-width: 15em">
This test page contains <a href="#top">a link</a> that spans two lines. mmmmmmmmmm <a href="#top">mmmmm mmmmm</a> mmmmmmmmmm
</p>
<p>
This test page contains a link that spans two lines.
The center of the bounding box of the link is not inside the link element. The center of the bounding box of the link is not inside the link element.
</p> </p>
</body> </body>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment