| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 base::TimeTicks start_time = base::TimeTicks::Now(); | 259 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 260 while (true) { | 260 while (true) { |
| 261 std::unique_ptr<base::Value> temp; | 261 std::unique_ptr<base::Value> temp; |
| 262 Status status = web_view->CallFunction( | 262 Status status = web_view->CallFunction( |
| 263 session->GetCurrentFrameId(), script, arguments, &temp); | 263 session->GetCurrentFrameId(), script, arguments, &temp); |
| 264 if (status.IsError()) | 264 if (status.IsError()) |
| 265 return status; | 265 return status; |
| 266 | 266 |
| 267 if (!temp->IsType(base::Value::Type::NONE)) { | 267 if (!temp->IsType(base::Value::Type::NONE)) { |
| 268 if (only_one) { | 268 if (only_one) { |
| 269 value->reset(temp.release()); | 269 *value = std::move(temp); |
| 270 return Status(kOk); | 270 return Status(kOk); |
| 271 } else { | 271 } else { |
| 272 base::ListValue* result; | 272 base::ListValue* result; |
| 273 if (!temp->GetAsList(&result)) | 273 if (!temp->GetAsList(&result)) |
| 274 return Status(kUnknownError, "script returns unexpected result"); | 274 return Status(kUnknownError, "script returns unexpected result"); |
| 275 if (result->GetSize() > 0U) { | 275 if (result->GetSize() > 0U) { |
| 276 value->reset(temp.release()); | 276 *value = std::move(temp); |
| 277 return Status(kOk); | 277 return Status(kOk); |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 } | 280 } |
| 281 | 281 |
| 282 if (base::TimeTicks::Now() - start_time >= session->implicit_wait) { | 282 if (base::TimeTicks::Now() - start_time >= session->implicit_wait) { |
| 283 if (only_one) { | 283 if (only_one) { |
| 284 return Status(kNoSuchElement, "Unable to locate element: {\"method\":\"" | 284 return Status(kNoSuchElement, "Unable to locate element: {\"method\":\"" |
| 285 + strategy + "\",\"selector\":\"" + target + "\"}"); | 285 + strategy + "\",\"selector\":\"" + target + "\"}"); |
| 286 } else { | 286 } else { |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 status = ScrollElementRegionIntoViewHelper( | 654 status = ScrollElementRegionIntoViewHelper( |
| 655 rit->parent_frame_id, web_view, frame_element_id, | 655 rit->parent_frame_id, web_view, frame_element_id, |
| 656 WebRect(region_offset, region_size), | 656 WebRect(region_offset, region_size), |
| 657 center, frame_element_id, ®ion_offset); | 657 center, frame_element_id, ®ion_offset); |
| 658 if (status.IsError()) | 658 if (status.IsError()) |
| 659 return status; | 659 return status; |
| 660 } | 660 } |
| 661 *location = region_offset; | 661 *location = region_offset; |
| 662 return Status(kOk); | 662 return Status(kOk); |
| 663 } | 663 } |
| OLD | NEW |