Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Side by Side Diff: src/inspector/v8-debugger-agent-impl.cc

Issue 2669713002: [inspector] return meaningful error on Debug.setScriptSource for ES module (Closed)
Patch Set: added missing test Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/inspector/debugger/es6-module-set-script-source.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/inspector/v8-debugger-agent-impl.h" 5 #include "src/inspector/v8-debugger-agent-impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "src/debug/debug-interface.h" 9 #include "src/debug/debug-interface.h"
10 #include "src/inspector/injected-script.h" 10 #include "src/inspector/injected-script.h"
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 return Response::OK(); 518 return Response::OK();
519 } 519 }
520 520
521 Response V8DebuggerAgentImpl::setScriptSource( 521 Response V8DebuggerAgentImpl::setScriptSource(
522 const String16& scriptId, const String16& newContent, Maybe<bool> dryRun, 522 const String16& scriptId, const String16& newContent, Maybe<bool> dryRun,
523 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames, 523 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames,
524 Maybe<bool>* stackChanged, Maybe<StackTrace>* asyncStackTrace, 524 Maybe<bool>* stackChanged, Maybe<StackTrace>* asyncStackTrace,
525 Maybe<protocol::Runtime::ExceptionDetails>* optOutCompileError) { 525 Maybe<protocol::Runtime::ExceptionDetails>* optOutCompileError) {
526 if (!enabled()) return Response::Error(kDebuggerNotEnabled); 526 if (!enabled()) return Response::Error(kDebuggerNotEnabled);
527 527
528 ScriptsMap::iterator it = m_scripts.find(scriptId);
529 if (it == m_scripts.end()) {
530 return Response::Error("No script for id: " + scriptId);
dgozman 2017/02/03 20:57:25 No script with given id found
kozy 2017/02/03 21:32:55 Done.
531 }
532 if (it->second->isModule()) {
533 // TODO(kozyatinskiy): LiveEdit should support ES6 module
534 return Response::Error(
535 "Debugger.setScriptSource doesn't support editing ES module");
dgozman 2017/02/03 20:57:25 Editing module's script is not supported.
kozy 2017/02/03 21:32:55 Done.
536 }
537
528 v8::HandleScope handles(m_isolate); 538 v8::HandleScope handles(m_isolate);
529 v8::Local<v8::String> newSource = toV8String(m_isolate, newContent); 539 v8::Local<v8::String> newSource = toV8String(m_isolate, newContent);
530 bool compileError = false; 540 bool compileError = false;
531 Response response = m_debugger->setScriptSource( 541 Response response = m_debugger->setScriptSource(
532 scriptId, newSource, dryRun.fromMaybe(false), optOutCompileError, 542 scriptId, newSource, dryRun.fromMaybe(false), optOutCompileError,
533 &m_pausedCallFrames, stackChanged, &compileError); 543 &m_pausedCallFrames, stackChanged, &compileError);
534 if (!response.isSuccess() || compileError) return response; 544 if (!response.isSuccess() || compileError) return response;
535 545
536 ScriptsMap::iterator it = m_scripts.find(scriptId); 546 it->second->setSource(newSource);
537 if (it != m_scripts.end()) it->second->setSource(newSource);
538
539 std::unique_ptr<Array<CallFrame>> callFrames; 547 std::unique_ptr<Array<CallFrame>> callFrames;
540 response = currentCallFrames(&callFrames); 548 response = currentCallFrames(&callFrames);
541 if (!response.isSuccess()) return response; 549 if (!response.isSuccess()) return response;
542 *newCallFrames = std::move(callFrames); 550 *newCallFrames = std::move(callFrames);
543 *asyncStackTrace = currentAsyncStackTrace(); 551 *asyncStackTrace = currentAsyncStackTrace();
544 return Response::OK(); 552 return Response::OK();
545 } 553 }
546 554
547 Response V8DebuggerAgentImpl::restartFrame( 555 Response V8DebuggerAgentImpl::restartFrame(
548 const String16& callFrameId, 556 const String16& callFrameId,
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 void V8DebuggerAgentImpl::reset() { 1197 void V8DebuggerAgentImpl::reset() {
1190 if (!enabled()) return; 1198 if (!enabled()) return;
1191 m_scheduledDebuggerStep = NoStep; 1199 m_scheduledDebuggerStep = NoStep;
1192 m_blackboxedPositions.clear(); 1200 m_blackboxedPositions.clear();
1193 resetBlackboxedStateCache(); 1201 resetBlackboxedStateCache();
1194 m_scripts.clear(); 1202 m_scripts.clear();
1195 m_breakpointIdToDebuggerBreakpointIds.clear(); 1203 m_breakpointIdToDebuggerBreakpointIds.clear();
1196 } 1204 }
1197 1205
1198 } // namespace v8_inspector 1206 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « no previous file | test/inspector/debugger/es6-module-set-script-source.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698