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

Unified Diff: Source/bindings/core/v8/ScriptDebugServer.cpp

Issue 1129473003: DevTools: respond with error when Debugger command is sent to disabled debugger agent (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed comments, added checks in DOMDebugger Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: Source/bindings/core/v8/ScriptDebugServer.cpp
diff --git a/Source/bindings/core/v8/ScriptDebugServer.cpp b/Source/bindings/core/v8/ScriptDebugServer.cpp
index 93b4f2a4c7f1b1fff4ca760306fd3d0f6b8430b6..709d29dfc7917f04619b1bc307c32a927db8168b 100644
--- a/Source/bindings/core/v8/ScriptDebugServer.cpp
+++ b/Source/bindings/core/v8/ScriptDebugServer.cpp
@@ -106,7 +106,7 @@ void ScriptDebugServer::enable()
ASSERT(!enabled());
v8::HandleScope scope(m_isolate);
v8::Debug::SetDebugEventListener(&ScriptDebugServer::v8DebugEventCallback, v8::External::New(m_isolate, this));
- ensureDebuggerScriptCompiled();
+ compileDebuggerScript();
}
void ScriptDebugServer::disable()
@@ -196,7 +196,10 @@ void ScriptDebugServer::clearBreakpoints()
void ScriptDebugServer::setBreakpointsActivated(bool activated)
{
- ensureDebuggerScriptCompiled();
+ if (!enabled()) {
+ ASSERT_NOT_REACHED();
+ return;
+ }
v8::HandleScope scope(m_isolate);
v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext();
v8::Context::Scope contextScope(debuggerContext);
@@ -211,7 +214,7 @@ void ScriptDebugServer::setBreakpointsActivated(bool activated)
ScriptDebugServer::PauseOnExceptionsState ScriptDebugServer::pauseOnExceptionsState()
{
- ensureDebuggerScriptCompiled();
+ ASSERT(enabled());
v8::HandleScope scope(m_isolate);
v8::Context::Scope contextScope(v8::Debug::GetDebugContext());
@@ -222,7 +225,7 @@ ScriptDebugServer::PauseOnExceptionsState ScriptDebugServer::pauseOnExceptionsSt
void ScriptDebugServer::setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExceptionsState)
{
- ensureDebuggerScriptCompiled();
+ ASSERT(enabled());
v8::HandleScope scope(m_isolate);
v8::Context::Scope contextScope(v8::Debug::GetDebugContext());
@@ -315,7 +318,7 @@ void ScriptDebugServer::stepOutOfFunction()
void ScriptDebugServer::clearStepping()
{
- ensureDebuggerScriptCompiled();
+ ASSERT(enabled());
v8::HandleScope scope(m_isolate);
v8::Context::Scope contextScope(v8::Debug::GetDebugContext());
@@ -333,7 +336,7 @@ bool ScriptDebugServer::setScriptSource(const String& sourceID, const String& ne
v8::Isolate* m_isolate;
};
- ensureDebuggerScriptCompiled();
+ ASSERT(enabled());
v8::HandleScope scope(m_isolate);
OwnPtr<v8::Context::Scope> contextScope;
@@ -677,10 +680,12 @@ void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8
listener->didParseSource(sourceID, script, compileResult);
}
-void ScriptDebugServer::ensureDebuggerScriptCompiled()
+void ScriptDebugServer::compileDebuggerScript()
{
- if (!m_debuggerScript.IsEmpty())
+ if (!m_debuggerScript.IsEmpty()) {
+ ASSERT_NOT_REACHED();
return;
+ }
v8::HandleScope scope(m_isolate);
v8::Context::Scope contextScope(v8::Debug::GetDebugContext());
@@ -705,41 +710,50 @@ v8::Local<v8::String> ScriptDebugServer::v8InternalizedString(const char* str) c
v8::Local<v8::Value> ScriptDebugServer::functionScopes(v8::Local<v8::Function> function)
{
- ensureDebuggerScriptCompiled();
-
+ if (!enabled()) {
+ ASSERT_NOT_REACHED();
+ return v8::Local<v8::Value>::New(m_isolate, v8::Undefined(m_isolate));
+ }
v8::Local<v8::Value> argv[] = { function };
return callDebuggerMethod("getFunctionScopes", 1, argv).ToLocalChecked();
}
v8::Local<v8::Value> ScriptDebugServer::generatorObjectDetails(v8::Local<v8::Object>& object)
{
- ensureDebuggerScriptCompiled();
-
+ if (!enabled()) {
+ ASSERT_NOT_REACHED();
+ return v8::Local<v8::Value>::New(m_isolate, v8::Undefined(m_isolate));
+ }
v8::Local<v8::Value> argv[] = { object };
return callDebuggerMethod("getGeneratorObjectDetails", 1, argv).ToLocalChecked();
}
v8::Local<v8::Value> ScriptDebugServer::collectionEntries(v8::Local<v8::Object>& object)
{
- ensureDebuggerScriptCompiled();
-
+ if (!enabled()) {
+ ASSERT_NOT_REACHED();
+ return v8::Local<v8::Value>::New(m_isolate, v8::Undefined(m_isolate));
+ }
v8::Local<v8::Value> argv[] = { object };
return callDebuggerMethod("getCollectionEntries", 1, argv).ToLocalChecked();
}
v8::Local<v8::Value> ScriptDebugServer::getInternalProperties(v8::Local<v8::Object>& object)
{
- if (m_debuggerScript.IsEmpty())
+ if (!enabled()) {
+ ASSERT_NOT_REACHED();
return v8::Local<v8::Value>::New(m_isolate, v8::Undefined(m_isolate));
-
+ }
v8::Local<v8::Value> argv[] = { object };
return callDebuggerMethod("getInternalProperties", 1, argv).ToLocalChecked();
}
v8::MaybeLocal<v8::Value> ScriptDebugServer::setFunctionVariableValue(v8::Local<v8::Value> functionValue, int scopeNumber, const String& variableName, v8::Local<v8::Value> newValue)
{
- if (m_debuggerScript.IsEmpty())
+ if (m_debuggerScript.IsEmpty()) {
+ ASSERT_NOT_REACHED();
return m_isolate->ThrowException(v8::String::NewFromUtf8(m_isolate, "Debugging is not enabled.", v8::NewStringType::kNormal).ToLocalChecked());
+ }
v8::Local<v8::Value> argv[] = {
functionValue,

Powered by Google App Engine
This is Rietveld 408576698