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

Unified Diff: third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.cpp

Issue 1812983002: [DevTools] Move evaluate from InjectedScriptSource.js to native (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-evaluate-on-call-frame
Patch Set: Created 4 years, 9 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: third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.cpp
diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.cpp b/third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.cpp
index 92a07f912413dad829ec972e521368ee97c80f92..e4dd2f1d41d26b1681c42e7224cf40b161d23aee 100644
--- a/third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.cpp
+++ b/third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.cpp
@@ -108,13 +108,46 @@ void V8RuntimeAgentImpl::evaluate(
*errorString = "Cannot find default execution context";
return;
}
- InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript(executionContextId.fromJust());
- if (!injectedScript) {
- *errorString = "Cannot find execution context with given id";
+ InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript(errorString, executionContextId.fromJust());
+ if (!injectedScript)
+ return;
+
+ v8::HandleScope scope(injectedScript->isolate());
+ v8::Local<v8::Context> localContext = injectedScript->context();
+ v8::Context::Scope contextScope(localContext);
+
+ if (!injectedScript->canAccessInspectedWindow()) {
+ *errorString = "Can not access given context";
+ return;
+ }
+ InjectedScriptManager::InjectScopeExtensionByName scopeExtension(errorString, injectedScript, false, includeCommandLineAPI.fromMaybe(false) ? "commandLineAPI" : String16());
+ if (scopeExtension.hasError()) {
+ *errorString = "Internal error";
return;
}
IgnoreExceptionsScope ignoreExceptionsScope(doNotPauseOnExceptionsAndMuteConsole.fromMaybe(false) ? m_debugger : nullptr);
- injectedScript->evaluate(errorString, expression, objectGroup.fromMaybe(""), includeCommandLineAPI.fromMaybe(false), returnByValue.fromMaybe(false), generatePreview.fromMaybe(false), result, wasThrown, exceptionDetails);
+
+ v8::TryCatch tryCatch(injectedScript->isolate());
+
+ v8::Local<v8::Value> resultValue;
+ bool success = m_debugger->compileAndRunInternalScript(localContext, toV8String(injectedScript->isolate(), expression)).ToLocal(&resultValue);
+ ALLOW_UNUSED_LOCAL(success);
+
+ injectedScript = m_injectedScriptManager->findInjectedScript(errorString, executionContextId.fromJust());
pfeldman 2016/03/17 21:24:22 Is there a chance m_injectedScriptManager no longe
kozy 2016/03/17 21:27:58 We keep OwnPtr to manager in this agent.
+ if (!injectedScript)
+ return;
+
+ V8RuntimeAgentImpl::wrapEvaluateResult(errorString,
+ m_debugger,
+ injectedScript,
+ resultValue,
+ tryCatch,
+ objectGroup.fromMaybe(""),
+ returnByValue.fromMaybe(false),
+ generatePreview.fromMaybe(false),
+ result,
+ wasThrown,
+ exceptionDetails);
}
void V8RuntimeAgentImpl::callFunctionOn(ErrorString* errorString,
@@ -216,11 +249,9 @@ void V8RuntimeAgentImpl::compileScript(ErrorString* errorString,
*errorString = "Runtime agent is not enabled";
return;
}
- InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript(executionContextId);
- if (!injectedScript) {
- *errorString = "Inspected frame has gone";
+ InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript(errorString, executionContextId);
+ if (!injectedScript)
return;
- }
v8::Isolate* isolate = injectedScript->isolate();
v8::HandleScope handles(isolate);
@@ -258,11 +289,9 @@ void V8RuntimeAgentImpl::runScript(ErrorString* errorString,
*errorString = "Runtime agent is not enabled";
return;
}
- InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript(executionContextId);
- if (!injectedScript) {
- *errorString = "Inspected frame has gone";
+ InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript(errorString, executionContextId);
+ if (!injectedScript)
return;
- }
IgnoreExceptionsScope ignoreExceptionsScope(doNotPauseOnExceptionsAndMuteConsole.fromMaybe(false) ? m_debugger : nullptr);
@@ -284,37 +313,29 @@ void V8RuntimeAgentImpl::runScript(ErrorString* errorString,
}
v8::TryCatch tryCatch(isolate);
- v8::Local<v8::Value> value;
-
InjectedScriptManager::InjectScopeExtensionByName scopeExtension(errorString, injectedScript, false, "commandLineAPI");
if (scopeExtension.hasError())
return;
- v8::MaybeLocal<v8::Value> maybeValue = m_debugger->runCompiledScript(context, script);
- if (maybeValue.IsEmpty()) {
- value = tryCatch.Exception();
- v8::Local<v8::Message> message = tryCatch.Message();
- if (!message.IsEmpty())
- *exceptionDetails = createExceptionDetails(m_debugger, injectedScript->context(), message);
- } else {
- value = maybeValue.ToLocalChecked();
- }
+ v8::Local<v8::Value> resultValue;
+ bool success = m_debugger->runCompiledScript(context, script).ToLocal(&resultValue);
+ ALLOW_UNUSED_LOCAL(success);
- if (value.IsEmpty()) {
- *errorString = "Script execution failed";
- return;
- }
-
- injectedScript = m_injectedScriptManager->findInjectedScript(executionContextId);
- if (!injectedScript) {
- *errorString = "Inspected frame has gone during script running";
+ injectedScript = m_injectedScriptManager->findInjectedScript(errorString, executionContextId);
+ if (!injectedScript)
return;
- }
- OwnPtr<RemoteObject> resultObject = injectedScript->wrapObject(errorString, value, objectGroup.fromMaybe(""));
- if (!resultObject)
- return;
- *result = resultObject.release();
+ V8RuntimeAgentImpl::wrapEvaluateResult(errorString,
+ m_debugger,
+ injectedScript,
+ resultValue,
+ tryCatch,
+ objectGroup.fromMaybe(""),
+ false,
+ false,
+ result,
+ nullptr,
+ exceptionDetails);
}
void V8RuntimeAgentImpl::setInspectorState(protocol::DictionaryValue* state)
@@ -466,20 +487,22 @@ void V8RuntimeAgentImpl::wrapEvaluateResult(ErrorString* errorString, V8Debugger
if (objectGroup == "console" && !injectedScript->setLastEvaluationResult(errorString, resultValue))
return;
*result = remoteObject.release();
- *wasThrown = false;
+ if (wasThrown)
+ *wasThrown = false;
} else {
v8::Local<v8::Value> exception = tryCatch.Exception();
OwnPtr<RemoteObject> remoteObject = injectedScript->wrapObject(errorString, exception, objectGroup, false, generatePreview && !exception->IsNativeError());
if (!remoteObject)
return;
- *result = remoteObject.release();
OwnPtr<ExceptionDetails> exceptionDetailsObject = createExceptionDetails(debugger, injectedScript->context(), tryCatch.Message());
if (!exceptionDetailsObject) {
*errorString = "Internal error";
return;
}
+ *result = remoteObject.release();
*exceptionDetails = exceptionDetailsObject.release();
- *wasThrown = true;
+ if (wasThrown)
+ *wasThrown = true;
}
}

Powered by Google App Engine
This is Rietveld 408576698