| 40 | } |
| 41 | |
| 42 | int IECommandHandler::GetElement(const IECommandExecutor& executor, |
| 43 | const std::string& element_id, |
| 44 | ElementHandle* element_wrapper) { |
| 45 | LOG(TRACE) << "Entering IECommandHandler::GetElement"; |
| 46 | ElementHandle candidate_wrapper; |
| 47 | int result = executor.GetManagedElement(element_id, &candidate_wrapper); |
| 48 | if (result != WD_SUCCESS) { |
| 49 | LOG(WARN) << "Unable to get managed element, element not found"; |
| 50 | return result; |
| 51 | } else { |
| 52 | if (!candidate_wrapper->IsAttachedToDom()) { |
| 53 | LOG(WARN) << "Found managed element is no longer valid"; |
| 54 | IECommandExecutor& mutable_executor = const_cast<IECommandExecutor&>(executor); |
| 55 | mutable_executor.RemoveManagedElement(element_id); |
| 56 | return EOBSOLETEELEMENT; |
| 57 | } else { |
| 58 | // If the element is attached to the DOM, validate that its document |
| 59 | // is the currently-focused document (via frames). |
| 60 | BrowserHandle current_browser; |
| 61 | executor.GetCurrentBrowser(¤t_browser); |
| 62 | CComPtr<IHTMLDocument2> focused_doc; |
| 63 | current_browser->GetDocument(&focused_doc); |
| 64 | |
| 65 | if (candidate_wrapper->IsDocumentFocused(focused_doc)) { |
| 66 | *element_wrapper = candidate_wrapper; |
| 67 | return WD_SUCCESS; |
| 68 | } else { |
| 69 | LOG(WARN) << "Found managed element's document is not currently focused"; |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | return EOBSOLETEELEMENT; |
| 75 | } |
| 76 | |
| 77 | Json::Value IECommandHandler::RecreateJsonParameterObject(const ParametersMap& command_parameters) { |
| 78 | Json::Value result; |
no test coverage detected