| 536 | } |
| 537 | |
| 538 | int Script::SetAsyncScriptElementArgument(HWND async_executor_handle, |
| 539 | const IECommandExecutor& command_executor, |
| 540 | const std::string& element_id) { |
| 541 | LOG(TRACE) << "Entering Script::SetAsyncScriptElementArgument"; |
| 542 | ElementInfo* info = new ElementInfo; |
| 543 | info->element_id = element_id; |
| 544 | ElementHandle element_wrapper; |
| 545 | int return_code = command_executor.GetManagedElement(element_id, |
| 546 | &element_wrapper); |
| 547 | if (return_code != WD_SUCCESS) { |
| 548 | LOG(WARN) << "Element requested with id " << element_id |
| 549 | << " does not exist."; |
| 550 | return return_code; |
| 551 | } |
| 552 | HRESULT hr = ::CoMarshalInterThreadInterfaceInStream(IID_IHTMLElement, |
| 553 | element_wrapper->element(), |
| 554 | &info->element_stream); |
| 555 | if (FAILED(hr)) { |
| 556 | CComVariant result; |
| 557 | CComBSTR error_description = L""; |
| 558 | LOGHR(WARN, hr) << "CoMarshalInterfaceThreadInStream() for IDispatch argument failed"; |
| 559 | result.Clear(); |
| 560 | result.vt = VT_BSTR; |
| 561 | error_description = L"Couldn't marshal the IDispatch interface to a stream. This is an internal COM error."; |
| 562 | result.bstrVal = error_description; |
| 563 | this->result_.Copy(&result); |
| 564 | return EUNEXPECTEDJSERROR; |
| 565 | } |
| 566 | ::PostMessage(async_executor_handle, |
| 567 | WD_ASYNC_SCRIPT_SET_ELEMENT_ARGUMENT, |
| 568 | NULL, |
| 569 | reinterpret_cast<LPARAM>(info)); |
| 570 | return return_code; |
| 571 | } |
| 572 | |
| 573 | int Script::ConvertResultToJsonValue(const IECommandExecutor& executor, |
| 574 | Json::Value* value) { |
no test coverage detected