| 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_commands.h" | 5 #include "chrome/test/chromedriver/element_commands.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 Status status = IsElementAttributeEqualToIgnoreCase( | 210 Status status = IsElementAttributeEqualToIgnoreCase( |
| 211 session, web_view, element_id, "tagName", "input", &is_input); | 211 session, web_view, element_id, "tagName", "input", &is_input); |
| 212 if (status.IsError()) | 212 if (status.IsError()) |
| 213 return status; | 213 return status; |
| 214 bool is_file = false; | 214 bool is_file = false; |
| 215 status = IsElementAttributeEqualToIgnoreCase( | 215 status = IsElementAttributeEqualToIgnoreCase( |
| 216 session, web_view, element_id, "type", "file", &is_file); | 216 session, web_view, element_id, "type", "file", &is_file); |
| 217 if (status.IsError()) | 217 if (status.IsError()) |
| 218 return status; | 218 return status; |
| 219 if (is_input && is_file) { | 219 if (is_input && is_file) { |
| 220 // File upload is only supported for chrome 27+. | |
| 221 if (session->chrome->GetBuildNo() < 1420) { | |
| 222 return Status( | |
| 223 kUnknownError, | |
| 224 base::StringPrintf( | |
| 225 "file upload requires chrome 27+, build 1420+," | |
| 226 "while current one is %s", | |
| 227 session->chrome->GetVersion().c_str())); | |
| 228 } | |
| 229 | |
| 230 // Compress array into a single string. | 220 // Compress array into a single string. |
| 231 base::FilePath::StringType paths_string; | 221 base::FilePath::StringType paths_string; |
| 232 for (size_t i = 0; i < key_list->GetSize(); ++i) { | 222 for (size_t i = 0; i < key_list->GetSize(); ++i) { |
| 233 base::FilePath::StringType path_part; | 223 base::FilePath::StringType path_part; |
| 234 if (!key_list->GetString(i, &path_part)) | 224 if (!key_list->GetString(i, &path_part)) |
| 235 return Status(kUnknownError, "'value' is invalid"); | 225 return Status(kUnknownError, "'value' is invalid"); |
| 236 paths_string.append(path_part); | 226 paths_string.append(path_part); |
| 237 } | 227 } |
| 238 | 228 |
| 239 // Separate the string into separate paths, delimited by '\n'. | 229 // Separate the string into separate paths, delimited by '\n'. |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 WebView* web_view, | 434 WebView* web_view, |
| 445 const std::string& element_id, | 435 const std::string& element_id, |
| 446 const base::DictionaryValue& params, | 436 const base::DictionaryValue& params, |
| 447 scoped_ptr<base::Value>* value) { | 437 scoped_ptr<base::Value>* value) { |
| 448 std::string other_element_id; | 438 std::string other_element_id; |
| 449 if (!params.GetString("other", &other_element_id)) | 439 if (!params.GetString("other", &other_element_id)) |
| 450 return Status(kUnknownError, "'other' must be a string"); | 440 return Status(kUnknownError, "'other' must be a string"); |
| 451 value->reset(new base::FundamentalValue(element_id == other_element_id)); | 441 value->reset(new base::FundamentalValue(element_id == other_element_id)); |
| 452 return Status(kOk); | 442 return Status(kOk); |
| 453 } | 443 } |
| OLD | NEW |