Commit 5aa2de81 authored by Kim-Anh Tran's avatar Kim-Anh Tran Committed by V8 LUCI CQ

[debugger] Return ServerError if debugger agent is disabled

This returns a server error on setting breakpoints if the
agent is disabled.

Also-by: bmeurer@chromium.org
Fixed: chromium:1202534
Change-Id: I87c80a4bd785fa5c59a8dd0d5ac5f4b31b015ed8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2874662
Commit-Queue: Kim-Anh Tran <kimanh@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Auto-Submit: Kim-Anh Tran <kimanh@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74399}
parent 0cddd59b
...@@ -510,6 +510,8 @@ Response V8DebuggerAgentImpl::setBreakpointByUrl( ...@@ -510,6 +510,8 @@ Response V8DebuggerAgentImpl::setBreakpointByUrl(
Maybe<int> optionalColumnNumber, Maybe<String16> optionalCondition, Maybe<int> optionalColumnNumber, Maybe<String16> optionalCondition,
String16* outBreakpointId, String16* outBreakpointId,
std::unique_ptr<protocol::Array<protocol::Debugger::Location>>* locations) { std::unique_ptr<protocol::Array<protocol::Debugger::Location>>* locations) {
if (!enabled()) return Response::ServerError(kDebuggerNotEnabled);
*locations = std::make_unique<Array<protocol::Debugger::Location>>(); *locations = std::make_unique<Array<protocol::Debugger::Location>>();
int specified = (optionalURL.isJust() ? 1 : 0) + int specified = (optionalURL.isJust() ? 1 : 0) +
...@@ -598,6 +600,8 @@ Response V8DebuggerAgentImpl::setBreakpoint( ...@@ -598,6 +600,8 @@ Response V8DebuggerAgentImpl::setBreakpoint(
String16 breakpointId = generateBreakpointId( String16 breakpointId = generateBreakpointId(
BreakpointType::kByScriptId, location->getScriptId(), BreakpointType::kByScriptId, location->getScriptId(),
location->getLineNumber(), location->getColumnNumber(0)); location->getLineNumber(), location->getColumnNumber(0));
if (!enabled()) return Response::ServerError(kDebuggerNotEnabled);
if (m_breakpointIdToDebuggerBreakpointIds.find(breakpointId) != if (m_breakpointIdToDebuggerBreakpointIds.find(breakpointId) !=
m_breakpointIdToDebuggerBreakpointIds.end()) { m_breakpointIdToDebuggerBreakpointIds.end()) {
return Response::ServerError( return Response::ServerError(
...@@ -616,6 +620,8 @@ Response V8DebuggerAgentImpl::setBreakpoint( ...@@ -616,6 +620,8 @@ Response V8DebuggerAgentImpl::setBreakpoint(
Response V8DebuggerAgentImpl::setBreakpointOnFunctionCall( Response V8DebuggerAgentImpl::setBreakpointOnFunctionCall(
const String16& functionObjectId, Maybe<String16> optionalCondition, const String16& functionObjectId, Maybe<String16> optionalCondition,
String16* outBreakpointId) { String16* outBreakpointId) {
if (!enabled()) return Response::ServerError(kDebuggerNotEnabled);
InjectedScript::ObjectScope scope(m_session, functionObjectId); InjectedScript::ObjectScope scope(m_session, functionObjectId);
Response response = scope.initialize(); Response response = scope.initialize();
if (!response.IsSuccess()) return response; if (!response.IsSuccess()) return response;
......
Tests that setting breakpoint before enabling debugger produces an error Tests that setting breakpoint before enabling debugger produces an error
setBreakpointByUrl error: undefined setBreakpointByUrl error: {
"code": -32000,
"message": "Debugger agent is not enabled"
}
setBreakpoint error: { setBreakpoint error: {
"code": -32602, "code": -32000,
"message": "Invalid parameters", "message": "Debugger agent is not enabled"
"data": "Failed to deserialize params.location - BINDINGS: mandatory field missing at <some position>" }
setBreakpointOnFunctionCall error: {
"code": -32000,
"message": "Debugger agent is not enabled"
} }
...@@ -10,12 +10,19 @@ function didSetBreakpointByUrlBeforeEnable(message) ...@@ -10,12 +10,19 @@ function didSetBreakpointByUrlBeforeEnable(message)
{ {
InspectorTest.log("setBreakpointByUrl error: " + JSON.stringify( InspectorTest.log("setBreakpointByUrl error: " + JSON.stringify(
InspectorTest.trimErrorMessage(message).error, null, 2)); InspectorTest.trimErrorMessage(message).error, null, 2));
Protocol.Debugger.setBreakpoint().then(didSetBreakpointBeforeEnable); Protocol.Debugger.setBreakpoint({location: { scriptId: "4", lineNumber: 0, columnNumber: 0 }}).then(didSetBreakpointBeforeEnable);
} }
function didSetBreakpointBeforeEnable(message) function didSetBreakpointBeforeEnable(message)
{ {
InspectorTest.log("setBreakpoint error: " + JSON.stringify( InspectorTest.log("setBreakpoint error: " + JSON.stringify(
InspectorTest.trimErrorMessage(message).error, null, 2)); InspectorTest.trimErrorMessage(message).error, null, 2));
Protocol.Debugger.setBreakpointOnFunctionCall({objectId: "4"}).then(didSetBreakpointOnFunctionCallBeforeEnable);
}
function didSetBreakpointOnFunctionCallBeforeEnable(message)
{
InspectorTest.log("setBreakpointOnFunctionCall error: " + JSON.stringify(
InspectorTest.trimErrorMessage(message).error, null, 2));
InspectorTest.completeTest(); InspectorTest.completeTest();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment