| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/test/chromedriver/element_util.h" | 5 #include "chrome/test/chromedriver/element_util.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/test/chromedriver/basic_types.h" | 13 #include "chrome/test/chromedriver/basic_types.h" |
| 14 #include "chrome/test/chromedriver/chrome/chrome.h" |
| 14 #include "chrome/test/chromedriver/chrome/js.h" | 15 #include "chrome/test/chromedriver/chrome/js.h" |
| 15 #include "chrome/test/chromedriver/chrome/status.h" | 16 #include "chrome/test/chromedriver/chrome/status.h" |
| 16 #include "chrome/test/chromedriver/chrome/web_view.h" | 17 #include "chrome/test/chromedriver/chrome/web_view.h" |
| 17 #include "chrome/test/chromedriver/session.h" | 18 #include "chrome/test/chromedriver/session.h" |
| 18 #include "third_party/webdriver/atoms.h" | 19 #include "third_party/webdriver/atoms.h" |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 const char kElementKey[] = "ELEMENT"; | 23 const char kElementKey[] = "ELEMENT"; |
| 23 | 24 |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 if (status.IsError()) | 385 if (status.IsError()) |
| 385 return status; | 386 return status; |
| 386 if (!is_displayed) | 387 if (!is_displayed) |
| 387 return Status(kElementNotVisible); | 388 return Status(kElementNotVisible); |
| 388 | 389 |
| 389 WebRect rect; | 390 WebRect rect; |
| 390 status = GetElementRegion(session, web_view, element_id, &rect); | 391 status = GetElementRegion(session, web_view, element_id, &rect); |
| 391 if (status.IsError()) | 392 if (status.IsError()) |
| 392 return status; | 393 return status; |
| 393 | 394 |
| 395 std::string tmp_element_id = element_id; |
| 396 if (tag_name == "area" && session->chrome->GetBuildNo() < 1799 && |
| 397 session->chrome->GetBuildNo() >= 1666) { |
| 398 // This is to skip clickable verification for <area>. |
| 399 // The problem is caused by document.ElementFromPoint(crbug.com/338601). |
| 400 // It was introduced by blink r159012, which rolled into chromium r227489. |
| 401 // And it was fixed in blink r165426, which rolled into chromium r245994. |
| 402 // TODO(stgao): Revert after 33 is not supported. |
| 403 tmp_element_id = std::string(); |
| 404 } |
| 405 |
| 394 status = ScrollElementRegionIntoView( | 406 status = ScrollElementRegionIntoView( |
| 395 session, web_view, target_element_id, rect, | 407 session, web_view, target_element_id, rect, |
| 396 true /* center */, element_id, location); | 408 true /* center */, tmp_element_id, location); |
| 397 if (status.IsError()) | 409 if (status.IsError()) |
| 398 return status; | 410 return status; |
| 399 location->Offset(rect.Width() / 2, rect.Height() / 2); | 411 location->Offset(rect.Width() / 2, rect.Height() / 2); |
| 400 return Status(kOk); | 412 return Status(kOk); |
| 401 } | 413 } |
| 402 | 414 |
| 403 Status GetElementEffectiveStyle( | 415 Status GetElementEffectiveStyle( |
| 404 Session* session, | 416 Session* session, |
| 405 WebView* web_view, | 417 WebView* web_view, |
| 406 const std::string& element_id, | 418 const std::string& element_id, |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 status = ScrollElementRegionIntoViewHelper( | 644 status = ScrollElementRegionIntoViewHelper( |
| 633 rit->parent_frame_id, web_view, frame_element_id, | 645 rit->parent_frame_id, web_view, frame_element_id, |
| 634 WebRect(region_offset, region_size), | 646 WebRect(region_offset, region_size), |
| 635 center, frame_element_id, ®ion_offset); | 647 center, frame_element_id, ®ion_offset); |
| 636 if (status.IsError()) | 648 if (status.IsError()) |
| 637 return status; | 649 return status; |
| 638 } | 650 } |
| 639 *location = region_offset; | 651 *location = region_offset; |
| 640 return Status(kOk); | 652 return Status(kOk); |
| 641 } | 653 } |
| OLD | NEW |