| 38 | } |
| 39 | |
| 40 | LRESULT AsyncScriptExecutor::OnCreate(UINT uMsg, |
| 41 | WPARAM wParam, |
| 42 | LPARAM lParam, |
| 43 | BOOL& bHandled) { |
| 44 | LOG(TRACE) << "Entering AsyncScriptExecutor::OnCreate"; |
| 45 | |
| 46 | CREATESTRUCT* create = reinterpret_cast<CREATESTRUCT*>(lParam); |
| 47 | AsyncScriptExecutorThreadContext* context = reinterpret_cast<AsyncScriptExecutorThreadContext*>(create->lpCreateParams); |
| 48 | |
| 49 | this->script_source_code_ = context->script_source; |
| 50 | this->script_argument_count_ = context->script_argument_count; |
| 51 | this->script_argument_index_ = 0; |
| 52 | std::wstring serialized_args = context->serialized_script_args; |
| 53 | this->main_element_repository_handle_ = context->main_element_repository_handle; |
| 54 | if (serialized_args.size() > 0) { |
| 55 | std::string parse_errors; |
| 56 | std::stringstream json_stream; |
| 57 | json_stream.str(StringUtilities::ToString(serialized_args)); |
| 58 | Json::parseFromStream(Json::CharReaderBuilder(), |
| 59 | json_stream, |
| 60 | &this->script_args_, |
| 61 | &parse_errors); |
| 62 | |
| 63 | if (this->script_args_.isArray()) { |
| 64 | this->GetElementIdList(this->script_args_); |
| 65 | this->script_argument_count_ = this->script_args_.size(); |
| 66 | } |
| 67 | } else { |
| 68 | this->main_element_repository_handle_ = NULL; |
| 69 | this->script_args_ = Json::Value::null; |
| 70 | } |
| 71 | // Calling vector::resize() is okay here, because the vector |
| 72 | // should be empty when Initialize() is called, and the |
| 73 | // reallocation of variants shouldn't give us too much of a |
| 74 | // negative impact. |
| 75 | this->script_arguments_.resize(this->script_argument_count_); |
| 76 | this->status_code_ = WD_SUCCESS; |
| 77 | this->is_execution_completed_ = false; |
| 78 | this->is_listener_attached_ = true; |
| 79 | this->element_repository_ = new ElementRepository(); |
| 80 | this->polling_script_source_code_ = L""; |
| 81 | return 0; |
| 82 | } |
| 83 | |
| 84 | LRESULT AsyncScriptExecutor::OnClose(UINT uMsg, |
| 85 | WPARAM wParam, |
nothing calls this directly
no test coverage detected