From 73790dc356faca9163e802b0ad2cd2fc26c5064f Mon Sep 17 00:00:00 2001 From: wengchangcheng Date: Wed, 8 Jun 2022 15:48:56 +0800 Subject: [PATCH 1/3] Descriptor: debugger refactor of independent js_runtime [ part-2 ] details: use pt json to parse message issue: https://gitee.com/openharmony/ark_js_runtime/issues/I5BBPM Signed-off-by: wengchangcheng Change-Id: I3bdc5475f8d500754d0b58af28a17775fbcf2e7c --- .../jspandafile/js_pandafile_manager.cpp | 12 +- ecmascript/tooling/agent/debugger_impl.cpp | 20 +- .../tooling/agent/heapprofiler_impl.cpp | 14 +- ecmascript/tooling/agent/profiler_impl.cpp | 4 +- ecmascript/tooling/agent/runtime_impl.cpp | 5 +- ecmascript/tooling/base/pt_json.cpp | 8 +- ecmascript/tooling/base/pt_json.h | 4 +- ecmascript/tooling/base/pt_params.cpp | 2 +- ecmascript/tooling/base/pt_params.h | 2 +- ecmascript/tooling/base/pt_returns.h | 4 + ecmascript/tooling/base/pt_types.h | 5 + ecmascript/tooling/dispatcher.cpp | 61 ++- ecmascript/tooling/dispatcher.h | 13 +- .../tooling/test/debugger_params_test.cpp | 128 ++--- .../tooling/test/debugger_types_test.cpp | 464 +++++++++--------- 15 files changed, 391 insertions(+), 355 deletions(-) diff --git a/ecmascript/jspandafile/js_pandafile_manager.cpp b/ecmascript/jspandafile/js_pandafile_manager.cpp index 1ac1f2a5b..575473d55 100644 --- a/ecmascript/jspandafile/js_pandafile_manager.cpp +++ b/ecmascript/jspandafile/js_pandafile_manager.cpp @@ -110,7 +110,7 @@ const JSPandaFile *JSPandaFileManager::LoadJSPandaFile(const CString &filename, JSHandle JSPandaFileManager::GenerateProgram(EcmaVM *vm, const JSPandaFile *jsPandaFile) { ECMA_BYTRACE_NAME(HITRACE_TAG_ARK, "JSPandaFileManager::GenerateProgram"); - LOG_ECMA(INFO) << "GenerateProgram " << jsPandaFile->GetPandaFile()->GetFilename(); + LOG_ECMA(INFO) << "GenerateProgram " << jsPandaFile->GetJSPandaFileDesc(); ASSERT(GetJSPandaFile(jsPandaFile->GetPandaFile()) != nullptr); JSHandle program = PandaFileTranslator::GenerateProgram(vm, jsPandaFile); @@ -146,7 +146,7 @@ const JSPandaFile *JSPandaFileManager::GetJSPandaFile(const panda_file::File *pf void JSPandaFileManager::InsertJSPandaFile(const JSPandaFile *jsPandaFile) { - LOG_ECMA(INFO) << "InsertJSPandaFile " << jsPandaFile->GetPandaFile()->GetFilename(); + LOG_ECMA(INFO) << "InsertJSPandaFile " << jsPandaFile->GetJSPandaFileDesc(); os::memory::LockHolder lock(jsPandaFileLock_); ASSERT(loadedJSPandaFiles_.find(jsPandaFile) == loadedJSPandaFiles_.end()); @@ -155,7 +155,7 @@ void JSPandaFileManager::InsertJSPandaFile(const JSPandaFile *jsPandaFile) void JSPandaFileManager::IncreaseRefJSPandaFile(const JSPandaFile *jsPandaFile) { - LOG_ECMA(INFO) << "IncreaseRefJSPandaFile " << jsPandaFile->GetPandaFile()->GetFilename(); + LOG_ECMA(INFO) << "IncreaseRefJSPandaFile " << jsPandaFile->GetJSPandaFileDesc(); os::memory::LockHolder lock(jsPandaFileLock_); ASSERT(loadedJSPandaFiles_.find(jsPandaFile) != loadedJSPandaFiles_.end()); @@ -164,7 +164,7 @@ void JSPandaFileManager::IncreaseRefJSPandaFile(const JSPandaFile *jsPandaFile) void JSPandaFileManager::DecreaseRefJSPandaFile(const JSPandaFile *jsPandaFile) { - LOG_ECMA(INFO) << "DecreaseRefJSPandaFile " << jsPandaFile->GetPandaFile()->GetFilename(); + LOG_ECMA(INFO) << "DecreaseRefJSPandaFile " << jsPandaFile->GetJSPandaFileDesc(); os::memory::LockHolder lock(jsPandaFileLock_); auto iter = loadedJSPandaFiles_.find(jsPandaFile); @@ -201,7 +201,7 @@ void JSPandaFileManager::ReleaseJSPandaFile(const JSPandaFile *jsPandaFile) if (jsPandaFile == nullptr) { return; } - LOG_ECMA(INFO) << "ReleaseJSPandaFile " << jsPandaFile->GetPandaFile()->GetFilename(); + LOG_ECMA(INFO) << "ReleaseJSPandaFile " << jsPandaFile->GetJSPandaFileDesc(); delete jsPandaFile; } @@ -303,7 +303,7 @@ void JSPandaFileManager::RemoveJSPandaFile(void *pointer, void *data) return; } auto jsPandaFile = static_cast(pointer); - LOG_ECMA(INFO) << "RemoveJSPandaFile " << jsPandaFile->GetPandaFile()->GetFilename(); + LOG_ECMA(INFO) << "RemoveJSPandaFile " << jsPandaFile->GetJSPandaFileDesc(); // dec ref in filemanager JSPandaFileManager *jsPandaFileManager = static_cast(data); jsPandaFileManager->DecreaseRefJSPandaFile(jsPandaFile); diff --git a/ecmascript/tooling/agent/debugger_impl.cpp b/ecmascript/tooling/agent/debugger_impl.cpp index 9c33f2c14..e632dfd4c 100644 --- a/ecmascript/tooling/agent/debugger_impl.cpp +++ b/ecmascript/tooling/agent/debugger_impl.cpp @@ -265,7 +265,7 @@ void DebuggerImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) void DebuggerImpl::DispatcherImpl::Enable(const DispatchRequest &request) { - std::unique_ptr params = EnableParams::Create(request.GetEcmaVM(), request.GetParams()); + std::unique_ptr params = EnableParams::Create(request.GetEcmaVM(), request.GetParamsObj()); if (params == nullptr) { SendResponse(request, DispatchResponse::Fail("wrong params")); return; @@ -287,7 +287,7 @@ void DebuggerImpl::DispatcherImpl::Disable(const DispatchRequest &request) void DebuggerImpl::DispatcherImpl::EvaluateOnCallFrame(const DispatchRequest &request) { std::unique_ptr params = - EvaluateOnCallFrameParams::Create(request.GetEcmaVM(), request.GetParams()); + EvaluateOnCallFrameParams::Create(request.GetEcmaVM(), request.GetParamsObj()); if (params == nullptr) { SendResponse(request, DispatchResponse::Fail("wrong params")); return; @@ -302,7 +302,7 @@ void DebuggerImpl::DispatcherImpl::EvaluateOnCallFrame(const DispatchRequest &re void DebuggerImpl::DispatcherImpl::GetPossibleBreakpoints(const DispatchRequest &request) { std::unique_ptr params = - GetPossibleBreakpointsParams::Create(request.GetEcmaVM(), request.GetParams()); + GetPossibleBreakpointsParams::Create(request.GetEcmaVM(), request.GetParamsObj()); if (params == nullptr) { SendResponse(request, DispatchResponse::Fail("wrong params")); return; @@ -316,7 +316,7 @@ void DebuggerImpl::DispatcherImpl::GetPossibleBreakpoints(const DispatchRequest void DebuggerImpl::DispatcherImpl::GetScriptSource(const DispatchRequest &request) { std::unique_ptr params = - GetScriptSourceParams::Create(request.GetEcmaVM(), request.GetParams()); + GetScriptSourceParams::Create(request.GetEcmaVM(), request.GetParamsObj()); if (params == nullptr) { SendResponse(request, DispatchResponse::Fail("wrong params")); return; @@ -336,7 +336,7 @@ void DebuggerImpl::DispatcherImpl::Pause(const DispatchRequest &request) void DebuggerImpl::DispatcherImpl::RemoveBreakpoint(const DispatchRequest &request) { std::unique_ptr params = - RemoveBreakpointParams::Create(request.GetEcmaVM(), request.GetParams()); + RemoveBreakpointParams::Create(request.GetEcmaVM(), request.GetParamsObj()); if (params == nullptr) { SendResponse(request, DispatchResponse::Fail("wrong params")); return; @@ -347,7 +347,7 @@ void DebuggerImpl::DispatcherImpl::RemoveBreakpoint(const DispatchRequest &reque void DebuggerImpl::DispatcherImpl::Resume(const DispatchRequest &request) { - std::unique_ptr params = ResumeParams::Create(request.GetEcmaVM(), request.GetParams()); + std::unique_ptr params = ResumeParams::Create(request.GetEcmaVM(), request.GetParamsObj()); if (params == nullptr) { SendResponse(request, DispatchResponse::Fail("wrong params")); return; @@ -365,7 +365,7 @@ void DebuggerImpl::DispatcherImpl::SetAsyncCallStackDepth(const DispatchRequest void DebuggerImpl::DispatcherImpl::SetBreakpointByUrl(const DispatchRequest &request) { std::unique_ptr params = - SetBreakpointByUrlParams::Create(request.GetEcmaVM(), request.GetParams()); + SetBreakpointByUrlParams::Create(request.GetEcmaVM(), request.GetParamsObj()); if (params == nullptr) { SendResponse(request, DispatchResponse::Fail("wrong params")); return; @@ -381,7 +381,7 @@ void DebuggerImpl::DispatcherImpl::SetBreakpointByUrl(const DispatchRequest &req void DebuggerImpl::DispatcherImpl::SetPauseOnExceptions(const DispatchRequest &request) { std::unique_ptr params = - SetPauseOnExceptionsParams::Create(request.GetEcmaVM(), request.GetParams()); + SetPauseOnExceptionsParams::Create(request.GetEcmaVM(), request.GetParamsObj()); if (params == nullptr) { SendResponse(request, DispatchResponse::Fail("wrong params")); return; @@ -393,7 +393,7 @@ void DebuggerImpl::DispatcherImpl::SetPauseOnExceptions(const DispatchRequest &r void DebuggerImpl::DispatcherImpl::StepInto(const DispatchRequest &request) { - std::unique_ptr params = StepIntoParams::Create(request.GetEcmaVM(), request.GetParams()); + std::unique_ptr params = StepIntoParams::Create(request.GetEcmaVM(), request.GetParamsObj()); if (params == nullptr) { SendResponse(request, DispatchResponse::Fail("wrong params")); return; @@ -410,7 +410,7 @@ void DebuggerImpl::DispatcherImpl::StepOut(const DispatchRequest &request) void DebuggerImpl::DispatcherImpl::StepOver(const DispatchRequest &request) { - std::unique_ptr params = StepOverParams::Create(request.GetEcmaVM(), request.GetParams()); + std::unique_ptr params = StepOverParams::Create(request.GetEcmaVM(), request.GetParamsObj()); if (params == nullptr) { SendResponse(request, DispatchResponse::Fail("wrong params")); return; diff --git a/ecmascript/tooling/agent/heapprofiler_impl.cpp b/ecmascript/tooling/agent/heapprofiler_impl.cpp index 3a8b6b00a..c02aff292 100644 --- a/ecmascript/tooling/agent/heapprofiler_impl.cpp +++ b/ecmascript/tooling/agent/heapprofiler_impl.cpp @@ -46,7 +46,7 @@ void HeapProfilerImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) void HeapProfilerImpl::DispatcherImpl::AddInspectedHeapObject(const DispatchRequest &request) { std::unique_ptr params = - AddInspectedHeapObjectParams::Create(request.GetEcmaVM(), request.GetParams()); + AddInspectedHeapObjectParams::Create(request.GetEcmaVM(), request.GetParamsObj()); if (params == nullptr) { SendResponse(request, DispatchResponse::Fail("wrong params")); return; @@ -76,7 +76,7 @@ void HeapProfilerImpl::DispatcherImpl::Disable(const DispatchRequest &request) void HeapProfilerImpl::DispatcherImpl::GetHeapObjectId(const DispatchRequest &request) { std::unique_ptr params = - GetHeapObjectIdParams::Create(request.GetEcmaVM(), request.GetParams()); + GetHeapObjectIdParams::Create(request.GetEcmaVM(), request.GetParamsObj()); if (params == nullptr) { SendResponse(request, DispatchResponse::Fail("wrong params")); return; @@ -91,7 +91,7 @@ void HeapProfilerImpl::DispatcherImpl::GetHeapObjectId(const DispatchRequest &re void HeapProfilerImpl::DispatcherImpl::GetObjectByHeapObjectId(const DispatchRequest &request) { std::unique_ptr params = - GetObjectByHeapObjectIdParams::Create(request.GetEcmaVM(), request.GetParams()); + GetObjectByHeapObjectIdParams::Create(request.GetEcmaVM(), request.GetParamsObj()); if (params == nullptr) { SendResponse(request, DispatchResponse::Fail("wrong params")); return; @@ -115,7 +115,7 @@ void HeapProfilerImpl::DispatcherImpl::GetSamplingProfile(const DispatchRequest void HeapProfilerImpl::DispatcherImpl::StartSampling(const DispatchRequest &request) { std::unique_ptr params = - StartSamplingParams::Create(request.GetEcmaVM(), request.GetParams()); + StartSamplingParams::Create(request.GetEcmaVM(), request.GetParamsObj()); if (params == nullptr) { SendResponse(request, DispatchResponse::Fail("wrong params")); return; @@ -127,7 +127,7 @@ void HeapProfilerImpl::DispatcherImpl::StartSampling(const DispatchRequest &requ void HeapProfilerImpl::DispatcherImpl::StartTrackingHeapObjects(const DispatchRequest &request) { std::unique_ptr params = - StartTrackingHeapObjectsParams::Create(request.GetEcmaVM(), request.GetParams()); + StartTrackingHeapObjectsParams::Create(request.GetEcmaVM(), request.GetParamsObj()); if (params == nullptr) { SendResponse(request, DispatchResponse::Fail("wrong params")); return; @@ -148,7 +148,7 @@ void HeapProfilerImpl::DispatcherImpl::StopSampling(const DispatchRequest &reque void HeapProfilerImpl::DispatcherImpl::StopTrackingHeapObjects(const DispatchRequest &request) { std::unique_ptr params = - StopTrackingHeapObjectsParams::Create(request.GetEcmaVM(), request.GetParams()); + StopTrackingHeapObjectsParams::Create(request.GetEcmaVM(), request.GetParamsObj()); if (params == nullptr) { SendResponse(request, DispatchResponse::Fail("wrong params")); return; @@ -160,7 +160,7 @@ void HeapProfilerImpl::DispatcherImpl::StopTrackingHeapObjects(const DispatchReq void HeapProfilerImpl::DispatcherImpl::TakeHeapSnapshot(const DispatchRequest &request) { std::unique_ptr params = - StopTrackingHeapObjectsParams::Create(request.GetEcmaVM(), request.GetParams()); + StopTrackingHeapObjectsParams::Create(request.GetEcmaVM(), request.GetParamsObj()); if (params == nullptr) { SendResponse(request, DispatchResponse::Fail("wrong params")); return; diff --git a/ecmascript/tooling/agent/profiler_impl.cpp b/ecmascript/tooling/agent/profiler_impl.cpp index d0870ddbd..b07e4abd7 100644 --- a/ecmascript/tooling/agent/profiler_impl.cpp +++ b/ecmascript/tooling/agent/profiler_impl.cpp @@ -77,7 +77,7 @@ void ProfilerImpl::DispatcherImpl::Stop(const DispatchRequest &request) void ProfilerImpl::DispatcherImpl::SetSamplingInterval(const DispatchRequest &request) { std::unique_ptr params = - SetSamplingIntervalParams::Create(request.GetEcmaVM(), request.GetParams()); + SetSamplingIntervalParams::Create(request.GetEcmaVM(), request.GetParamsObj()); if (params == nullptr) { SendResponse(request, DispatchResponse::Fail("wrong params")); return; @@ -107,7 +107,7 @@ void ProfilerImpl::DispatcherImpl::TakePreciseCoverage(const DispatchRequest &re void ProfilerImpl::DispatcherImpl::StartPreciseCoverage(const DispatchRequest &request) { std::unique_ptr params = - StartPreciseCoverageParam::Create(request.GetEcmaVM(), request.GetParams()); + StartPreciseCoverageParam::Create(request.GetEcmaVM(), request.GetParamsObj()); if (params == nullptr) { SendResponse(request, DispatchResponse::Fail("wrong params")); return; diff --git a/ecmascript/tooling/agent/runtime_impl.cpp b/ecmascript/tooling/agent/runtime_impl.cpp index aceec6aa5..67e6ed9ce 100644 --- a/ecmascript/tooling/agent/runtime_impl.cpp +++ b/ecmascript/tooling/agent/runtime_impl.cpp @@ -65,7 +65,8 @@ void RuntimeImpl::DispatcherImpl::RunIfWaitingForDebugger(const DispatchRequest void RuntimeImpl::DispatcherImpl::GetProperties(const DispatchRequest &request) { - std::unique_ptr params = GetPropertiesParams::Create(request.GetEcmaVM(), request.GetParams()); + std::unique_ptr params = + GetPropertiesParams::Create(request.GetEcmaVM(), request.GetParamsObj()); if (params == nullptr) { SendResponse(request, DispatchResponse::Fail("wrong params")); return; @@ -90,7 +91,7 @@ void RuntimeImpl::DispatcherImpl::GetProperties(const DispatchRequest &request) void RuntimeImpl::DispatcherImpl::CallFunctionOn(const DispatchRequest &request) { std::unique_ptr params = - CallFunctionOnParams::Create(request.GetEcmaVM(), request.GetParams()); + CallFunctionOnParams::Create(request.GetEcmaVM(), request.GetParamsObj()); if (params == nullptr) { SendResponse(request, DispatchResponse::Fail("wrong params")); return; diff --git a/ecmascript/tooling/base/pt_json.cpp b/ecmascript/tooling/base/pt_json.cpp index b79085414..e9772dffa 100644 --- a/ecmascript/tooling/base/pt_json.cpp +++ b/ecmascript/tooling/base/pt_json.cpp @@ -36,9 +36,9 @@ void PtJson::ReleaseRoot() } } -std::unique_ptr PtJson::Parse(const char *data) +std::unique_ptr PtJson::Parse(const std::string &data) { - cJSON *value = cJSON_ParseWithOpts(data, nullptr, true); + cJSON *value = cJSON_ParseWithOpts(data.c_str(), nullptr, true); return std::make_unique(value); } @@ -369,11 +369,11 @@ double PtJson::GetDouble(const char *key, double defaultValue) const return value->valuedouble; } -std::string PtJson::GetString(const char *key, std::string defaultValue) const +std::string PtJson::GetString(const char *key) const { cJSON *value = cJSON_GetObjectItem(object_, key); if (value == nullptr || cJSON_IsString(value) == 0) { - return defaultValue; + return ""; } return value->valuestring; diff --git a/ecmascript/tooling/base/pt_json.h b/ecmascript/tooling/base/pt_json.h index 7b376ea19..8a349732c 100644 --- a/ecmascript/tooling/base/pt_json.h +++ b/ecmascript/tooling/base/pt_json.h @@ -36,7 +36,7 @@ public: void ReleaseRoot(); // String parse to json - static std::unique_ptr Parse(const char *data); + static std::unique_ptr Parse(const std::string &data); // To string std::string Stringify() const; @@ -90,7 +90,7 @@ public: int32_t GetInt(const char *key, int32_t defaultValue = 0) const; int64_t GetInt64(const char *key, int64_t defaultValue = 0) const; double GetDouble(const char *key, double defaultValue = 0.0) const; - std::string GetString(const char *key, std::string defaultValue = "") const; + std::string GetString(const char *key) const; std::unique_ptr GetObject(const char *key) const; std::unique_ptr GetArray(const char *key) const; diff --git a/ecmascript/tooling/base/pt_params.cpp b/ecmascript/tooling/base/pt_params.cpp index b03f3235b..189c068ff 100644 --- a/ecmascript/tooling/base/pt_params.cpp +++ b/ecmascript/tooling/base/pt_params.cpp @@ -20,7 +20,7 @@ std::unique_ptr EnableParams::Create(const EcmaVM *ecmaVm, const L { ASSERT(ecmaVm); if (params.IsEmpty()) { - LOG(ERROR, DEBUGGER) << "RemoteObject::Create params is nullptr"; + LOG(ERROR, DEBUGGER) << "EnableParams::Create params is nullptr"; return nullptr; } std::string error; diff --git a/ecmascript/tooling/base/pt_params.h b/ecmascript/tooling/base/pt_params.h index 06eb0104d..271e6fc02 100644 --- a/ecmascript/tooling/base/pt_params.h +++ b/ecmascript/tooling/base/pt_params.h @@ -56,7 +56,7 @@ private: NO_COPY_SEMANTIC(EnableParams); NO_MOVE_SEMANTIC(EnableParams); - std::optional maxScriptsCacheSize_ {0}; + std::optional maxScriptsCacheSize_ {}; }; class EvaluateOnCallFrameParams : public PtBaseParams { diff --git a/ecmascript/tooling/base/pt_returns.h b/ecmascript/tooling/base/pt_returns.h index eb0993a64..d474a46bc 100644 --- a/ecmascript/tooling/base/pt_returns.h +++ b/ecmascript/tooling/base/pt_returns.h @@ -28,6 +28,10 @@ public: { return NewObject(ecmaVm); } + std::unique_ptr ToJson() const override + { + return PtJson::CreateObject(); + } private: NO_COPY_SEMANTIC(PtBaseReturns); diff --git a/ecmascript/tooling/base/pt_types.h b/ecmascript/tooling/base/pt_types.h index c2257f2c6..b96315b8c 100644 --- a/ecmascript/tooling/base/pt_types.h +++ b/ecmascript/tooling/base/pt_types.h @@ -21,6 +21,7 @@ #include "ecmascript/dfx/cpu_profiler/samples_record.h" #include "ecmascript/tooling/backend/debugger_api.h" +#include "ecmascript/tooling/base/pt_json.h" #include "libpandabase/macros.h" namespace panda::ecmascript::tooling { @@ -30,6 +31,10 @@ public: PtBaseTypes() = default; virtual ~PtBaseTypes() = default; virtual Local ToObject(const EcmaVM *ecmaVm) const = 0; + virtual std::unique_ptr ToJson() const + { + return PtJson::CreateObject(); + } protected: static Local NewObject(const EcmaVM *ecmaVm); diff --git a/ecmascript/tooling/dispatcher.cpp b/ecmascript/tooling/dispatcher.cpp index d27275562..df4017f77 100644 --- a/ecmascript/tooling/dispatcher.cpp +++ b/ecmascript/tooling/dispatcher.cpp @@ -26,46 +26,28 @@ namespace panda::ecmascript::tooling { DispatchRequest::DispatchRequest(const EcmaVM *ecmaVm, const std::string &message) : ecmaVm_(ecmaVm) { - Local msgValue = JSON::Parse(ecmaVm, StringRef::NewFromUtf8(ecmaVm, message.c_str())); - if (msgValue->IsException()) { - DebuggerApi::ClearException(ecmaVm); - LOG(ERROR, DEBUGGER) << "json parse throw exception"; - return; - } - if (!msgValue->IsObject()) { + std::unique_ptr json = PtJson::Parse(message); + if (json == nullptr || !json->IsObject()) { code_ = RequestCode::JSON_PARSE_ERROR; LOG(ERROR, DEBUGGER) << "json parse error"; return; } - ObjectRef *msgObj = ObjectRef::Cast(*msgValue); - Local idStr = StringRef::NewFromUtf8(ecmaVm, "id"); - Local idResult = msgObj->Get(ecmaVm, idStr); - if (idResult.IsEmpty()) { + int32_t callId = json->GetInt("id", -1); + if (callId == -1) { code_ = RequestCode::PARSE_ID_ERROR; LOG(ERROR, DEBUGGER) << "parse id error"; return; + } else { + callId_ = callId; } - if (!idResult->IsNumber()) { - code_ = RequestCode::ID_FORMAT_ERROR; - LOG(ERROR, DEBUGGER) << "id format error"; - return; - } - callId_ = static_cast(Local(idResult)->Value()); - Local methodStr = StringRef::NewFromUtf8(ecmaVm, "method"); - Local methodResult = msgObj->Get(ecmaVm, methodStr); - if (methodResult.IsEmpty()) { + std::string wholeMethod = json->GetString("method"); + if (wholeMethod.empty()) { code_ = RequestCode::PARSE_METHOD_ERROR; LOG(ERROR, DEBUGGER) << "parse method error"; return; } - if (!methodResult->IsString()) { - code_ = RequestCode::METHOD_FORMAT_ERROR; - LOG(ERROR, DEBUGGER) << "method format error"; - return; - } - std::string wholeMethod = DebuggerApi::ToStdString(methodResult); std::string::size_type length = wholeMethod.length(); std::string::size_type indexPoint; indexPoint = wholeMethod.find_first_of('.', 0); @@ -81,7 +63,32 @@ DispatchRequest::DispatchRequest(const EcmaVM *ecmaVm, const std::string &messag LOG(DEBUG, DEBUGGER) << "domain: " << domain_; LOG(DEBUG, DEBUGGER) << "method: " << method_; + std::unique_ptr params = json->GetObject("params"); + if (params == nullptr) { + return; + } + if (!params->IsObject()) { + code_ = RequestCode::PARAMS_FORMAT_ERROR; + LOG(ERROR, DEBUGGER) << "params format error"; + return; + } else { + params_ = std::move(params); + } + + // below code will delete soon + Local msgValue = JSON::Parse(ecmaVm, StringRef::NewFromUtf8(ecmaVm, message.c_str())); + if (msgValue->IsException()) { + DebuggerApi::ClearException(ecmaVm); + LOG(ERROR, DEBUGGER) << "json parse throw exception"; + return; + } + if (!msgValue->IsObject()) { + code_ = RequestCode::JSON_PARSE_ERROR; + LOG(ERROR, DEBUGGER) << "json parse error"; + return; + } Local paramsStr = StringRef::NewFromUtf8(ecmaVm, "params"); + ObjectRef *msgObj = ObjectRef::Cast(*msgValue); Local paramsValue = msgObj->Get(ecmaVm, paramsStr); if (paramsValue.IsEmpty()) { return; @@ -91,7 +98,7 @@ DispatchRequest::DispatchRequest(const EcmaVM *ecmaVm, const std::string &messag LOG(ERROR, DEBUGGER) << "params format error"; return; } - params_ = paramsValue; + paramsObj_ = paramsValue; } DispatchResponse DispatchResponse::Create(ResponseCode code, const std::string &msg) diff --git a/ecmascript/tooling/dispatcher.h b/ecmascript/tooling/dispatcher.h index d8c43788b..ca7657dd3 100644 --- a/ecmascript/tooling/dispatcher.h +++ b/ecmascript/tooling/dispatcher.h @@ -57,9 +57,13 @@ public: { return callId_; } - Local GetParams() const + Local GetParamsObj() const { - return params_; + return paramsObj_; + } + const PtJson &GetParams() const + { + return *params_; } const std::string &GetDomain() const { @@ -78,10 +82,11 @@ public: private: const EcmaVM *ecmaVm_ {nullptr}; - int32_t callId_ {-1}; + int32_t callId_ = -1; std::string domain_ {}; std::string method_ {}; - Local params_ {}; + Local paramsObj_ {}; + std::unique_ptr params_ = std::make_unique(); RequestCode code_ {RequestCode::OK}; std::string errorMsg_ {}; }; diff --git a/ecmascript/tooling/test/debugger_params_test.cpp b/ecmascript/tooling/test/debugger_params_test.cpp index d08694f2b..06e89c538 100644 --- a/ecmascript/tooling/test/debugger_params_test.cpp +++ b/ecmascript/tooling/test/debugger_params_test.cpp @@ -72,39 +72,39 @@ HWTEST_F_L0(DebuggerParamsTest, StartSamplingParamsCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(startSamplingData, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(startSamplingData, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(startSamplingData, nullptr); EXPECT_EQ(startSamplingData->GetSamplingInterval(), 32768); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(startSamplingData, nullptr); EXPECT_EQ(startSamplingData->GetSamplingInterval(), 32768); // abnormal params of params.sub-key=["samplingInterval":true] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"samplingInterval":true}})"; - startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(startSamplingData, nullptr); // abnormal params of params.sub-key=["samplingInterval":true] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"samplingInterval":"Test"}})"; - startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(startSamplingData, nullptr); // abnormal params of params.sub-key = [ "size"=100,"nodeId"=1,"ordinal"=10] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"samplingInterval":1000}})"; - startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(startSamplingData, nullptr); EXPECT_EQ(startSamplingData->GetSamplingInterval(), 1000); } @@ -116,7 +116,7 @@ HWTEST_F_L0(DebuggerParamsTest, StartSamplingParamsToObjectTest) Local tmpStr; msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"samplingInterval":1000}})"; - startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(startSamplingData, nullptr); Local object = startSamplingData->ToObject(ecmaVm); @@ -134,39 +134,39 @@ HWTEST_F_L0(DebuggerParamsTest, StartTrackingHeapObjectsParamsCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - objectData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - objectData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - objectData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(objectData, nullptr); ASSERT_FALSE(objectData->GetTrackAllocations()); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - objectData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(objectData, nullptr); ASSERT_FALSE(objectData->GetTrackAllocations()); // abnormal params of params.sub-key=["trackAllocations":10] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"trackAllocations":10}})"; - objectData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of params.sub-key=["trackAllocations":"Test"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"trackAllocations":"Test"}})"; - objectData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of params.sub-key=["trackAllocations":true] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"trackAllocations":true}})"; - objectData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(objectData, nullptr); ASSERT_TRUE(objectData->GetTrackAllocations()); } @@ -178,7 +178,7 @@ HWTEST_F_L0(DebuggerParamsTest, StartTrackingHeapObjectsParamsToObjectTest) Local tmpStr; msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"trackAllocations":true}})"; - startTrackingData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + startTrackingData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(startTrackingData, nullptr); Local object = startTrackingData->ToObject(ecmaVm); @@ -196,17 +196,17 @@ HWTEST_F_L0(DebuggerParamsTest, StopTrackingHeapObjectsParamsCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - objectData = StopTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = StopTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - objectData = StopTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = StopTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - objectData = StopTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = StopTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(objectData, nullptr); ASSERT_FALSE(objectData->GetReportProgress()); ASSERT_FALSE(objectData->GetTreatGlobalObjectsAsRoots()); @@ -214,7 +214,7 @@ HWTEST_F_L0(DebuggerParamsTest, StopTrackingHeapObjectsParamsCreateTest) // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - objectData = StopTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = StopTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(objectData, nullptr); ASSERT_FALSE(objectData->GetReportProgress()); ASSERT_FALSE(objectData->GetTreatGlobalObjectsAsRoots()); @@ -224,21 +224,21 @@ HWTEST_F_L0(DebuggerParamsTest, StopTrackingHeapObjectsParamsCreateTest) "reportProgress":10, "treatGlobalObjectsAsRoots":10, "captureNumericValue":10}})"; - objectData = StopTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = StopTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "reportProgress":"Test", "treatGlobalObjectsAsRoots":"Test", "captureNumericValue":"Test"}})"; - objectData = StopTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = StopTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "reportProgress":true, "treatGlobalObjectsAsRoots":true, "captureNumericValue":true}})"; - objectData = StopTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = StopTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(objectData, nullptr); ASSERT_TRUE(objectData->GetReportProgress()); ASSERT_TRUE(objectData->GetTreatGlobalObjectsAsRoots()); @@ -255,7 +255,7 @@ HWTEST_F_L0(DebuggerParamsTest, StopTrackingHeapObjectsParamsToObjectTest) "reportProgress":true, "treatGlobalObjectsAsRoots":true, "captureNumericValue":true}})"; - stopTrackingData = StopTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + stopTrackingData = StopTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(stopTrackingData, nullptr); Local object = stopTrackingData->ToObject(ecmaVm); @@ -285,37 +285,37 @@ HWTEST_F_L0(DebuggerParamsTest, AddInspectedHeapObjectParamsCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of params.sub-key=["heapObjectId":10] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"heapObjectId":10}})"; - objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of params.sub-key=["heapObjectId":true] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"heapObjectId":true}})"; - objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of params.sub-key=["heapObjectId":“10”] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"heapObjectId":"10"}})"; - objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(objectData, nullptr); EXPECT_EQ((int)objectData->GetHeapObjectId(), 10); } @@ -327,7 +327,7 @@ HWTEST_F_L0(DebuggerParamsTest, AddInspectedHeapObjectParamsToObjectTest) Local tmpStr; msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"heapObjectId":"10"}})"; - objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(objectData, nullptr); Local object = objectData->ToObject(ecmaVm); @@ -345,37 +345,37 @@ HWTEST_F_L0(DebuggerParamsTest, GetHeapObjectIdParamsCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of params.sub-key=["objectId":10] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":10}})"; - objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of params.sub-key=["objectId":true] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":true}})"; - objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of params.sub-key=["objectId":“10”] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10"}})"; - objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(objectData, nullptr); EXPECT_EQ((int)objectData->GetObjectId(), 10); } @@ -387,7 +387,7 @@ HWTEST_F_L0(DebuggerParamsTest, GetHeapObjectIdParamsToObjectTest) Local tmpStr; msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10"}})"; - objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(objectData, nullptr); Local object = objectData->ToObject(ecmaVm); @@ -405,43 +405,43 @@ HWTEST_F_L0(DebuggerParamsTest, GetObjectByHeapObjectIdParamsCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of params.sub-key=["objectId":10] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":10}})"; - objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of params.sub-key=["objectId":true] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10", "objectGroup":10}})"; - objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of params.sub-key=["objectId":“10”] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10"}})"; - objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(objectData, nullptr); EXPECT_EQ((int)objectData->GetObjectId(), 10); ASSERT_FALSE(objectData->HasObjectGroup()); msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10", "objectGroup":"groupname"}})"; - objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(objectData, nullptr); EXPECT_EQ((int)objectData->GetObjectId(), 10); EXPECT_EQ(objectData->GetObjectGroup(), "groupname"); @@ -454,7 +454,7 @@ HWTEST_F_L0(DebuggerParamsTest, GetObjectByHeapObjectIdParamsToObjectTest) Local tmpStr; msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10", "objectGroup":"groupname"}})"; - objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(objectData, nullptr); Local object = objectData->ToObject(ecmaVm); @@ -478,43 +478,43 @@ HWTEST_F_L0(DebuggerParamsTest, StartPreciseCoverageParamCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - objectData = StartPreciseCoverageParam::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = StartPreciseCoverageParam::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - objectData = StartPreciseCoverageParam::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = StartPreciseCoverageParam::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - objectData = StartPreciseCoverageParam::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = StartPreciseCoverageParam::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(objectData, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - objectData = StartPreciseCoverageParam::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = StartPreciseCoverageParam::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(objectData, nullptr); msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callCount":8, "detailed":8, "allowTriggeredUpdates":8}})"; - objectData = StartPreciseCoverageParam::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = StartPreciseCoverageParam::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callCount":"Test", "detailed":"Test", "allowTriggeredUpdates":"Test"}})"; - objectData = StartPreciseCoverageParam::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = StartPreciseCoverageParam::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callCount":true, "detailed":true, "allowTriggeredUpdates":true}})"; - objectData = StartPreciseCoverageParam::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = StartPreciseCoverageParam::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(objectData, nullptr); ASSERT_TRUE(objectData->GetCallCount()); ASSERT_TRUE(objectData->GetDetailed()); @@ -531,7 +531,7 @@ HWTEST_F_L0(DebuggerParamsTest, StartPreciseCoverageParamToObjectTest) "callCount":true, "detailed":true, "allowTriggeredUpdates":true}})"; - startTrackingData = StartPreciseCoverageParam::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + startTrackingData = StartPreciseCoverageParam::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(startTrackingData, nullptr); Local object = startTrackingData->ToObject(ecmaVm); @@ -561,31 +561,31 @@ HWTEST_F_L0(DebuggerParamsTest, SetSamplingIntervalParamsCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - objectData = SetSamplingIntervalParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = SetSamplingIntervalParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - objectData = SetSamplingIntervalParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = SetSamplingIntervalParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - objectData = SetSamplingIntervalParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = SetSamplingIntervalParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - objectData = SetSamplingIntervalParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = SetSamplingIntervalParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "interval":"500"}})"; - objectData = SetSamplingIntervalParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = SetSamplingIntervalParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(objectData, nullptr); msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"interval":500}})"; - objectData = SetSamplingIntervalParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + objectData = SetSamplingIntervalParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(objectData, nullptr); EXPECT_EQ(objectData->GetInterval(), 500); } @@ -597,7 +597,7 @@ HWTEST_F_L0(DebuggerParamsTest, SetSamplingIntervalParamsToObjectTest) Local tmpStr; msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"interval":500}})"; - setSamplingIntervalData = SetSamplingIntervalParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + setSamplingIntervalData = SetSamplingIntervalParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(setSamplingIntervalData, nullptr); Local object = setSamplingIntervalData->ToObject(ecmaVm); diff --git a/ecmascript/tooling/test/debugger_types_test.cpp b/ecmascript/tooling/test/debugger_types_test.cpp index b7a44fe7a..2ddd8ffaa 100644 --- a/ecmascript/tooling/test/debugger_types_test.cpp +++ b/ecmascript/tooling/test/debugger_types_test.cpp @@ -73,56 +73,56 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(remoteObject, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(remoteObject, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(remoteObject, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(remoteObject, nullptr); // abnormal params of params.sub-key = [ type = 100, ] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":100}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(remoteObject, nullptr); // abnormal params of params.sub-key = [ type = [ "sub": "test" ] }, ] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":100}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(remoteObject, nullptr); // normal params of params.sub-key = [ type = "object", ] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"("}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(remoteObject, nullptr); EXPECT_EQ(ObjectType::Object, remoteObject->GetType()); // abnormal params of params.sub-key = [ type = "object", subtype = "unknown"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","subtype":"unknown"}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(remoteObject, nullptr); // abnormal params of params.sub-key = [ type = "object", subtype = 100] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","subtype":100}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(remoteObject, nullptr); // normal params of params.sub-key = [ type = "object", subtype = "array"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::Array + R"("}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(remoteObject, nullptr); EXPECT_EQ(ObjectType::Object, remoteObject->GetType()); ASSERT_TRUE(remoteObject->HasSubType()); @@ -131,19 +131,19 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectCreateTest) // abnormal params of params.sub-key = [ type = "object", className = 100] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","className":100}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(remoteObject, nullptr); // abnormal params of params.sub-key = [ type = "object", className = {"xx":"yy"}] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","className":{"xx":"yy"}}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(remoteObject, nullptr); // normal params of params.sub-key = [ type = "object", className = "TestClass"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","className":"TestClass"}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(remoteObject, nullptr); EXPECT_EQ(ObjectType::Object, remoteObject->GetType()); ASSERT_TRUE(remoteObject->HasClassName()); @@ -152,7 +152,7 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectCreateTest) // normal params of params.sub-key = [ type = "object", value = 100] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","value":100}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(remoteObject, nullptr); EXPECT_EQ(ObjectType::Object, remoteObject->GetType()); ASSERT_TRUE(remoteObject->HasValue()); @@ -161,7 +161,7 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectCreateTest) // normal params of params.sub-key = [ type = "object", value = {"xx":"yy"}] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","value":{"xx":"yy"}}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(remoteObject, nullptr); EXPECT_EQ(ObjectType::Object, remoteObject->GetType()); ASSERT_TRUE(remoteObject->HasValue()); @@ -172,7 +172,7 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectCreateTest) // normal params of params.sub-key = [ type = "object", value = "Test"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","value":"Test"}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(remoteObject, nullptr); EXPECT_EQ(ObjectType::Object, remoteObject->GetType()); ASSERT_TRUE(remoteObject->HasValue()); @@ -181,19 +181,19 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectCreateTest) // abnormal params of params.sub-key = [ type = "object", unserializableValue = 100] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","unserializableValue":100}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(remoteObject, nullptr); // abnormal params of params.sub-key = [ type = "object", unserializableValue = {"xx":"yy"}] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","unserializableValue":{"xx":"yy"}}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(remoteObject, nullptr); // normal params of params.sub-key = [ type = "object", unserializableValue = "TestClass"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","unserializableValue":"Test"}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(remoteObject, nullptr); EXPECT_EQ(ObjectType::Object, remoteObject->GetType()); ASSERT_TRUE(remoteObject->HasUnserializableValue()); @@ -202,19 +202,19 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectCreateTest) // abnormal params of params.sub-key = [ type = "object", description = 100] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","description":100}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(remoteObject, nullptr); // abnormal params of params.sub-key = [ type = "object", description = {"xx":"yy"}] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","description":{"xx":"yy"}}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(remoteObject, nullptr); // normal params of params.sub-key = [ type = "object", description = "Test"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","description":"Test"}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(remoteObject, nullptr); EXPECT_EQ(ObjectType::Object, remoteObject->GetType()); ASSERT_TRUE(remoteObject->HasDescription()); @@ -223,19 +223,19 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectCreateTest) // abnormal params of params.sub-key = [ type = "object", objectId = 100] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","objectId":100}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(remoteObject, nullptr); // abnormal params of params.sub-key = [ type = "object", objectId = {"xx":"yy"}] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","objectId":{"xx":"yy"}}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(remoteObject, nullptr); // normal params of params.sub-key = [ type = "object", objectId = "id_1"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","objectId":"1"}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(remoteObject, nullptr); EXPECT_EQ(ObjectType::Object, remoteObject->GetType()); ASSERT_TRUE(remoteObject->HasObjectId()); @@ -251,7 +251,7 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectToObjectTest) msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(", "subtype":")" + ObjectSubType::Array + R"(","className":"TestClass","value":100, "unserializableValue":"Test","description":"Test","objectId":"1"}})"; - remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(remoteObject, nullptr); Local object = remoteObject->ToObject(ecmaVm); @@ -299,76 +299,76 @@ HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = [ exceptionId="Test","text"="text0","lineNumber"=10,"columnNumber"=20] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":"Test","text":"text0","lineNumber":10,"columnNumber":20}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = [ exceptionId={"xx":"yy"},"text"="text0","lineNumber"=10,"columnNumber"=20] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":{"xx":"yy"},"text":"text0","lineNumber":10,"columnNumber":20}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = [ exceptionId=3,"text"=10,"lineNumber"=10,"columnNumber"=20] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":10,"lineNumber":10,"columnNumber":20}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = [ exceptionId=3,"text"=["text0"],"lineNumber"=10,"columnNumber"=20] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":["text0"],"lineNumber":10,"columnNumber":20}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = [ exceptionId=3,"text"="text0","lineNumber"="10","columnNumber"=20] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":"10","columnNumber":20}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = [ exceptionId=3,"text"="text0","lineNumber"=["10"],"columnNumber"=20] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":["10"],"columnNumber":20}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = [ exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"="20"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":"20"}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = [ exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=["20"]] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":["20"]}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(exceptionMetaData, nullptr); // normal params of params.sub-key = [ exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(exceptionMetaData, nullptr); EXPECT_EQ(exceptionMetaData->GetExceptionId(), 3); EXPECT_EQ("text0", exceptionMetaData->GetText()); @@ -379,21 +379,21 @@ HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsCreateTest) // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"scriptId"=10] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"scriptId":10}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"scriptId"=["10"]] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"scriptId":["10"]}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(exceptionMetaData, nullptr); // normal params of params.sub-key = // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"scriptId"="id0"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"scriptId":"0"}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(exceptionMetaData, nullptr); EXPECT_EQ(exceptionMetaData->GetExceptionId(), 3); EXPECT_EQ("text0", exceptionMetaData->GetText()); @@ -405,21 +405,21 @@ HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsCreateTest) // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"url"=10] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"url":10}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"url"=["10"]] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"url":["10"]}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(exceptionMetaData, nullptr); // normal params of params.sub-key = // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"url"="url0"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"url":"url0"}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(exceptionMetaData, nullptr); EXPECT_EQ(exceptionMetaData->GetExceptionId(), 3); EXPECT_EQ("text0", exceptionMetaData->GetText()); @@ -431,14 +431,14 @@ HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsCreateTest) // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"exception"=10] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"exception":10}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"exception"=["10"]] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"exception":["10"]}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(exceptionMetaData, nullptr); // normal params of params.sub-key = @@ -446,7 +446,7 @@ HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsCreateTest) msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"exception":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::Error + R"("}}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(exceptionMetaData, nullptr); EXPECT_EQ(exceptionMetaData->GetExceptionId(), 3); EXPECT_EQ("text0", exceptionMetaData->GetText()); @@ -461,21 +461,21 @@ HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsCreateTest) // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"executionContextId"="10"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"executionContextId":"10"}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"executionContextId"=["10"]] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"executionContextId":["10"]}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(exceptionMetaData, nullptr); // normal params of params.sub-key = // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"executionContextId"=2] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"executionContextId":2}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(exceptionMetaData, nullptr); EXPECT_EQ(exceptionMetaData->GetExceptionId(), 3); EXPECT_EQ("text0", exceptionMetaData->GetText()); @@ -494,7 +494,7 @@ HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsToObjectTest) "exceptionId":5,"text":"text0","lineNumber":10,"columnNumber":20,"scriptId":"100","url":"url0", "exception":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::Error + R"("},"executionContextId":30}})"; - exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(exceptionMetaData, nullptr); Local object = exceptionMetaData->ToObject(ecmaVm); @@ -557,79 +557,92 @@ HWTEST_F_L0(DebuggerTypesTest, InternalPropertyDescriptorCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + internalPropertyDescriptor = + InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(internalPropertyDescriptor, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + internalPropertyDescriptor = + InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(internalPropertyDescriptor, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + internalPropertyDescriptor = + InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(internalPropertyDescriptor, nullptr); // abnormal params of unknown params.sub-key=["name":"name8"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name8","value":99}})"; - internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + internalPropertyDescriptor = + InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(internalPropertyDescriptor, nullptr); // abnormal params of unknown params.sub-key=["name":"name8"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name8","value":99}})"; - internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + internalPropertyDescriptor = + InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(internalPropertyDescriptor, nullptr); // abnormal params of unknown params.sub-key=["name":"name8","value":99] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name8","value":99}})"; - internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + internalPropertyDescriptor = + InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(internalPropertyDescriptor, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + internalPropertyDescriptor = + InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(internalPropertyDescriptor, nullptr); // abnormal params of unknown params.sub-key=["name":99] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name8","value":99}})"; - internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + internalPropertyDescriptor = + InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(internalPropertyDescriptor, nullptr); // abnormal params of unknown params.sub-key=["name":[99]] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name8","value":[99]}})"; - internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + internalPropertyDescriptor = + InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(internalPropertyDescriptor, nullptr); // normal params of params.sub-key=["name":"name7"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name7"}})"; - internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + internalPropertyDescriptor = + InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(internalPropertyDescriptor, nullptr); EXPECT_EQ("name7", internalPropertyDescriptor->GetName()); // abnormal params of unknown params.sub-key=["name":"name8","value":{"type":"object","subtype":"map"}] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name8","value":"99"}})"; - internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + internalPropertyDescriptor = + InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(internalPropertyDescriptor, nullptr); // abnormal params of unknown params.sub-key=["name":"name8","value":{"type":"object","subtype":"wrong"}] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name8","value":{"type":")" + ObjectType::Object + R"(","subtype":"wrong"}}})"; - internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + internalPropertyDescriptor = + InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(internalPropertyDescriptor, nullptr); // normal params of params.sub-key=["name":"name8","value":{"type":"object","subtype":"map"}] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name8","value":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::Map + R"("}}})"; - internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + internalPropertyDescriptor = + InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(internalPropertyDescriptor, nullptr); EXPECT_EQ("name8", internalPropertyDescriptor->GetName()); ASSERT_TRUE(internalPropertyDescriptor->HasValue()); @@ -648,7 +661,8 @@ HWTEST_F_L0(DebuggerTypesTest, InternalPropertyDescriptorToObjectTest) msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name8","value":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::Map + R"("}}})"; - internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + internalPropertyDescriptor = + InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(internalPropertyDescriptor, nullptr); Local object = internalPropertyDescriptor->ToObject(ecmaVm); @@ -681,77 +695,77 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":10,"configurable":true,"enumerable":true] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":10,"configurable":true,"enumerable":true,"value":10}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":["name85"],"configurable":true,"enumerable":true] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":["name85"],"configurable":true,"enumerable":true,"value":10}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":10,"enumerable":true] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":10,"enumerable":true}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":"true","enumerable":true] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":"true","enumerable":true}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":10] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":10}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":"true"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":"true"}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"value":10] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"value":10}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"value":{"ee":"11"}] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"value":{"ee":"11"}}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // normal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"value":{..}] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"value":{"type":")" + ObjectType::Symbol + R"("}}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(propertyDescriptor, nullptr); EXPECT_EQ("name85", propertyDescriptor->GetName()); ASSERT_TRUE(propertyDescriptor->GetConfigurable()); @@ -763,19 +777,19 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorCreateTest) // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"writable":98] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"writable":98}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"writable":[true]] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"writable":[true]}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // normal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"writable":true] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"writable":true}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(propertyDescriptor, nullptr); EXPECT_EQ("name85", propertyDescriptor->GetName()); ASSERT_TRUE(propertyDescriptor->GetConfigurable()); @@ -785,20 +799,20 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorCreateTest) // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"get":10] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"get":10}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"get":[10]] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"get":[10]}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // normal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"get":{}] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"get":{"type":")" + ObjectType::Function + R"("}}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(propertyDescriptor, nullptr); EXPECT_EQ("name85", propertyDescriptor->GetName()); ASSERT_TRUE(propertyDescriptor->GetConfigurable()); @@ -810,20 +824,20 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorCreateTest) // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"set":10] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"set":10}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"set":[10]] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"set":[10]}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // normal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"set":{}] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"set":{"type":")" + ObjectType::String + R"("}}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(propertyDescriptor, nullptr); EXPECT_EQ("name85", propertyDescriptor->GetName()); ASSERT_TRUE(propertyDescriptor->GetConfigurable()); @@ -835,19 +849,19 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorCreateTest) // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"wasThrown":98] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"wasThrown":98}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"wasThrown":[true]] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"wasThrown":[true]}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // normal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"wasThrown":true] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"wasThrown":true}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(propertyDescriptor, nullptr); EXPECT_EQ("name85", propertyDescriptor->GetName()); ASSERT_TRUE(propertyDescriptor->GetConfigurable()); @@ -857,19 +871,19 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorCreateTest) // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"isOwn":98] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"isOwn":98}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"isOwn":[true]] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"isOwn":[true]}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // normal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"isOwn":true] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"isOwn":true}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(propertyDescriptor, nullptr); EXPECT_EQ("name85", propertyDescriptor->GetName()); ASSERT_TRUE(propertyDescriptor->GetConfigurable()); @@ -879,20 +893,20 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorCreateTest) // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true, "symbol":10] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"symbol":10}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true, "symbol":[10]] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"symbol":[10]}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(propertyDescriptor, nullptr); // normal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true, "symbol":{}] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"symbol":{"type":")" + ObjectType::Wasm + R"("}}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(propertyDescriptor, nullptr); EXPECT_EQ("name85", propertyDescriptor->GetName()); ASSERT_TRUE(propertyDescriptor->GetConfigurable()); @@ -916,7 +930,7 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorToObjectTest) ObjectType::Object + R"(","subtype":")" + ObjectSubType::Generator + R"("},"configurable":true,"enumerable":true,"wasThrown":true,"isOwn":true,"symbol":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::Proxy + R"("}}})"; - propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(propertyDescriptor, nullptr); Local object = propertyDescriptor->ToObject(ecmaVm); @@ -1019,64 +1033,64 @@ HWTEST_F_L0(DebuggerTypesTest, LocationCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(location, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(location, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(location, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(location, nullptr); // abnormal params of params.sub-key=["scriptId":10,"lineNumber":99] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":10,"lineNumber":99 }})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(location, nullptr); // abnormal params of params.sub-key=["scriptId":["id3"],"lineNumber":99] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":["id3"],"lineNumber":99 }})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(location, nullptr); // abnormal params of params.sub-key=["scriptId":"222","lineNumber":"99"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":"99" }})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(location, nullptr); // abnormal params of params.sub-key=["scriptId":"222","lineNumber":[99]] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":[99] }})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(location, nullptr); // abnormal params of params.sub-key=["scriptId":"2","lineNumber":99,"columnNumber":"18"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":899,"columnNumber":"18" }})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(location, nullptr); // normal params of params.sub-key=["scriptId":"2","lineNumber":99,"columnNumber":138] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":899,"columnNumber":138 }})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(location, nullptr); EXPECT_EQ(222U, location->GetScriptId()); EXPECT_EQ(location->GetLine(), 899); @@ -1086,7 +1100,7 @@ HWTEST_F_L0(DebuggerTypesTest, LocationCreateTest) msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"2122","lineNumber":8299 }})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(location, nullptr); EXPECT_EQ(2122U, location->GetScriptId()); EXPECT_EQ(location->GetLine(), 8299); @@ -1101,7 +1115,7 @@ HWTEST_F_L0(DebuggerTypesTest, LocationToObjectTest) msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"2","lineNumber":99,"columnNumber":18 }})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(location, nullptr); Local object = location->ToObject(ecmaVm); @@ -1129,78 +1143,78 @@ HWTEST_F_L0(DebuggerTypesTest, BreakLocationCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(breakLocation, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(breakLocation, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(breakLocation, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(breakLocation, nullptr); // abnormal params of params.sub-key=["scriptId":10,"lineNumber":99] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":10,"lineNumber":99 }})"; - breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(breakLocation, nullptr); // abnormal params of params.sub-key=["scriptId":["id3"],"lineNumber":99] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":["id3"],"lineNumber":99 }})"; - breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(breakLocation, nullptr); // abnormal params of params.sub-key=["scriptId":"222","lineNumber":"99"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":"99" }})"; - breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(breakLocation, nullptr); // abnormal params of params.sub-key=["scriptId":"222","lineNumber":[99]] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":[99] }})"; - breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(breakLocation, nullptr); // abnormal params of params.sub-key=["scriptId":"2","lineNumber":99,"columnNumber":"18"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":899,"columnNumber":"18" }})"; - breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(breakLocation, nullptr); // abnormal params of params.sub-key=["scriptId":"2","lineNumber":99,"columnNumber":"18","type":10] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":899,"columnNumber":"18","type":10 }})"; - breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(breakLocation, nullptr); // abnormal params of params.sub-key=["scriptId":"2","lineNumber":99,"columnNumber":"18","type":"ee"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":899,"columnNumber":"18","type":"ee" }})"; - breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(breakLocation, nullptr); // normal params of params.sub-key=["scriptId":"2","lineNumber":99,"columnNumber":138,"type":"return"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":899,"columnNumber":138,"type":"return" }})"; - breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(breakLocation, nullptr); EXPECT_EQ(222U, breakLocation->GetScriptId()); EXPECT_EQ(breakLocation->GetLine(), 899); @@ -1211,7 +1225,7 @@ HWTEST_F_L0(DebuggerTypesTest, BreakLocationCreateTest) msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"2122","lineNumber":8299 }})"; - breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(breakLocation, nullptr); EXPECT_EQ(2122U, breakLocation->GetScriptId()); EXPECT_EQ(breakLocation->GetLine(), 8299); @@ -1226,7 +1240,7 @@ HWTEST_F_L0(DebuggerTypesTest, BreakLocationToObjectTest) msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"12","lineNumber":919,"columnNumber":148,"type":"call" }})"; - breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(breakLocation, nullptr); Local object = breakLocation->ToObject(ecmaVm); @@ -1259,70 +1273,70 @@ HWTEST_F_L0(DebuggerTypesTest, ScopeCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(scope, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(scope, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(scope, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(scope, nullptr); // abnormal params of params.sub-key=["type":"ss","object":{..}] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"ss","object":{"type":")" + ObjectType::Bigint + R"("}}})"; - scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(scope, nullptr); // abnormal params of params.sub-key=["type":12,"object":{..}] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":12,"object":{"type":")" + ObjectType::Bigint + R"("}}})"; - scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(scope, nullptr); // abnormal params of params.sub-key=["type":"global","object":10] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"global","object":10}})"; - scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(scope, nullptr); // abnormal params of params.sub-key=["type":"global","object":{..}] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"global","object":{"ww":")" + ObjectType::Bigint + R"("}}})"; - scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(scope, nullptr); // abnormal params of params.sub-key=["type":"global","object":{..},"name":10] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"global","object":{"type":")" + ObjectType::Bigint + R"("},"name":10}})"; - scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(scope, nullptr); // abnormal params of params.sub-key=["type":"global","object":{..},"name":["10"]] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"global","object":{"type":")" + ObjectType::Bigint + R"("},"name":["10"]}})"; - scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(scope, nullptr); // normal params of params.sub-key=["type":"global","object":{..},"name":"name128"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"global","object":{"type":")" + ObjectType::Bigint + R"("},"name":"name117"}})"; - scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(scope, nullptr); EXPECT_EQ("name117", scope->GetName()); @@ -1330,35 +1344,35 @@ HWTEST_F_L0(DebuggerTypesTest, ScopeCreateTest) msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"global","object":{"type":")" + ObjectType::Bigint + R"("},"startLocation":10}})"; - scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(scope, nullptr); // abnormal params of params.sub-key=["type":"global","object":{..},"startLocation":{"12":"34"}] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"global","object":{"type":")" + ObjectType::Bigint + R"("},"startLocation":{"12":"34"}}})"; - scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(scope, nullptr); // abnormal params of params.sub-key=["type":"global","object":{..},"endLocation":10] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"global","object":{"type":")" + ObjectType::Bigint + R"("},"endLocation":10}})"; - scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(scope, nullptr); // abnormal params of params.sub-key=["type":"global","object":{..},"endLocation":{"12":"34"}] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"global","object":{"type":")" + ObjectType::Bigint + R"("},"endLocation":{"12":"34"}}})"; - scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(scope, nullptr); // normal params of params.sub-key=["type":"global","object":{..}] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"global","object":{"type":")" + ObjectType::Bigint + R"("}}})"; - scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(scope, nullptr); EXPECT_EQ("global", scope->GetType()); RemoteObject *object = scope->GetObject(); @@ -1378,7 +1392,7 @@ HWTEST_F_L0(DebuggerTypesTest, ScopeToObjectTest) "startLocation":{"scriptId":"2","lineNumber":99}, "endLocation":{"scriptId":"13","lineNumber":146} }})"; - scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(scope, nullptr); Local object = scope->ToObject(ecmaVm); @@ -1446,22 +1460,22 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(callFrame, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(callFrame, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(callFrame, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] @@ -1471,7 +1485,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) [{"type":"global","object":{"type":")" + ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object + R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] @@ -1481,7 +1495,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) [{"type":"global","object":{"type":")" + ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object + R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] @@ -1491,7 +1505,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) [{"type":"global","object":{"type":")" + ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object + R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] @@ -1501,7 +1515,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) [{"type":"global","object":{"type":")" + ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object + R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] @@ -1511,7 +1525,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) [{"type":"global","object":{"type":")" + ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object + R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] @@ -1521,7 +1535,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) [{"type":"global","object":{"type":")" + ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object + R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] @@ -1531,7 +1545,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) [{"type":"global","object":{"type":")" + ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object + R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] @@ -1541,7 +1555,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) [{"type":"global","object":{"type":")" + ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object + R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] @@ -1551,7 +1565,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) [{"type":"global","object":{"type":")" + ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object + R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] @@ -1561,7 +1575,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) [{"type":"global","object":{"type":")" + ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object + R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] @@ -1569,7 +1583,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) "callFrameId":"0","functionName":"name0", "location":{"scriptId":"5","lineNumber":19}, "url":"url7","scopeChain":10,"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] @@ -1579,7 +1593,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) {"type":"22","object":{"type":")" + ObjectType::Object + R"("}},"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] @@ -1589,7 +1603,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) [{"type":"global","object":{"type":")" + ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object + R"("}}],"this":10}})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] @@ -1599,7 +1613,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) [{"type":"global","object":{"type":")" + ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object + R"("}}],"this":{"11":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] @@ -1610,7 +1624,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object + R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}, "returnValue":10}})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] @@ -1621,7 +1635,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object + R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}, "returnValue":{"type":"object","subtype":"11"}}})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(callFrame, nullptr); // normal params of params.sub-key=[..] @@ -1631,7 +1645,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) [{"type":"global","object":{"type":")" + ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object + R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(callFrame, nullptr); EXPECT_EQ(0U, callFrame->GetCallFrameId()); EXPECT_EQ("name0", callFrame->GetFunctionName()); @@ -1656,7 +1670,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object + R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("},"returnValue":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::I32 + R"("}}})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(callFrame, nullptr); EXPECT_EQ(10U, callFrame->GetCallFrameId()); EXPECT_EQ("name0", callFrame->GetFunctionName()); @@ -1692,7 +1706,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameToObjectTest) ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object + R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::Iterator + R"("},"returnValue":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::I64 + R"("}}})"; - callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(callFrame, nullptr); Local object = callFrame->ToObject(ecmaVm); @@ -1787,39 +1801,39 @@ HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileSampleCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - object = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + object = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(object, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - object = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + object = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(object, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - object = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + object = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(object, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - object = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + object = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(object, nullptr); // abnormal params of params.sub-key = [ "size"="Test","nodeId"="Test","ordinal"="Test"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "size":"Test","nodeId":"Test","ordinal":"Test"}})"; - object = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + object = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(object, nullptr); // abnormal params of params.sub-key = [ "size"={"xx":"yy"},"nodeId"={"xx":"yy"},"ordinal"={"xx":"yy"}] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "size":{"xx":"yy"},"nodeId":{"xx":"yy"},"ordinal":{"xx":"yy"}}})"; - object = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + object = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(object, nullptr); // abnormal params of params.sub-key = [ "size"=100,"nodeId"=1,"ordinal"=10] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"size":100,"nodeId":1,"ordinal":10}})"; - object = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + object = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(object, nullptr); EXPECT_EQ(object->GetSize(), 100); EXPECT_EQ(object->GetNodeId(), 1); @@ -1833,7 +1847,8 @@ HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileSampleToObjectTest) Local tmpStr; msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"size":100,"nodeId":1,"ordinal":10}})"; - samplingHeapProfileSampleData = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + samplingHeapProfileSampleData = + SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(samplingHeapProfileSampleData, nullptr); Local object = samplingHeapProfileSampleData->ToObject(ecmaVm); @@ -1863,22 +1878,22 @@ HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileNodeCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - object = SamplingHeapProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + object = SamplingHeapProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(object, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - object = SamplingHeapProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + object = SamplingHeapProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(object, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - object = SamplingHeapProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + object = SamplingHeapProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(object, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - object = SamplingHeapProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + object = SamplingHeapProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(object, nullptr); msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ @@ -1887,7 +1902,7 @@ HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileNodeCreateTest) "id":5, "children":[] }})"; - object = SamplingHeapProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + object = SamplingHeapProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(object, nullptr); RuntimeCallFrame *runTimeCallFrame = object->GetCallFrame(); ASSERT_NE(runTimeCallFrame, nullptr); @@ -1916,7 +1931,7 @@ HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileNodeToObjectTest) "id":5, "children":[] }})"; - samplingHeapProfileNode = SamplingHeapProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + samplingHeapProfileNode = SamplingHeapProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(samplingHeapProfileNode, nullptr); Local object = samplingHeapProfileNode->ToObject(ecmaVm); tmpStr = StringRef::NewFromUtf8(ecmaVm, "callFrame"); @@ -1967,22 +1982,22 @@ HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - object = SamplingHeapProfile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + object = SamplingHeapProfile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(object, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - object = SamplingHeapProfile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + object = SamplingHeapProfile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(object, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - object = SamplingHeapProfile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + object = SamplingHeapProfile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(object, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - object = SamplingHeapProfile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + object = SamplingHeapProfile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(object, nullptr); msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ @@ -1994,7 +2009,7 @@ HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileCreateTest) }, "samples":[{"size":100, "nodeId":1, "ordinal":10}] }})"; - object = SamplingHeapProfile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + object = SamplingHeapProfile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(object, nullptr); SamplingHeapProfileNode *head = object->GetHead(); ASSERT_NE(head, nullptr); @@ -2037,7 +2052,7 @@ HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileToObjectTest) "samples":[{"size":100, "nodeId":1, "ordinal":10}] }})"; - samplingHeapProfile = SamplingHeapProfile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + samplingHeapProfile = SamplingHeapProfile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(samplingHeapProfile, nullptr); Local object = samplingHeapProfile->ToObject(ecmaVm); @@ -2120,45 +2135,45 @@ HWTEST_F_L0(DebuggerTypesTest, PositionTickInfoCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(positionTickInfo, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(positionTickInfo, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(positionTickInfo, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(positionTickInfo, nullptr); // abnormal params of params.sub-key=["line":11,"ticks":99] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "line":"11","ticks":99}})"; - positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(positionTickInfo, nullptr); // abnormal params of params.sub-key=["line":"11","ticks":"99"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "line":"11","ticks":"99"}})"; - positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(positionTickInfo, nullptr); // abnormal params of params.sub-key=["line":[11],"ticks":[99]] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "line":[11],"ticks":[99]}})"; - positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(positionTickInfo, nullptr); // normal params of params.sub-key=["line":11,"ticks":99] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"line":1,"ticks":0}})"; - positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(positionTickInfo, nullptr); EXPECT_EQ(positionTickInfo->GetLine(), 1); EXPECT_EQ(positionTickInfo->GetTicks(), 0); @@ -2171,9 +2186,8 @@ HWTEST_F_L0(DebuggerTypesTest, PositionTickInfoToObjectTest) std::unique_ptr positionTickInfo; Local tmpStr; - msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ - "line":1,"ticks":0,}})"; - positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"line":1,"ticks":0}})"; + positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(positionTickInfo, nullptr); Local object = positionTickInfo->ToObject(ecmaVm); @@ -2197,22 +2211,22 @@ HWTEST_F_L0(DebuggerTypesTest, ProfileNodeCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - profileNode = ProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + profileNode = ProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(profileNode, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - profileNode = ProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + profileNode = ProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(profileNode, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - profileNode = ProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + profileNode = ProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(profileNode, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - profileNode = ProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + profileNode = ProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(profileNode, nullptr); // normal params of params.sub-key=[..] @@ -2220,7 +2234,7 @@ HWTEST_F_L0(DebuggerTypesTest, ProfileNodeCreateTest) "id":10, "callFrame": {"functionName":"name0", "scriptId":"12", "url":"url15", "lineNumber":11, "columnNumber":20}, "hitCount":15,"children":[],"positionTicks":[],"deoptReason":"yyy"}})"; - profileNode = ProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + profileNode = ProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(profileNode, nullptr); EXPECT_EQ(profileNode->GetId(), 10); @@ -2246,7 +2260,7 @@ HWTEST_F_L0(DebuggerTypesTest, ProfileNodeToObjectTest) "id":10, "callFrame": {"functionName":"name0", "scriptId":"12", "url":"url15", "lineNumber":11, "columnNumber":20}, "hitCount":15,"children":[],"positionTicks":[],"deoptReason":"yyy"}})"; - profilenode = ProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + profilenode = ProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(profilenode, nullptr); Local object = profilenode->ToObject(ecmaVm); @@ -2308,28 +2322,28 @@ HWTEST_F_L0(DebuggerTypesTest, ProfileCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - profile = Profile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + profile = Profile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(profile, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - profile = Profile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + profile = Profile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(profile, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - profile = Profile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + profile = Profile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(profile, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - profile = Profile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + profile = Profile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(profile, nullptr); // abnormal params of params.sub-key=[..] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "startTime":10,"endTime":25,"nodes":[],"samples":[],"timeDeltas":[]}})"; - profile = Profile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + profile = Profile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(profile, nullptr); EXPECT_EQ(profile->GetStartTime(), 10LL); @@ -2347,7 +2361,7 @@ HWTEST_F_L0(DebuggerTypesTest, ProfileToObjectTest) msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "startTime":10,"endTime":25,"nodes":[],"samples":[],"timeDeltas":[]}})"; - profile = Profile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + profile = Profile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(profile, nullptr); Local object = profile->ToObject(ecmaVm); @@ -2376,28 +2390,28 @@ HWTEST_F_L0(DebuggerTypesTest, CoverageCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - coverage = Coverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + coverage = Coverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(coverage, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - coverage = Coverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + coverage = Coverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(coverage, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - coverage = Coverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + coverage = Coverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(coverage, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - coverage = Coverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + coverage = Coverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(coverage, nullptr); // normal params of params.sub-key=["startOffset":0,"endOffset":5,"count":13] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "startOffset":0,"endOffset":13,"count":13}})"; - coverage = Coverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + coverage = Coverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(coverage, nullptr); EXPECT_EQ(coverage->GetStartOffset(), 0); EXPECT_EQ(coverage->GetEndOffset(), 13); @@ -2412,7 +2426,7 @@ HWTEST_F_L0(DebuggerTypesTest, CoverageToObjectTest) msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "startOffset":0,"endOffset":13,"count":13}})"; - coverage = Coverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + coverage = Coverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(coverage, nullptr); Local object = coverage->ToObject(ecmaVm); @@ -2443,28 +2457,28 @@ HWTEST_F_L0(DebuggerTypesTest, FunctionCoverageCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - functionCoverage = FunctionCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + functionCoverage = FunctionCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(functionCoverage, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - functionCoverage = FunctionCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + functionCoverage = FunctionCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(functionCoverage, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - functionCoverage = FunctionCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + functionCoverage = FunctionCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(functionCoverage, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - functionCoverage = FunctionCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + functionCoverage = FunctionCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(functionCoverage, nullptr); // normal params of params.sub-key=[..] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "functionName":"Create0","ranges":[],"isBlockCoverage":true}})"; - functionCoverage = FunctionCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + functionCoverage = FunctionCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(functionCoverage, nullptr); EXPECT_EQ(functionCoverage->GetFunctionName(), "Create0"); @@ -2482,7 +2496,7 @@ HWTEST_F_L0(DebuggerTypesTest, FunctionCoverageToObjectTest) msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "functionName":"Create0","ranges":[],"isBlockCoverage":true}})"; - functionCoverage = FunctionCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + functionCoverage = FunctionCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(functionCoverage, nullptr); Local object = functionCoverage->ToObject(ecmaVm); tmpStr = StringRef::NewFromUtf8(ecmaVm, "functionName"); @@ -2510,28 +2524,28 @@ HWTEST_F_L0(DebuggerTypesTest, ScriptCoverageCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - scriptCoverage = ScriptCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scriptCoverage = ScriptCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(scriptCoverage, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - scriptCoverage = ScriptCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scriptCoverage = ScriptCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(scriptCoverage, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - scriptCoverage = ScriptCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scriptCoverage = ScriptCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(scriptCoverage, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - scriptCoverage = ScriptCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scriptCoverage = ScriptCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); EXPECT_EQ(scriptCoverage, nullptr); // normal params of params.sub-key=[..] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"1001","url":"url17","functions":[]}})"; - scriptCoverage = ScriptCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scriptCoverage = ScriptCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(scriptCoverage, nullptr); EXPECT_EQ(scriptCoverage->GetScriptId(), "1001"); EXPECT_EQ(scriptCoverage->GetUrl(), "url17"); @@ -2548,7 +2562,7 @@ HWTEST_F_L0(DebuggerTypesTest, ScriptCoverageToObjectTest) msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"1001","url":"url17","functions":[]}})"; - scriptCoverage = ScriptCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); + scriptCoverage = ScriptCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); ASSERT_NE(scriptCoverage, nullptr); Local object = scriptCoverage->ToObject(ecmaVm); tmpStr = StringRef::NewFromUtf8(ecmaVm, "scriptId"); -- Gitee From c523af114efd595651c49cf17c3bbf2a8143cc7c Mon Sep 17 00:00:00 2001 From: wengchangcheng Date: Wed, 8 Jun 2022 18:19:29 +0800 Subject: [PATCH 2/3] Descriptor: debugger refactor of independent js_runtime [ part-2 ] details: add Create function by PtJson issue: https://gitee.com/openharmony/ark_js_runtime/issues/I5BBPM Signed-off-by: wengchangcheng Change-Id: I2870f1d377bd6b4adc0d12d33cba84d53af7f076 --- ecmascript/tooling/agent/debugger_impl.cpp | 2 +- ecmascript/tooling/base/pt_params.cpp | 13 +++++++++ ecmascript/tooling/base/pt_params.h | 1 + ecmascript/tooling/base/pt_types.cpp | 29 +++++++++++++++++++ ecmascript/tooling/base/pt_types.h | 1 + .../tooling/test/debugger_params_test.cpp | 18 ++++++++++++ .../tooling/test/debugger_types_test.cpp | 27 +++++++---------- 7 files changed, 73 insertions(+), 18 deletions(-) diff --git a/ecmascript/tooling/agent/debugger_impl.cpp b/ecmascript/tooling/agent/debugger_impl.cpp index e632dfd4c..a0f638f1a 100644 --- a/ecmascript/tooling/agent/debugger_impl.cpp +++ b/ecmascript/tooling/agent/debugger_impl.cpp @@ -265,7 +265,7 @@ void DebuggerImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) void DebuggerImpl::DispatcherImpl::Enable(const DispatchRequest &request) { - std::unique_ptr params = EnableParams::Create(request.GetEcmaVM(), request.GetParamsObj()); + std::unique_ptr params = EnableParams::Create(request.GetParams()); if (params == nullptr) { SendResponse(request, DispatchResponse::Fail("wrong params")); return; diff --git a/ecmascript/tooling/base/pt_params.cpp b/ecmascript/tooling/base/pt_params.cpp index 189c068ff..39643baaf 100644 --- a/ecmascript/tooling/base/pt_params.cpp +++ b/ecmascript/tooling/base/pt_params.cpp @@ -43,6 +43,19 @@ std::unique_ptr EnableParams::Create(const EcmaVM *ecmaVm, const L return paramsObject; } +std::unique_ptr EnableParams::Create(const PtJson ¶ms) +{ + auto paramsObject = std::make_unique(); + + double result = params.GetDouble("maxScriptsCacheSize", -1.0); + if (result != -1.0) { + // optional params + paramsObject->maxScriptsCacheSize_ = result; + } + + return paramsObject; +} + std::unique_ptr EvaluateOnCallFrameParams::Create(const EcmaVM *ecmaVm, const Local ¶ms) { diff --git a/ecmascript/tooling/base/pt_params.h b/ecmascript/tooling/base/pt_params.h index 271e6fc02..d792ad387 100644 --- a/ecmascript/tooling/base/pt_params.h +++ b/ecmascript/tooling/base/pt_params.h @@ -37,6 +37,7 @@ public: ~EnableParams() override = default; static std::unique_ptr Create(const EcmaVM *ecmaVm, const Local ¶ms); + static std::unique_ptr Create(const PtJson ¶ms); Local ToObject([[maybe_unused]] const EcmaVM *ecmaVm) const override { return Local(); diff --git a/ecmascript/tooling/base/pt_types.cpp b/ecmascript/tooling/base/pt_types.cpp index ffe4195a0..82d2ad5a6 100644 --- a/ecmascript/tooling/base/pt_types.cpp +++ b/ecmascript/tooling/base/pt_types.cpp @@ -1042,6 +1042,35 @@ std::unique_ptr Location::Create(const EcmaVM *ecmaVm, const Local Location::Create(const PtJson ¶ms) +{ + std::string error; + auto location = std::make_unique(); + + std::string scriptId = params.GetString("scriptId"); + if (scriptId.empty()) { + error += "should contain string 'scriptId';"; + } else { + location->scriptId_ = static_cast(std::stoi(scriptId)); + } + int32_t line = params.GetInt("lineNumber", -1); + if (line == -1) { + error += "should contain number 'lineNumber';"; + } else { + location->line_ = line; + } + int32_t column = params.GetInt("columnNumber", -1); + if (column != -1) { + location->column_ = column; + } + if (!error.empty()) { + LOG(ERROR, DEBUGGER) << "Location::Create " << error; + return nullptr; + } + + return location; +} + Local Location::ToObject(const EcmaVM *ecmaVm) const { Local params = NewObject(ecmaVm); diff --git a/ecmascript/tooling/base/pt_types.h b/ecmascript/tooling/base/pt_types.h index b96315b8c..db71e8791 100644 --- a/ecmascript/tooling/base/pt_types.h +++ b/ecmascript/tooling/base/pt_types.h @@ -941,6 +941,7 @@ public: ~Location() override = default; static std::unique_ptr Create(const EcmaVM *ecmaVm, const Local ¶ms); + static std::unique_ptr Create(const PtJson ¶ms); Local ToObject(const EcmaVM *ecmaVm) const override; ScriptId GetScriptId() const diff --git a/ecmascript/tooling/test/debugger_params_test.cpp b/ecmascript/tooling/test/debugger_params_test.cpp index 06e89c538..521e71ec8 100644 --- a/ecmascript/tooling/test/debugger_params_test.cpp +++ b/ecmascript/tooling/test/debugger_params_test.cpp @@ -65,6 +65,24 @@ protected: JSThread *thread {nullptr}; }; +HWTEST_F_L0(DebuggerParamsTest, EnableParamsCreateTest) +{ + std::string msg; + std::unique_ptr enableParams; + + // abnormal + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + enableParams = EnableParams::Create(DispatchRequest(ecmaVm, msg).GetParams()); + ASSERT_NE(enableParams, nullptr); + EXPECT_FALSE(enableParams->HasMaxScriptsCacheSize()); + + // normal + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"maxScriptsCacheSize":100}})"; + enableParams = EnableParams::Create(DispatchRequest(ecmaVm, msg).GetParams()); + ASSERT_NE(enableParams, nullptr); + EXPECT_EQ(enableParams->GetMaxScriptsCacheSize(), 100); +} + HWTEST_F_L0(DebuggerParamsTest, StartSamplingParamsCreateTest) { std::string msg; diff --git a/ecmascript/tooling/test/debugger_types_test.cpp b/ecmascript/tooling/test/debugger_types_test.cpp index 2ddd8ffaa..70125800b 100644 --- a/ecmascript/tooling/test/debugger_types_test.cpp +++ b/ecmascript/tooling/test/debugger_types_test.cpp @@ -1033,64 +1033,57 @@ HWTEST_F_L0(DebuggerTypesTest, LocationCreateTest) // abnormal params of null msg msg = std::string() + R"({})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); + location = Location::Create(DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(location, nullptr); // abnormal params of unexist key params msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); + location = Location::Create(DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(location, nullptr); // abnormal params of null params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); + location = Location::Create(DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(location, nullptr); // abnormal params of unknown params.sub-key msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); + location = Location::Create(DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(location, nullptr); // abnormal params of params.sub-key=["scriptId":10,"lineNumber":99] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":10,"lineNumber":99 }})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); + location = Location::Create(DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(location, nullptr); // abnormal params of params.sub-key=["scriptId":["id3"],"lineNumber":99] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":["id3"],"lineNumber":99 }})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); + location = Location::Create(DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(location, nullptr); // abnormal params of params.sub-key=["scriptId":"222","lineNumber":"99"] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":"99" }})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); + location = Location::Create(DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(location, nullptr); // abnormal params of params.sub-key=["scriptId":"222","lineNumber":[99]] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":[99] }})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); - EXPECT_EQ(location, nullptr); - - // abnormal params of params.sub-key=["scriptId":"2","lineNumber":99,"columnNumber":"18"] - msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ - "scriptId":"222","lineNumber":899,"columnNumber":"18" - }})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); + location = Location::Create(DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(location, nullptr); // normal params of params.sub-key=["scriptId":"2","lineNumber":99,"columnNumber":138] msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":899,"columnNumber":138 }})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); + location = Location::Create(DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(location, nullptr); EXPECT_EQ(222U, location->GetScriptId()); EXPECT_EQ(location->GetLine(), 899); @@ -1100,7 +1093,7 @@ HWTEST_F_L0(DebuggerTypesTest, LocationCreateTest) msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"2122","lineNumber":8299 }})"; - location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); + location = Location::Create(DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(location, nullptr); EXPECT_EQ(2122U, location->GetScriptId()); EXPECT_EQ(location->GetLine(), 8299); -- Gitee From aed241208d642436f7a44d9ca62301edcca2cf7e Mon Sep 17 00:00:00 2001 From: wengchangcheng Date: Wed, 8 Jun 2022 18:20:09 +0800 Subject: [PATCH 3/3] Descriptor: debugger refactor of independent js_runtime [ part-2 ] details: add ToJson sample by PtJson issue: https://gitee.com/openharmony/ark_js_runtime/issues/I5BBPM Signed-off-by: wengchangcheng Change-Id: Icb84d3c163a662230730f4e27362f3ea23b80e1c --- ecmascript/tooling/base/pt_events.cpp | 13 ++++++++ ecmascript/tooling/base/pt_events.h | 1 + ecmascript/tooling/base/pt_returns.cpp | 9 ++++++ ecmascript/tooling/base/pt_returns.h | 1 + ecmascript/tooling/base/pt_types.cpp | 13 ++++++++ ecmascript/tooling/base/pt_types.h | 1 + .../tooling/test/debugger_events_test.cpp | 19 ++++++++++++ .../tooling/test/debugger_types_test.cpp | 30 +++++++++++++++++++ 8 files changed, 87 insertions(+) diff --git a/ecmascript/tooling/base/pt_events.cpp b/ecmascript/tooling/base/pt_events.cpp index 0f60511c4..41b2b7e67 100644 --- a/ecmascript/tooling/base/pt_events.cpp +++ b/ecmascript/tooling/base/pt_events.cpp @@ -36,6 +36,19 @@ Local BreakpointResolved::ToObject(const EcmaVM *ecmaVm) const return object; } +std::unique_ptr BreakpointResolved::ToJson() const +{ + std::unique_ptr result = PtJson::CreateObject(); + result->Add("breakpointId", breakpointId_.c_str()); + result->Add("location", location_->ToJson()); + + std::unique_ptr object = PtJson::CreateObject(); + object->Add("method", GetName().c_str()); + object->Add("params", result); + + return object; +} + Local Paused::ToObject(const EcmaVM *ecmaVm) const { Local params = NewObject(ecmaVm); diff --git a/ecmascript/tooling/base/pt_events.h b/ecmascript/tooling/base/pt_events.h index 2b0c09fcc..487df0d2e 100644 --- a/ecmascript/tooling/base/pt_events.h +++ b/ecmascript/tooling/base/pt_events.h @@ -42,6 +42,7 @@ public: BreakpointResolved() = default; ~BreakpointResolved() override = default; Local ToObject(const EcmaVM *ecmaVm) const override; + std::unique_ptr ToJson() const override; std::string GetName() const override { diff --git a/ecmascript/tooling/base/pt_returns.cpp b/ecmascript/tooling/base/pt_returns.cpp index 2358b83dd..22d043f45 100644 --- a/ecmascript/tooling/base/pt_returns.cpp +++ b/ecmascript/tooling/base/pt_returns.cpp @@ -27,6 +27,15 @@ Local EnableReturns::ToObject(const EcmaVM *ecmaVm) const return result; } +std::unique_ptr EnableReturns::ToJson() const +{ + std::unique_ptr result = PtJson::CreateObject(); + + result->Add("debuggerId", std::to_string(debuggerId_).c_str()); + + return result; +} + Local SetBreakpointByUrlReturns::ToObject(const EcmaVM *ecmaVm) const { size_t len = locations_.size(); diff --git a/ecmascript/tooling/base/pt_returns.h b/ecmascript/tooling/base/pt_returns.h index d474a46bc..4640525ce 100644 --- a/ecmascript/tooling/base/pt_returns.h +++ b/ecmascript/tooling/base/pt_returns.h @@ -44,6 +44,7 @@ public: ~EnableReturns() override = default; Local ToObject(const EcmaVM *ecmaVm) const override; + std::unique_ptr ToJson() const override; private: EnableReturns() = default; diff --git a/ecmascript/tooling/base/pt_types.cpp b/ecmascript/tooling/base/pt_types.cpp index 82d2ad5a6..1aaecbfda 100644 --- a/ecmascript/tooling/base/pt_types.cpp +++ b/ecmascript/tooling/base/pt_types.cpp @@ -1089,6 +1089,19 @@ Local Location::ToObject(const EcmaVM *ecmaVm) const return params; } +std::unique_ptr Location::ToJson() const +{ + std::unique_ptr result = PtJson::CreateObject(); + + result->Add("scriptId", std::to_string(scriptId_).c_str()); + result->Add("lineNumber", line_); + if (column_) { + result->Add("columnNumber", column_.value()); + } + + return result; +} + std::unique_ptr ScriptPosition::Create(const EcmaVM *ecmaVm, const Local ¶ms) { if (params.IsEmpty() || !params->IsObject()) { diff --git a/ecmascript/tooling/base/pt_types.h b/ecmascript/tooling/base/pt_types.h index db71e8791..f9ef610e5 100644 --- a/ecmascript/tooling/base/pt_types.h +++ b/ecmascript/tooling/base/pt_types.h @@ -943,6 +943,7 @@ public: static std::unique_ptr Create(const EcmaVM *ecmaVm, const Local ¶ms); static std::unique_ptr Create(const PtJson ¶ms); Local ToObject(const EcmaVM *ecmaVm) const override; + std::unique_ptr ToJson() const override; ScriptId GetScriptId() const { diff --git a/ecmascript/tooling/test/debugger_events_test.cpp b/ecmascript/tooling/test/debugger_events_test.cpp index 2470553b3..06d87cdd3 100644 --- a/ecmascript/tooling/test/debugger_events_test.cpp +++ b/ecmascript/tooling/test/debugger_events_test.cpp @@ -87,6 +87,25 @@ HWTEST_F_L0(DebuggerEventsTest, BreakpointResolvedToObjectTest) ASSERT_TRUE(result->IsObject()); } +HWTEST_F_L0(DebuggerEventsTest, BreakpointResolvedToJsonTest) +{ + BreakpointResolved breakpointResolved; + + auto location = std::make_unique(); + location->SetScriptId(2).SetLine(99); + breakpointResolved.SetBreakpointId("00").SetLocation(std::move(location)); + + auto json = breakpointResolved.ToJson()->GetObject("params"); + auto breakpointId = json->GetString("breakpointId"); + EXPECT_EQ(breakpointId, "00"); + + auto locationJson = json->GetObject("location"); + auto scriptId = locationJson->GetString("scriptId"); + EXPECT_EQ(scriptId, "2"); + auto lineNumber = locationJson->GetInt("lineNumber"); + EXPECT_EQ(lineNumber, 99); +} + HWTEST_F_L0(DebuggerEventsTest, PausedToObjectTest) { Paused paused; diff --git a/ecmascript/tooling/test/debugger_types_test.cpp b/ecmascript/tooling/test/debugger_types_test.cpp index 70125800b..de2864a13 100644 --- a/ecmascript/tooling/test/debugger_types_test.cpp +++ b/ecmascript/tooling/test/debugger_types_test.cpp @@ -1129,6 +1129,36 @@ HWTEST_F_L0(DebuggerTypesTest, LocationToObjectTest) EXPECT_EQ(Local(result)->Value(), 18); } +HWTEST_F_L0(DebuggerTypesTest, LocationToJsonTest) +{ + std::string msg; + std::unique_ptr location; + Local tmpStr; + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ + "scriptId":"2","lineNumber":99,"columnNumber":18 + }})"; + location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParamsObj()); + ASSERT_NE(location, nullptr); + Local object = location->ToObject(ecmaVm); + + tmpStr = StringRef::NewFromUtf8(ecmaVm, "scriptId"); + ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); + Local result = object->Get(ecmaVm, tmpStr); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); + EXPECT_EQ("2", DebuggerApi::ToStdString(result)); + tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber"); + ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); + result = object->Get(ecmaVm, tmpStr); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); + EXPECT_EQ(Local(result)->Value(), 99); + tmpStr = StringRef::NewFromUtf8(ecmaVm, "columnNumber"); + ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); + result = object->Get(ecmaVm, tmpStr); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); + EXPECT_EQ(Local(result)->Value(), 18); +} + HWTEST_F_L0(DebuggerTypesTest, BreakLocationCreateTest) { std::string msg; -- Gitee