OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/webdriver/commands/mouse_commands.h" | 5 #include "chrome/test/webdriver/commands/mouse_commands.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/common/automation_constants.h" | 8 #include "chrome/common/automation_constants.h" |
9 #include "chrome/test/automation/value_conversion_util.h" | 9 #include "chrome/test/automation/value_conversion_util.h" |
10 #include "chrome/test/webdriver/commands/response.h" | 10 #include "chrome/test/webdriver/commands/response.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 Error* error = session_->GetElementTagName( | 40 Error* error = session_->GetElementTagName( |
41 session_->current_target(), element, &tag_name); | 41 session_->current_target(), element, &tag_name); |
42 if (error) { | 42 if (error) { |
43 response->SetError(error); | 43 response->SetError(error); |
44 return; | 44 return; |
45 } | 45 } |
46 | 46 |
47 if (tag_name == "option") { | 47 if (tag_name == "option") { |
48 const char* kCanOptionBeToggledScript = | 48 const char* kCanOptionBeToggledScript = |
49 "function(option) {" | 49 "function(option) {" |
50 " var select = option.parentElement;" | 50 " for (var parent = option.parentElement;" |
51 " if (!select || select.tagName.toLowerCase() != 'select')" | 51 " parent;" |
52 " throw new Error('Option element is not in a select');" | 52 " parent = parent.parentElement) {" |
53 " return select.multiple;" | 53 " if (parent.tagName.toLowerCase() == 'select') {" |
54 "}"; | 54 " return parent.multiple;" |
| 55 " }" |
| 56 " }" |
| 57 " throw new Error('Option element is not in a select');" |
| 58 "};"; |
55 bool can_be_toggled; | 59 bool can_be_toggled; |
56 error = session_->ExecuteScriptAndParse( | 60 error = session_->ExecuteScriptAndParse( |
57 session_->current_target(), | 61 session_->current_target(), |
58 kCanOptionBeToggledScript, | 62 kCanOptionBeToggledScript, |
59 "canOptionBeToggled", | 63 "canOptionBeToggled", |
60 CreateListValueFrom(element), | 64 CreateListValueFrom(element), |
61 CreateDirectValueParser(&can_be_toggled)); | 65 CreateDirectValueParser(&can_be_toggled)); |
62 if (error) { | 66 if (error) { |
63 response->SetError(error); | 67 response->SetError(error); |
64 return; | 68 return; |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 306 |
303 void DoubleClickCommand::ExecutePost(Response* const response) { | 307 void DoubleClickCommand::ExecutePost(Response* const response) { |
304 Error* error = session_->MouseDoubleClick(); | 308 Error* error = session_->MouseDoubleClick(); |
305 if (error) { | 309 if (error) { |
306 response->SetError(error); | 310 response->SetError(error); |
307 return; | 311 return; |
308 } | 312 } |
309 } | 313 } |
310 | 314 |
311 } // namespace webdriver | 315 } // namespace webdriver |
OLD | NEW |