From 8c603a3b669631918750ef9aa22ba7bd00f65cb7 Mon Sep 17 00:00:00 2001 From: wengchangcheng Date: Thu, 30 Sep 2021 15:19:45 +0800 Subject: [PATCH] fix debugger crash Signed-off-by: wengchangcheng --- ecmascript/tooling/BUILD.gn | 2 + ecmascript/tooling/agent/debugger_impl.cpp | 40 +++++ ecmascript/tooling/agent/runtime_impl.cpp | 4 + ecmascript/tooling/base/pt_events.cpp | 78 +++++----- ecmascript/tooling/base/pt_params.cpp | 50 +++--- ecmascript/tooling/base/pt_types.cpp | 116 +++++++------- .../tooling/test/debugger_events_test.cpp | 86 +++++------ .../tooling/test/debugger_types_test.cpp | 146 +++++++++--------- 8 files changed, 284 insertions(+), 238 deletions(-) diff --git a/ecmascript/tooling/BUILD.gn b/ecmascript/tooling/BUILD.gn index 43898ca3ca..e789c1b086 100644 --- a/ecmascript/tooling/BUILD.gn +++ b/ecmascript/tooling/BUILD.gn @@ -85,6 +85,8 @@ source_set("libark_ecma_debugger_test_static") { "$ark_root/libpandabase:libarkbase", "$ark_root/libpandafile:libarkfile", "$ark_root/runtime:arkruntime_gen_intrinsics_intrinsics_h", + "$ark_root/runtime:libarkruntime_options_gen_h", + "$ark_root/verification/gen:verification_verifier_messages_h", ] } diff --git a/ecmascript/tooling/agent/debugger_impl.cpp b/ecmascript/tooling/agent/debugger_impl.cpp index d888667e58..dec7485bf2 100644 --- a/ecmascript/tooling/agent/debugger_impl.cpp +++ b/ecmascript/tooling/agent/debugger_impl.cpp @@ -57,6 +57,10 @@ void DebuggerImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) void DebuggerImpl::DispatcherImpl::Enable(const DispatchRequest &request) { std::unique_ptr params = EnableParams::Create(request.GetEcmaVM(), request.GetParams()); + if (params == nullptr) { + SendResponse(request, DispatchResponse::Fail("Debugger got wrong params"), nullptr); + return; + } UniqueDebuggerId id; DispatchResponse response = debugger_->Enable(std::move(params), &id); @@ -69,6 +73,10 @@ void DebuggerImpl::DispatcherImpl::EvaluateOnCallFrame(const DispatchRequest &re { std::unique_ptr params = EvaluateOnCallFrameParams::Create(request.GetEcmaVM(), request.GetParams()); + if (params == nullptr) { + SendResponse(request, DispatchResponse::Fail("Debugger got wrong params"), nullptr); + return; + } std::unique_ptr result1 = std::make_unique(); DispatchResponse response = debugger_->EvaluateOnCallFrame(std::move(params), &result1); @@ -81,6 +89,10 @@ void DebuggerImpl::DispatcherImpl::GetPossibleBreakpoints(const DispatchRequest { std::unique_ptr params = GetPossibleBreakpointsParams::Create(request.GetEcmaVM(), request.GetParams()); + if (params == nullptr) { + SendResponse(request, DispatchResponse::Fail("Debugger got wrong params"), nullptr); + return; + } CVector> locations; DispatchResponse response = debugger_->GetPossibleBreakpoints(std::move(params), &locations); std::unique_ptr points = @@ -92,6 +104,10 @@ void DebuggerImpl::DispatcherImpl::GetScriptSource(const DispatchRequest &reques { std::unique_ptr params = GetScriptSourceParams::Create(request.GetEcmaVM(), request.GetParams()); + if (params == nullptr) { + SendResponse(request, DispatchResponse::Fail("Debugger got wrong params"), nullptr); + return; + } CString source; DispatchResponse response = debugger_->GetScriptSource(std::move(params), &source); std::unique_ptr result = std::make_unique(std::move(source)); @@ -109,6 +125,10 @@ void DebuggerImpl::DispatcherImpl::RemoveBreakpoint(const DispatchRequest &reque { std::unique_ptr params = RemoveBreakpointParams::Create(request.GetEcmaVM(), request.GetParams()); + if (params == nullptr) { + SendResponse(request, DispatchResponse::Fail("Debugger got wrong params"), nullptr); + return; + } DispatchResponse response = debugger_->RemoveBreakpoint(std::move(params)); std::unique_ptr result = std::make_unique(); SendResponse(request, response, std::move(result)); @@ -117,6 +137,10 @@ void DebuggerImpl::DispatcherImpl::RemoveBreakpoint(const DispatchRequest &reque void DebuggerImpl::DispatcherImpl::Resume(const DispatchRequest &request) { std::unique_ptr params = ResumeParams::Create(request.GetEcmaVM(), request.GetParams()); + if (params == nullptr) { + SendResponse(request, DispatchResponse::Fail("Debugger got wrong params"), nullptr); + return; + } DispatchResponse response = debugger_->Resume(std::move(params)); std::unique_ptr result = std::make_unique(); SendResponse(request, response, std::move(result)); @@ -133,6 +157,10 @@ void DebuggerImpl::DispatcherImpl::SetBreakpointByUrl(const DispatchRequest &req { std::unique_ptr params = SetBreakpointByUrlParams::Create(request.GetEcmaVM(), request.GetParams()); + if (params == nullptr) { + SendResponse(request, DispatchResponse::Fail("Debugger got wrong params"), nullptr); + return; + } CString out_id; CVector> outLocations; @@ -146,6 +174,10 @@ void DebuggerImpl::DispatcherImpl::SetPauseOnExceptions(const DispatchRequest &r { std::unique_ptr params = SetPauseOnExceptionsParams::Create(request.GetEcmaVM(), request.GetParams()); + if (params == nullptr) { + SendResponse(request, DispatchResponse::Fail("Debugger got wrong params"), nullptr); + return; + } DispatchResponse response = debugger_->SetPauseOnExceptions(std::move(params)); std::unique_ptr result = std::make_unique(); @@ -155,6 +187,10 @@ void DebuggerImpl::DispatcherImpl::SetPauseOnExceptions(const DispatchRequest &r void DebuggerImpl::DispatcherImpl::StepInto(const DispatchRequest &request) { std::unique_ptr params = StepIntoParams::Create(request.GetEcmaVM(), request.GetParams()); + if (params == nullptr) { + SendResponse(request, DispatchResponse::Fail("Debugger got wrong params"), nullptr); + return; + } DispatchResponse response = debugger_->StepInto(std::move(params)); std::unique_ptr result = std::make_unique(); SendResponse(request, response, std::move(result)); @@ -170,6 +206,10 @@ void DebuggerImpl::DispatcherImpl::StepOut(const DispatchRequest &request) void DebuggerImpl::DispatcherImpl::StepOver(const DispatchRequest &request) { std::unique_ptr params = StepOverParams::Create(request.GetEcmaVM(), request.GetParams()); + if (params == nullptr) { + SendResponse(request, DispatchResponse::Fail("Debugger got wrong params"), nullptr); + return; + } DispatchResponse response = debugger_->StepOver(std::move(params)); std::unique_ptr result = std::make_unique(); SendResponse(request, response, std::move(result)); diff --git a/ecmascript/tooling/agent/runtime_impl.cpp b/ecmascript/tooling/agent/runtime_impl.cpp index 9592a3e85a..b39d10eca1 100644 --- a/ecmascript/tooling/agent/runtime_impl.cpp +++ b/ecmascript/tooling/agent/runtime_impl.cpp @@ -56,6 +56,10 @@ void RuntimeImpl::DispatcherImpl::RunIfWaitingForDebugger(const DispatchRequest void RuntimeImpl::DispatcherImpl::GetProperties(const DispatchRequest &request) { std::unique_ptr params = GetPropertiesParams::Create(request.GetEcmaVM(), request.GetParams()); + if (params == nullptr) { + SendResponse(request, DispatchResponse::Fail("Debugger got wrong params"), nullptr); + return; + } CVector> outPropertyDesc; std::optional>> outInternalDescs; diff --git a/ecmascript/tooling/base/pt_events.cpp b/ecmascript/tooling/base/pt_events.cpp index dd082b4372..6b15c56e8e 100644 --- a/ecmascript/tooling/base/pt_events.cpp +++ b/ecmascript/tooling/base/pt_events.cpp @@ -27,7 +27,7 @@ std::unique_ptr BreakpointResolved::Create(const EcmaVM *ecm Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "breakpointId"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { breakpointResolved->breakpointId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -37,7 +37,7 @@ std::unique_ptr BreakpointResolved::Create(const EcmaVM *ecm error += "should contain 'breakpointId';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "location"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { std::unique_ptr location = Location::Create(ecmaVm, result); if (location == nullptr) { @@ -90,7 +90,7 @@ std::unique_ptr Paused::Create(const EcmaVM *ecmaVm, const Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "callFrames"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsArray(ecmaVm)) { auto array = Local(result); uint32_t len = array->Length(ecmaVm); @@ -111,7 +111,7 @@ std::unique_ptr Paused::Create(const EcmaVM *ecmaVm, const Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "reason"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { paused->reason_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -121,7 +121,7 @@ std::unique_ptr Paused::Create(const EcmaVM *ecmaVm, const Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "data"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { paused->data_ = Local(result); } else { @@ -129,7 +129,7 @@ std::unique_ptr Paused::Create(const EcmaVM *ecmaVm, const Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "hitBreakpoints"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsArray(ecmaVm)) { CVector breakPoints; auto array = Local(result); @@ -221,7 +221,7 @@ std::unique_ptr ScriptFailedToParse::Create(const EcmaVM *e auto scriptEvent = std::make_unique(); Local result = Local(params)->Get(ecmaVm, StringRef::NewFromUtf8(ecmaVm, "scriptId")); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { scriptEvent->scriptId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -231,7 +231,7 @@ std::unique_ptr ScriptFailedToParse::Create(const EcmaVM *e error += "should contain 'scriptId';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "url"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { scriptEvent->url_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -241,7 +241,7 @@ std::unique_ptr ScriptFailedToParse::Create(const EcmaVM *e error += "should contain 'url';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "startLine"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { scriptEvent->startLine_ = static_cast(Local(result)->Value()); } else { @@ -251,7 +251,7 @@ std::unique_ptr ScriptFailedToParse::Create(const EcmaVM *e error += "should contain 'startLine';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "startColumn"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { scriptEvent->startColumn_ = static_cast(Local(result)->Value()); } else { @@ -261,7 +261,7 @@ std::unique_ptr ScriptFailedToParse::Create(const EcmaVM *e error += "should contain 'startColumn';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "endLine"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { scriptEvent->endLine_ = static_cast(Local(result)->Value()); } else { @@ -271,7 +271,7 @@ std::unique_ptr ScriptFailedToParse::Create(const EcmaVM *e error += "should contain 'endLine';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "endColumn"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { scriptEvent->endColumn_ = static_cast(Local(result)->Value()); } else { @@ -282,7 +282,7 @@ std::unique_ptr ScriptFailedToParse::Create(const EcmaVM *e } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "executionContextId"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { scriptEvent->executionContextId_ = static_cast(Local(result)->Value()); } else { @@ -292,7 +292,7 @@ std::unique_ptr ScriptFailedToParse::Create(const EcmaVM *e error += "should contain 'executionContextId';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "hash"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { scriptEvent->hash_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -303,7 +303,7 @@ std::unique_ptr ScriptFailedToParse::Create(const EcmaVM *e } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "executionContextAuxData"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { scriptEvent->execContextAuxData_ = Local(result); } else { @@ -311,7 +311,7 @@ std::unique_ptr ScriptFailedToParse::Create(const EcmaVM *e } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "sourceMapURL"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { scriptEvent->sourceMapUrl_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -319,7 +319,7 @@ std::unique_ptr ScriptFailedToParse::Create(const EcmaVM *e } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "hasSourceURL"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsBoolean()) { scriptEvent->hasSourceUrl_ = result->IsTrue(); } else { @@ -327,7 +327,7 @@ std::unique_ptr ScriptFailedToParse::Create(const EcmaVM *e } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "isModule"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsBoolean()) { scriptEvent->isModule_ = result->IsTrue(); } else { @@ -335,7 +335,7 @@ std::unique_ptr ScriptFailedToParse::Create(const EcmaVM *e } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "length"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { scriptEvent->length_ = static_cast(Local(result)->Value()); } else { @@ -343,7 +343,7 @@ std::unique_ptr ScriptFailedToParse::Create(const EcmaVM *e } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "codeOffset"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { scriptEvent->codeOffset_ = static_cast(Local(result)->Value()); } else { @@ -351,7 +351,7 @@ std::unique_ptr ScriptFailedToParse::Create(const EcmaVM *e } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "scriptLanguage"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { scriptEvent->scriptLanguage_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -359,7 +359,7 @@ std::unique_ptr ScriptFailedToParse::Create(const EcmaVM *e } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "embedderName"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { scriptEvent->embedderName_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -460,7 +460,7 @@ std::unique_ptr ScriptParsed::Create(const EcmaVM *ecmaVm, const L Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "scriptId"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { scriptEvent->scriptId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -470,7 +470,7 @@ std::unique_ptr ScriptParsed::Create(const EcmaVM *ecmaVm, const L error += "should contain 'scriptId';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "url"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { scriptEvent->url_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -480,7 +480,7 @@ std::unique_ptr ScriptParsed::Create(const EcmaVM *ecmaVm, const L error += "should contain 'url';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "startLine"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { scriptEvent->startLine_ = static_cast(Local(result)->Value()); } else { @@ -490,7 +490,7 @@ std::unique_ptr ScriptParsed::Create(const EcmaVM *ecmaVm, const L error += "should contain 'startLine';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "startColumn"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { scriptEvent->startColumn_ = static_cast(Local(result)->Value()); } else { @@ -500,7 +500,7 @@ std::unique_ptr ScriptParsed::Create(const EcmaVM *ecmaVm, const L error += "should contain 'startColumn';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "endLine"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { scriptEvent->endLine_ = static_cast(Local(result)->Value()); } else { @@ -510,7 +510,7 @@ std::unique_ptr ScriptParsed::Create(const EcmaVM *ecmaVm, const L error += "should contain 'endLine';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "endColumn"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { scriptEvent->endColumn_ = static_cast(Local(result)->Value()); } else { @@ -521,7 +521,7 @@ std::unique_ptr ScriptParsed::Create(const EcmaVM *ecmaVm, const L } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "executionContextId"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { scriptEvent->executionContextId_ = static_cast(Local(result)->Value()); } else { @@ -531,7 +531,7 @@ std::unique_ptr ScriptParsed::Create(const EcmaVM *ecmaVm, const L error += "should contain 'executionContextId';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "hash"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { scriptEvent->hash_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -542,7 +542,7 @@ std::unique_ptr ScriptParsed::Create(const EcmaVM *ecmaVm, const L } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "executionContextAuxData"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { scriptEvent->execContextAuxData_ = Local(result); } else { @@ -550,7 +550,7 @@ std::unique_ptr ScriptParsed::Create(const EcmaVM *ecmaVm, const L } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "isLiveEdit"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsBoolean()) { scriptEvent->isLiveEdit_ = result->IsTrue(); } else { @@ -558,7 +558,7 @@ std::unique_ptr ScriptParsed::Create(const EcmaVM *ecmaVm, const L } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "sourceMapURL"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { scriptEvent->sourceMapUrl_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -566,7 +566,7 @@ std::unique_ptr ScriptParsed::Create(const EcmaVM *ecmaVm, const L } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "hasSourceURL"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsBoolean()) { scriptEvent->hasSourceUrl_ = result->IsTrue(); } else { @@ -574,7 +574,7 @@ std::unique_ptr ScriptParsed::Create(const EcmaVM *ecmaVm, const L } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "isModule"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsBoolean()) { scriptEvent->isModule_ = result->IsTrue(); } else { @@ -582,7 +582,7 @@ std::unique_ptr ScriptParsed::Create(const EcmaVM *ecmaVm, const L } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "length"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { scriptEvent->length_ = static_cast(Local(result)->Value()); } else { @@ -590,7 +590,7 @@ std::unique_ptr ScriptParsed::Create(const EcmaVM *ecmaVm, const L } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "codeOffset"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { scriptEvent->codeOffset_ = static_cast(Local(result)->Value()); } else { @@ -598,7 +598,7 @@ std::unique_ptr ScriptParsed::Create(const EcmaVM *ecmaVm, const L } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "scriptLanguage"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { scriptEvent->scriptLanguage_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -606,7 +606,7 @@ std::unique_ptr ScriptParsed::Create(const EcmaVM *ecmaVm, const L } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "embedderName"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { scriptEvent->embedderName_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { diff --git a/ecmascript/tooling/base/pt_params.cpp b/ecmascript/tooling/base/pt_params.cpp index 156c1bd801..2893c27617 100644 --- a/ecmascript/tooling/base/pt_params.cpp +++ b/ecmascript/tooling/base/pt_params.cpp @@ -28,7 +28,7 @@ std::unique_ptr EnableParams::Create(const EcmaVM *ecmaVm, const L Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "maxScriptsCacheSize"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { paramsObject->maxScriptsCacheSize_ = Local(result)->Value(); } else { @@ -56,7 +56,7 @@ std::unique_ptr EvaluateOnCallFrameParams::Create(con Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "callFrameId"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { paramsObject->callFrameId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -67,7 +67,7 @@ std::unique_ptr EvaluateOnCallFrameParams::Create(con } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "expression"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { paramsObject->expression_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -130,7 +130,7 @@ std::unique_ptr GetPossibleBreakpointsParams::Crea Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "start"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { std::unique_ptr obj = Location::Create(ecmaVm, result); if (obj == nullptr) { @@ -145,7 +145,7 @@ std::unique_ptr GetPossibleBreakpointsParams::Crea error += "should contain 'start';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "end"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { std::unique_ptr obj = Location::Create(ecmaVm, result); if (obj == nullptr) { @@ -159,7 +159,7 @@ std::unique_ptr GetPossibleBreakpointsParams::Crea } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "restrictToFunction"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsBoolean()) { paramsObject->restrictToFunction_ = result->IsTrue(); } else { @@ -187,7 +187,7 @@ std::unique_ptr GetScriptSourceParams::Create(const EcmaV Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "scriptId"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { paramsObject->scriptId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -217,7 +217,7 @@ std::unique_ptr RemoveBreakpointParams::Create(const Ecm Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "breakpointId"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { paramsObject->breakpointId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -246,7 +246,7 @@ std::unique_ptr ResumeParams::Create(const EcmaVM *ecmaVm, const L Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "terminateOnResume"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsBoolean()) { paramsObject->terminateOnResume_ = result->IsTrue(); } else { @@ -274,7 +274,7 @@ std::unique_ptr SetAsyncCallStackDepthParams::Crea Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "maxDepth"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { paramsObject->maxDepth_ = static_cast(Local(result)->Value()); } else { @@ -304,7 +304,7 @@ std::unique_ptr SetBlackboxPatternsParams::Create(con Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "patterns"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsArray(ecmaVm)) { Local array = Local(result); uint32_t len = array->Length(ecmaVm); @@ -346,7 +346,7 @@ std::unique_ptr SetBreakpointByUrlParams::Create(const Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "lineNumber"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { paramsObject->line_ = static_cast(Local(result)->Value()); } else { @@ -356,7 +356,7 @@ std::unique_ptr SetBreakpointByUrlParams::Create(const error += "should contain 'lineNumber';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "url"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { paramsObject->url_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -364,7 +364,7 @@ std::unique_ptr SetBreakpointByUrlParams::Create(const } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "urlRegex"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { paramsObject->urlRegex_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -372,7 +372,7 @@ std::unique_ptr SetBreakpointByUrlParams::Create(const } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "scriptHash"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { paramsObject->scriptHash_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -380,7 +380,7 @@ std::unique_ptr SetBreakpointByUrlParams::Create(const } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "columnNumber"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { paramsObject->column_ = static_cast(Local(result)->Value()); } else { @@ -388,7 +388,7 @@ std::unique_ptr SetBreakpointByUrlParams::Create(const } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "condition"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { paramsObject->condition_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -416,7 +416,7 @@ std::unique_ptr SetPauseOnExceptionsParams::Create(c Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "state"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { if (!paramsObject->StoreState(DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()))) { error += "'state' is invalid;"; @@ -447,7 +447,7 @@ std::unique_ptr StepIntoParams::Create(const EcmaVM *ecmaVm, con Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "breakOnAsyncCall"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsBoolean()) { paramsObject->breakOnAsyncCall_ = result->IsTrue(); } else { @@ -455,7 +455,7 @@ std::unique_ptr StepIntoParams::Create(const EcmaVM *ecmaVm, con } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "skipList"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsArray(ecmaVm)) { Local array = Local(result); uint32_t len = array->Length(ecmaVm); @@ -498,7 +498,7 @@ std::unique_ptr StepOverParams::Create(const EcmaVM *ecmaVm, con Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "skipList"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsArray(ecmaVm)) { Local array = Local(result); uint32_t len = array->Length(ecmaVm); @@ -541,7 +541,7 @@ std::unique_ptr GetPropertiesParams::Create(const EcmaVM *e Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "objectId"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { paramsObject->objectId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -551,7 +551,7 @@ std::unique_ptr GetPropertiesParams::Create(const EcmaVM *e error += "should contain 'objectId';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "ownProperties"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsBoolean()) { paramsObject->ownProperties_ = result->IsTrue(); } else { @@ -560,7 +560,7 @@ std::unique_ptr GetPropertiesParams::Create(const EcmaVM *e } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "accessorPropertiesOnly"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsBoolean()) { paramsObject->accessorPropertiesOnly_ = result->IsTrue(); } else { @@ -569,7 +569,7 @@ std::unique_ptr GetPropertiesParams::Create(const EcmaVM *e } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "generatePreview"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsBoolean()) { paramsObject->generatePreview_ = result->IsTrue(); } else { diff --git a/ecmascript/tooling/base/pt_types.cpp b/ecmascript/tooling/base/pt_types.cpp index 7822525e9a..8a8556e402 100644 --- a/ecmascript/tooling/base/pt_types.cpp +++ b/ecmascript/tooling/base/pt_types.cpp @@ -311,7 +311,7 @@ std::unique_ptr RemoteObject::Create(const EcmaVM *ecmaVm, const L Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "type"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { auto type = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); if (ObjectType::Valid(type)) { @@ -326,7 +326,7 @@ std::unique_ptr RemoteObject::Create(const EcmaVM *ecmaVm, const L error += "should contain 'type';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "subtype"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { auto type = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); if (ObjectSubType::Valid(type)) { @@ -339,7 +339,7 @@ std::unique_ptr RemoteObject::Create(const EcmaVM *ecmaVm, const L } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "className"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { remoteObject->className_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -347,12 +347,12 @@ std::unique_ptr RemoteObject::Create(const EcmaVM *ecmaVm, const L } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "value"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { remoteObject->value_ = result; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "unserializableValue"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { remoteObject->unserializableValue_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -360,7 +360,7 @@ std::unique_ptr RemoteObject::Create(const EcmaVM *ecmaVm, const L } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "description"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { remoteObject->description_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -368,7 +368,7 @@ std::unique_ptr RemoteObject::Create(const EcmaVM *ecmaVm, const L } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "objectId"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { remoteObject->objectId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -433,7 +433,7 @@ std::unique_ptr ExceptionDetails::Create(const EcmaVM *ecmaVm, Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "exceptionId"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { exceptionDetails->exceptionId_ = static_cast(Local(result)->Value()); } else { @@ -443,7 +443,7 @@ std::unique_ptr ExceptionDetails::Create(const EcmaVM *ecmaVm, error += "should contain 'exceptionId';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "text"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { exceptionDetails->text_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -453,7 +453,7 @@ std::unique_ptr ExceptionDetails::Create(const EcmaVM *ecmaVm, error += "should contain 'text';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "lineNumber"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { exceptionDetails->line_ = static_cast(Local(result)->Value()); } else { @@ -463,7 +463,7 @@ std::unique_ptr ExceptionDetails::Create(const EcmaVM *ecmaVm, error += "should contain 'lineNumber';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "columnNumber"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { exceptionDetails->column_ = static_cast(Local(result)->Value()); } else { @@ -473,7 +473,7 @@ std::unique_ptr ExceptionDetails::Create(const EcmaVM *ecmaVm, error += "should contain 'columnNumber';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "scriptId"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { exceptionDetails->scriptId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -481,7 +481,7 @@ std::unique_ptr ExceptionDetails::Create(const EcmaVM *ecmaVm, } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "url"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { exceptionDetails->url_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -489,7 +489,7 @@ std::unique_ptr ExceptionDetails::Create(const EcmaVM *ecmaVm, } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "exception"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { std::unique_ptr obj = RemoteObject::Create(ecmaVm, result); if (obj == nullptr) { @@ -504,7 +504,7 @@ std::unique_ptr ExceptionDetails::Create(const EcmaVM *ecmaVm, result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "executionContextId"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { exceptionDetails->executionContextId_ = static_cast(Local(result)->Value()); } else { @@ -570,7 +570,7 @@ std::unique_ptr InternalPropertyDescriptor::Create(c Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "name"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { internalPropertyDescriptor->name_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -580,7 +580,7 @@ std::unique_ptr InternalPropertyDescriptor::Create(c error += "should contain 'name';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "value"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { std::unique_ptr obj = RemoteObject::Create(ecmaVm, result); if (obj == nullptr) { @@ -629,7 +629,7 @@ std::unique_ptr PrivatePropertyDescriptor::Create(con Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "name"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { propertyDescriptor->name_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -639,7 +639,7 @@ std::unique_ptr PrivatePropertyDescriptor::Create(con error += "should contain 'name';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "value"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { std::unique_ptr obj = RemoteObject::Create(ecmaVm, result); if (obj == nullptr) { @@ -652,7 +652,7 @@ std::unique_ptr PrivatePropertyDescriptor::Create(con } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "get"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { std::unique_ptr obj = RemoteObject::Create(ecmaVm, result); if (obj == nullptr) { @@ -665,7 +665,7 @@ std::unique_ptr PrivatePropertyDescriptor::Create(con } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "set"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { std::unique_ptr obj = RemoteObject::Create(ecmaVm, result); if (obj == nullptr) { @@ -760,7 +760,7 @@ std::unique_ptr PropertyDescriptor::Create(const EcmaVM *ecm Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "name"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { propertyDescriptor->name_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -770,7 +770,7 @@ std::unique_ptr PropertyDescriptor::Create(const EcmaVM *ecm error += "should contain 'name';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "value"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { std::unique_ptr obj = RemoteObject::Create(ecmaVm, result); if (obj == nullptr) { @@ -783,7 +783,7 @@ std::unique_ptr PropertyDescriptor::Create(const EcmaVM *ecm } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "writable"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsBoolean()) { propertyDescriptor->writable_ = result->IsTrue(); } else { @@ -791,7 +791,7 @@ std::unique_ptr PropertyDescriptor::Create(const EcmaVM *ecm } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "get"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { std::unique_ptr obj = RemoteObject::Create(ecmaVm, result); if (obj == nullptr) { @@ -804,7 +804,7 @@ std::unique_ptr PropertyDescriptor::Create(const EcmaVM *ecm } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "set"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { std::unique_ptr obj = RemoteObject::Create(ecmaVm, result); if (obj == nullptr) { @@ -817,7 +817,7 @@ std::unique_ptr PropertyDescriptor::Create(const EcmaVM *ecm } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "configurable"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsBoolean()) { propertyDescriptor->configurable_ = result->IsTrue(); } else { @@ -827,7 +827,7 @@ std::unique_ptr PropertyDescriptor::Create(const EcmaVM *ecm error += "should contain 'configurable';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "enumerable"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsBoolean()) { propertyDescriptor->enumerable_ = result->IsTrue(); } else { @@ -837,7 +837,7 @@ std::unique_ptr PropertyDescriptor::Create(const EcmaVM *ecm error += "should contain 'enumerable';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "wasThrown"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsBoolean()) { propertyDescriptor->wasThrown_ = result->IsTrue(); } else { @@ -845,7 +845,7 @@ std::unique_ptr PropertyDescriptor::Create(const EcmaVM *ecm } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "isOwn"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsBoolean()) { propertyDescriptor->isOwn_ = result->IsTrue(); } else { @@ -853,7 +853,7 @@ std::unique_ptr PropertyDescriptor::Create(const EcmaVM *ecm } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "symbol"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { std::unique_ptr obj = RemoteObject::Create(ecmaVm, result); if (obj == nullptr) { @@ -939,7 +939,7 @@ std::unique_ptr Location::Create(const EcmaVM *ecmaVm, const Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "scriptId"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { location->scriptId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -949,7 +949,7 @@ std::unique_ptr Location::Create(const EcmaVM *ecmaVm, const Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "lineNumber"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { location->line_ = static_cast(Local(result)->Value()); } else { @@ -959,7 +959,7 @@ std::unique_ptr Location::Create(const EcmaVM *ecmaVm, const Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "columnNumber"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { location->column_ = static_cast(Local(result)->Value()); } else { @@ -1003,7 +1003,7 @@ std::unique_ptr ScriptPosition::Create(const EcmaVM *ecmaVm, con Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "lineNumber"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { scriptPosition->line_ = static_cast(Local(result)->Value()); } else { @@ -1013,7 +1013,7 @@ std::unique_ptr ScriptPosition::Create(const EcmaVM *ecmaVm, con error += "should contain 'lineNumber';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "columnNumber"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { scriptPosition->column_ = static_cast(Local(result)->Value()); } else { @@ -1053,7 +1053,7 @@ std::unique_ptr SearchMatch::Create(const EcmaVM *ecmaVm, const Loc Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "lineNumber"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { locationSearch->lineNumber_ = static_cast(Local(result)->Value()); } else { @@ -1064,7 +1064,7 @@ std::unique_ptr SearchMatch::Create(const EcmaVM *ecmaVm, const Loc } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "lineContent"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { locationSearch->lineContent_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -1105,7 +1105,7 @@ std::unique_ptr LocationRange::Create(const EcmaVM *ecmaVm, const Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "scriptId"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { locationRange->scriptId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -1115,7 +1115,7 @@ std::unique_ptr LocationRange::Create(const EcmaVM *ecmaVm, const error += "should contain 'scriptId';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "start"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { std::unique_ptr obj = ScriptPosition::Create(ecmaVm, result); if (obj == nullptr) { @@ -1130,7 +1130,7 @@ std::unique_ptr LocationRange::Create(const EcmaVM *ecmaVm, const error += "should contain 'start';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "end"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { std::unique_ptr obj = ScriptPosition::Create(ecmaVm, result); if (obj == nullptr) { @@ -1181,7 +1181,7 @@ std::unique_ptr BreakLocation::Create(const EcmaVM *ecmaVm, const Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "scriptId"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { breakLocation->scriptId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -1191,7 +1191,7 @@ std::unique_ptr BreakLocation::Create(const EcmaVM *ecmaVm, const error += "should contain 'scriptId';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "lineNumber"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { breakLocation->line_ = static_cast(Local(result)->Value()); } else { @@ -1201,7 +1201,7 @@ std::unique_ptr BreakLocation::Create(const EcmaVM *ecmaVm, const error += "should contain 'lineNumber';"; } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "columnNumber"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsNumber()) { breakLocation->column_ = static_cast(Local(result)->Value()); } else { @@ -1209,7 +1209,7 @@ std::unique_ptr BreakLocation::Create(const EcmaVM *ecmaVm, const } } result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "type"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { auto type = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); if (BreakType::Valid(type)) { @@ -1263,7 +1263,7 @@ std::unique_ptr Scope::Create(const EcmaVM *ecmaVm, const Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "type"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { auto type = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); if (Scope::Type::Valid(type)) { @@ -1278,7 +1278,7 @@ std::unique_ptr Scope::Create(const EcmaVM *ecmaVm, const Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "object"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { std::unique_ptr obj = RemoteObject::Create(ecmaVm, result); if (obj == nullptr) { @@ -1293,7 +1293,7 @@ std::unique_ptr Scope::Create(const EcmaVM *ecmaVm, const Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "name"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { scope->name_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -1301,7 +1301,7 @@ std::unique_ptr Scope::Create(const EcmaVM *ecmaVm, const Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "startLocation"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { std::unique_ptr obj = Location::Create(ecmaVm, result); if (obj == nullptr) { @@ -1314,7 +1314,7 @@ std::unique_ptr Scope::Create(const EcmaVM *ecmaVm, const Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "endLocation"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { std::unique_ptr obj = Location::Create(ecmaVm, result); if (obj == nullptr) { @@ -1377,7 +1377,7 @@ std::unique_ptr CallFrame::Create(const EcmaVM *ecmaVm, const Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "callFrameId"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { callFrame->callFrameId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -1387,7 +1387,7 @@ std::unique_ptr CallFrame::Create(const EcmaVM *ecmaVm, const Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "functionName"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { callFrame->functionName_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -1398,7 +1398,7 @@ std::unique_ptr CallFrame::Create(const EcmaVM *ecmaVm, const Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "functionLocation"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { std::unique_ptr obj = Location::Create(ecmaVm, result); if (obj == nullptr) { @@ -1411,7 +1411,7 @@ std::unique_ptr CallFrame::Create(const EcmaVM *ecmaVm, const Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "location"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { std::unique_ptr obj = Location::Create(ecmaVm, result); if (obj == nullptr) { @@ -1426,7 +1426,7 @@ std::unique_ptr CallFrame::Create(const EcmaVM *ecmaVm, const Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "url"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { callFrame->url_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()); } else { @@ -1436,7 +1436,7 @@ std::unique_ptr CallFrame::Create(const EcmaVM *ecmaVm, const Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "scopeChain"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsArray(ecmaVm)) { auto array = Local(result); uint32_t len = array->Length(ecmaVm); @@ -1457,7 +1457,7 @@ std::unique_ptr CallFrame::Create(const EcmaVM *ecmaVm, const Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "this"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { std::unique_ptr obj = RemoteObject::Create(ecmaVm, result); if (obj == nullptr) { @@ -1472,7 +1472,7 @@ std::unique_ptr CallFrame::Create(const EcmaVM *ecmaVm, const Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "returnValue"))); - if (!result.IsEmpty()) { + if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsObject()) { std::unique_ptr obj = RemoteObject::Create(ecmaVm, result); if (obj == nullptr) { diff --git a/ecmascript/tooling/test/debugger_events_test.cpp b/ecmascript/tooling/test/debugger_events_test.cpp index 36125f5b52..47ac37e178 100644 --- a/ecmascript/tooling/test/debugger_events_test.cpp +++ b/ecmascript/tooling/test/debugger_events_test.cpp @@ -113,20 +113,20 @@ HWTEST_F_L0(DebuggerEventsTest, BreakpointResolvedToObjectTest) ASSERT_NE(breakpointResolved, nullptr); Local object1 = breakpointResolved->ToObject(ecmaVm); Local result = object1->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsObject()); Local object = Local(result); tmpStr = StringRef::NewFromUtf8(ecmaVm, "breakpointId"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("00", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "location"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsObject()); } @@ -199,20 +199,20 @@ HWTEST_F_L0(DebuggerEventsTest, PausedToObjectTest) Local object1 = paused->ToObject(ecmaVm); Local result = object1->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsObject()); Local object = Local(result); tmpStr = StringRef::NewFromUtf8(ecmaVm, "reason"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("exception", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "callFrames"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsArray(ecmaVm)); } @@ -227,13 +227,13 @@ HWTEST_F_L0(DebuggerEventsTest, ResumedToObjectTest) tmpStr = StringRef::NewFromUtf8(ecmaVm, "method"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); Local result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(std::string(resumed->GetName().c_str()), Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "params"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsObject()); } @@ -550,104 +550,104 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseToObjectTest) Local object1 = parse->ToObject(ecmaVm); Local result = object1->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsObject()); Local object = Local(result); tmpStr = StringRef::NewFromUtf8(ecmaVm, "scriptId"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("00", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "url"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("use/test.js", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "startLine"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(Local(result)->Value(), 0); tmpStr = StringRef::NewFromUtf8(ecmaVm, "startColumn"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(Local(result)->Value(), 4); tmpStr = StringRef::NewFromUtf8(ecmaVm, "endLine"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(Local(result)->Value(), 10); tmpStr = StringRef::NewFromUtf8(ecmaVm, "endColumn"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(Local(result)->Value(), 10); tmpStr = StringRef::NewFromUtf8(ecmaVm, "executionContextId"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(Local(result)->Value(), 2); tmpStr = StringRef::NewFromUtf8(ecmaVm, "hash"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("hash0001", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "executionContextAuxData"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsObject()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "sourceMapURL"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("usr/", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "hasSourceURL"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsTrue()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "isModule"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsTrue()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "length"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(Local(result)->Value(), 34); tmpStr = StringRef::NewFromUtf8(ecmaVm, "codeOffset"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(Local(result)->Value(), 432); tmpStr = StringRef::NewFromUtf8(ecmaVm, "scriptLanguage"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("JavaScript", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "embedderName"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("hh", Local(result)->ToString()); } @@ -804,110 +804,110 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptParsedToObjectTest) Local object1 = parse->ToObject(ecmaVm); Local result = object1->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsObject()); Local object = Local(result); tmpStr = StringRef::NewFromUtf8(ecmaVm, "scriptId"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("00", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "url"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("use/test.js", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "startLine"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(Local(result)->Value(), 0); tmpStr = StringRef::NewFromUtf8(ecmaVm, "startColumn"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(Local(result)->Value(), 4); tmpStr = StringRef::NewFromUtf8(ecmaVm, "endLine"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(Local(result)->Value(), 10); tmpStr = StringRef::NewFromUtf8(ecmaVm, "endColumn"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(Local(result)->Value(), 10); tmpStr = StringRef::NewFromUtf8(ecmaVm, "executionContextId"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(Local(result)->Value(), 2); tmpStr = StringRef::NewFromUtf8(ecmaVm, "hash"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("hash0001", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "executionContextAuxData"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsObject()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "isLiveEdit"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsTrue()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "sourceMapURL"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("usr/", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "hasSourceURL"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsTrue()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "isModule"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsTrue()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "length"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(Local(result)->Value(), 34); tmpStr = StringRef::NewFromUtf8(ecmaVm, "codeOffset"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(Local(result)->Value(), 432); tmpStr = StringRef::NewFromUtf8(ecmaVm, "scriptLanguage"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("JavaScript", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "embedderName"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("hh", Local(result)->ToString()); } } // namespace panda::test \ No newline at end of file diff --git a/ecmascript/tooling/test/debugger_types_test.cpp b/ecmascript/tooling/test/debugger_types_test.cpp index 3a626ca6f6..9724096b6e 100644 --- a/ecmascript/tooling/test/debugger_types_test.cpp +++ b/ecmascript/tooling/test/debugger_types_test.cpp @@ -259,37 +259,37 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectToObjectTest) tmpStr = StringRef::NewFromUtf8(ecmaVm, "type"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); Local result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(std::string(ObjectType::Object.c_str()), Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(std::string(ObjectSubType::Array.c_str()), Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "className"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("TestClass", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "value"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(Local(result)->Value(), 100.0); tmpStr = StringRef::NewFromUtf8(ecmaVm, "unserializableValue"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("Test", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "description"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("Test", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "objectId"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("id_1", Local(result)->ToString()); } @@ -502,52 +502,52 @@ HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsToObjectTest) tmpStr = StringRef::NewFromUtf8(ecmaVm, "exceptionId"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); Local result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(Local(result)->Value(), 5); tmpStr = StringRef::NewFromUtf8(ecmaVm, "text"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("text0", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(Local(result)->Value(), 10); tmpStr = StringRef::NewFromUtf8(ecmaVm, "columnNumber"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(Local(result)->Value(), 20); tmpStr = StringRef::NewFromUtf8(ecmaVm, "scriptId"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("ScriptId0", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "url"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("url0", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "exception"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsObject()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "type"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); Local subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ(std::string(ObjectType::Object.c_str()), Local(subResult)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ(std::string(ObjectSubType::Error.c_str()), Local(subResult)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "executionContextId"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(Local(result)->Value(), 30); } @@ -656,22 +656,22 @@ HWTEST_F_L0(DebuggerTypesTest, InternalPropertyDescriptorToObjectTest) tmpStr = StringRef::NewFromUtf8(ecmaVm, "name"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); Local result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("name8", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "value"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsObject()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "type"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); Local subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ(std::string(ObjectType::Object.c_str()), Local(subResult)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ(std::string(ObjectSubType::Map.c_str()), Local(subResult)->ToString()); } @@ -924,92 +924,92 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorToObjectTest) tmpStr = StringRef::NewFromUtf8(ecmaVm, "name"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); Local result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("name8", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "value"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsObject()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "type"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); Local subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ(std::string(ObjectType::Object.c_str()), Local(subResult)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ(std::string(ObjectSubType::Map.c_str()), Local(subResult)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "writable"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsTrue()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "get"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsObject()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "type"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ(std::string(ObjectType::Object.c_str()), Local(subResult)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ(std::string(ObjectSubType::Regexp.c_str()), Local(subResult)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "set"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsObject()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "type"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ(std::string(ObjectType::Object.c_str()), Local(subResult)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ(std::string(ObjectSubType::Generator.c_str()), Local(subResult)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "configurable"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsTrue()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "enumerable"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsTrue()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "wasThrown"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsTrue()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "isOwn"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsTrue()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "symbol"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsObject()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "type"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ(std::string(ObjectType::Object.c_str()), Local(subResult)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ(std::string(ObjectSubType::Proxy.c_str()), Local(subResult)->ToString()); } @@ -1109,17 +1109,17 @@ HWTEST_F_L0(DebuggerTypesTest, LocationToObjectTest) tmpStr = StringRef::NewFromUtf8(ecmaVm, "scriptId"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); Local result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("id2", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + 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()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(Local(result)->Value(), 18); } @@ -1234,22 +1234,22 @@ HWTEST_F_L0(DebuggerTypesTest, BreakLocationToObjectTest) tmpStr = StringRef::NewFromUtf8(ecmaVm, "scriptId"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); Local result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("id12", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(Local(result)->Value(), 919); tmpStr = StringRef::NewFromUtf8(ecmaVm, "columnNumber"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ(Local(result)->Value(), 148); tmpStr = StringRef::NewFromUtf8(ecmaVm, "type"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("call", Local(result)->ToString()); } @@ -1386,57 +1386,57 @@ HWTEST_F_L0(DebuggerTypesTest, ScopeToObjectTest) tmpStr = StringRef::NewFromUtf8(ecmaVm, "type"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); Local result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("global", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "object"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsObject()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "type"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); Local subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ(std::string(ObjectType::Object.c_str()), Local(subResult)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ(std::string(ObjectSubType::Dataview.c_str()), Local(subResult)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "name"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("name9", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "startLocation"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsObject()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "scriptId"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ("id2", Local(subResult)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ(Local(subResult)->Value(), 99); tmpStr = StringRef::NewFromUtf8(ecmaVm, "endLocation"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsObject()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "scriptId"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ("id13", Local(subResult)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ(Local(subResult)->Value(), 146); } @@ -1700,84 +1700,84 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameToObjectTest) tmpStr = StringRef::NewFromUtf8(ecmaVm, "callFrameId"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); Local result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("id0", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "functionName"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("name0", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "functionLocation"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsObject()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "scriptId"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); Local subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ("id3", Local(subResult)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ(Local(subResult)->Value(), 16); tmpStr = StringRef::NewFromUtf8(ecmaVm, "location"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsObject()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "scriptId"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ("id5", Local(subResult)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ(Local(subResult)->Value(), 19); tmpStr = StringRef::NewFromUtf8(ecmaVm, "url"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); EXPECT_EQ("url7", Local(result)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "scopeChain"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsArray(ecmaVm)); EXPECT_EQ(Local(result)->Length(ecmaVm), 2); tmpStr = StringRef::NewFromUtf8(ecmaVm, "this"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsObject()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "type"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ(std::string(ObjectType::Object.c_str()), Local(subResult)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ(std::string(ObjectSubType::Iterator.c_str()), Local(subResult)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "returnValue"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!result.IsEmpty()); + ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsObject()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "type"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ(std::string(ObjectType::Object.c_str()), Local(subResult)->ToString()); tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); - ASSERT_TRUE(!subResult.IsEmpty()); + ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); EXPECT_EQ(std::string(ObjectSubType::I64.c_str()), Local(subResult)->ToString()); } } // namespace panda::test -- Gitee