diff --git a/include/js_protocol.pdl b/include/js_protocol.pdl index 18cf0c7638..09a7a53f2b 100644 --- a/include/js_protocol.pdl +++ b/include/js_protocol.pdl @@ -452,14 +452,22 @@ domain Debugger optional boolean dryRun returns # New stack trace in case editing has happened while VM was stopped. - optional array of CallFrame callFrames + deprecated optional array of CallFrame callFrames # Whether current call stack was modified after applying the changes. - optional boolean stackChanged + deprecated optional boolean stackChanged # Async stack trace, if any. - optional Runtime.StackTrace asyncStackTrace + deprecated optional Runtime.StackTrace asyncStackTrace # Async stack trace, if any. - experimental optional Runtime.StackTraceId asyncStackTraceId - # Exception details if any. + deprecated optional Runtime.StackTraceId asyncStackTraceId + # Whether the operation was successful or not. Only `Ok` denotes a + # successful live edit while the other enum variants denote why + # the live edit failed. + experimental enum status + Ok + CompileError + BlockedByActiveGenerator + BlockedByActiveFunction + # Exception details if any. Only present when `status` is `CompileError`. optional Runtime.ExceptionDetails exceptionDetails # Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc). diff --git a/src/inspector/v8-debugger-agent-impl.cc b/src/inspector/v8-debugger-agent-impl.cc index 2be2822eea..b7f11208f9 100644 --- a/src/inspector/v8-debugger-agent-impl.cc +++ b/src/inspector/v8-debugger-agent-impl.cc @@ -1002,12 +1002,29 @@ Response V8DebuggerAgentImpl::searchInContent( return Response::Success(); } +namespace { +const char* buildStatus(v8::debug::LiveEditResult::Status status) { + switch (status) { + case v8::debug::LiveEditResult::OK: + return protocol::Debugger::SetScriptSource::StatusEnum::Ok; + case v8::debug::LiveEditResult::COMPILE_ERROR: + return protocol::Debugger::SetScriptSource::StatusEnum::CompileError; + case v8::debug::LiveEditResult::BLOCKED_BY_ACTIVE_FUNCTION: + return protocol::Debugger::SetScriptSource::StatusEnum:: + BlockedByActiveFunction; + case v8::debug::LiveEditResult::BLOCKED_BY_RUNNING_GENERATOR: + return protocol::Debugger::SetScriptSource::StatusEnum:: + BlockedByActiveGenerator; + } +} +} // namespace + Response V8DebuggerAgentImpl::setScriptSource( const String16& scriptId, const String16& newContent, Maybe dryRun, Maybe>* newCallFrames, Maybe* stackChanged, Maybe* asyncStackTrace, - Maybe* asyncStackTraceId, + Maybe* asyncStackTraceId, String16* status, Maybe* optOutCompileError) { if (!enabled()) return Response::ServerError(kDebuggerNotEnabled); @@ -1026,7 +1043,8 @@ Response V8DebuggerAgentImpl::setScriptSource( v8::debug::LiveEditResult result; it->second->setSource(newContent, dryRun.fromMaybe(false), &result); - if (result.status != v8::debug::LiveEditResult::OK) { + *status = buildStatus(result.status); + if (result.status == v8::debug::LiveEditResult::COMPILE_ERROR) { *optOutCompileError = protocol::Runtime::ExceptionDetails::create() .setExceptionId(m_inspector->nextExceptionId()) @@ -1037,15 +1055,7 @@ Response V8DebuggerAgentImpl::setScriptSource( : 0) .build(); return Response::Success(); - } else { - *stackChanged = result.stack_changed; } - std::unique_ptr> callFrames; - Response response = currentCallFrames(&callFrames); - if (!response.IsSuccess()) return response; - *newCallFrames = std::move(callFrames); - *asyncStackTrace = currentAsyncStackTrace(); - *asyncStackTraceId = currentExternalStackTrace(); return Response::Success(); } diff --git a/src/inspector/v8-debugger-agent-impl.h b/src/inspector/v8-debugger-agent-impl.h index ac58e3f55c..50256740a0 100644 --- a/src/inspector/v8-debugger-agent-impl.h +++ b/src/inspector/v8-debugger-agent-impl.h @@ -88,6 +88,7 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend { Maybe* optOutStackChanged, Maybe* optOutAsyncStackTrace, Maybe* optOutAsyncStackTraceId, + String16* outStatus, Maybe* optOutCompileError) override; Response restartFrame( const String16& callFrameId, Maybe mode, diff --git a/test/inspector/debugger/es6-module-liveedit-expected.txt b/test/inspector/debugger/es6-module-liveedit-expected.txt index 8ce34728a4..c02087d1cf 100644 --- a/test/inspector/debugger/es6-module-liveedit-expected.txt +++ b/test/inspector/debugger/es6-module-liveedit-expected.txt @@ -6,9 +6,7 @@ console.log message from function before patching: } Debugger.setScriptSource result: { - callFrames : [ - ] - stackChanged : false + status : Ok } console.log message from function after patching: { diff --git a/test/inspector/debugger/set-breakpoint-after-liveedit-expected.txt b/test/inspector/debugger/set-breakpoint-after-liveedit-expected.txt index cd50a5358a..864e4bd5bf 100644 --- a/test/inspector/debugger/set-breakpoint-after-liveedit-expected.txt +++ b/test/inspector/debugger/set-breakpoint-after-liveedit-expected.txt @@ -1,9 +1,7 @@ Breakpoint in liveedited script Update script source { - callFrames : [ - ] - stackChanged : false + status : Ok } Set breakpoint { diff --git a/test/inspector/debugger/set-script-source-exception-expected.txt b/test/inspector/debugger/set-script-source-exception-expected.txt index d74d65471e..36dc66adfc 100644 --- a/test/inspector/debugger/set-script-source-exception-expected.txt +++ b/test/inspector/debugger/set-script-source-exception-expected.txt @@ -19,5 +19,6 @@ Running test: testSourceWithSyntaxError lineNumber : 1 text : Uncaught SyntaxError: Invalid or unexpected token } + status : CompileError } } diff --git a/test/inspector/debugger/set-script-source-expected.txt b/test/inspector/debugger/set-script-source-expected.txt index 61f47e93fe..d52fc4ee98 100644 --- a/test/inspector/debugger/set-script-source-expected.txt +++ b/test/inspector/debugger/set-script-source-expected.txt @@ -2,9 +2,7 @@ Tests Debugger.setScriptSource TestExpression(2,4) === 6 Update current script source 'a + b' -> 'a * b'.. { - callFrames : [ - ] - stackChanged : false + status : Ok } TestExpression(2,4) === 8 Update current script source 'a * b' -> 'a # b'.. @@ -15,5 +13,6 @@ Update current script source 'a * b' -> 'a # b'.. lineNumber : 1 text : Uncaught SyntaxError: Invalid or unexpected token } + status : CompileError } TestExpression(2,4) === 8 diff --git a/test/inspector/regress/regress-crbug-1195927-expected.txt b/test/inspector/regress/regress-crbug-1195927-expected.txt index b5c92408da..197cc07e0a 100644 --- a/test/inspector/regress/regress-crbug-1195927-expected.txt +++ b/test/inspector/regress/regress-crbug-1195927-expected.txt @@ -15,12 +15,7 @@ foo (foo.js:2:2) (anonymous) (:0:0) Debugger.setScriptSource result: { - exceptionDetails : { - columnNumber : 0 - exceptionId : - lineNumber : 0 - text : - } + status : BlockedByActiveFunction } foo(42) result: { diff --git a/test/inspector/regress/regress-crbug-1328453-expected.txt b/test/inspector/regress/regress-crbug-1328453-expected.txt index 5302745518..74a36834ce 100644 --- a/test/inspector/regress/regress-crbug-1328453-expected.txt +++ b/test/inspector/regress/regress-crbug-1328453-expected.txt @@ -2,8 +2,6 @@ Don't crash when live editing an unused inner function [crbug.com/1328453] { id : result : { - callFrames : [ - ] - stackChanged : false + status : Ok } }