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

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: Removed _callFrameForId 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 ad9f59c86d7b6b75f52fff686c652808f48108b3..e9785ae3f07036442c0dabb6f282c7383df49b10 100644
--- a/third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.cpp
+++ b/third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.cpp
@@ -88,13 +88,44 @@ 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;
}
+
+ v8::MaybeLocal<v8::Object> commandLineAPI = includeCommandLineAPI.fromMaybe(false) ? injectedScript->commandLineAPI(errorString) : v8::MaybeLocal<v8::Object>();
+ if (includeCommandLineAPI.fromMaybe(false) && commandLineAPI.IsEmpty())
+ return;
+
+ InjectedScriptManager::ScopedGlobalObjectExtension scopeExtension(injectedScript, nullptr, commandLineAPI);
+
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::MaybeLocal<v8::Value> maybeResultValue = m_debugger->compileAndRunInternalScript(localContext, toV8String(injectedScript->isolate(), expression));
+
+ // InjectedScript may be gone after any evaluate call - find it again.
+ injectedScript = m_injectedScriptManager->findInjectedScript(errorString, executionContextId.fromJust());
+ if (!injectedScript)
+ return;
+
+ injectedScript->wrapEvaluateResult(errorString,
+ maybeResultValue,
+ tryCatch,
+ objectGroup.fromMaybe(""),
+ returnByValue.fromMaybe(false),
+ generatePreview.fromMaybe(false),
+ result,
+ wasThrown,
+ exceptionDetails);
}
void V8RuntimeAgentImpl::callFunctionOn(ErrorString* errorString,
@@ -196,11 +227,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);
@@ -238,11 +267,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);
@@ -262,7 +289,6 @@ void V8RuntimeAgentImpl::runScript(ErrorString* errorString,
*errorString = "Script execution failed";
return;
}
- v8::TryCatch tryCatch(isolate);
v8::MaybeLocal<v8::Object> commandLineAPI = includeCommandLineAPI.fromMaybe(false) ? injectedScript->commandLineAPI(errorString) : v8::MaybeLocal<v8::Object>();
if (includeCommandLineAPI.fromMaybe(false) && commandLineAPI.IsEmpty())
@@ -270,30 +296,15 @@ void V8RuntimeAgentImpl::runScript(ErrorString* errorString,
InjectedScriptManager::ScopedGlobalObjectExtension scopeExtension(injectedScript, nullptr, commandLineAPI);
- v8::Local<v8::Value> value;
- 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 = injectedScript->createExceptionDetails(message);
- } else {
- value = maybeValue.ToLocalChecked();
- }
-
- if (value.IsEmpty()) {
- *errorString = "Script execution failed";
- return;
- }
+ v8::TryCatch tryCatch(isolate);
+ v8::MaybeLocal<v8::Value> maybeResultValue = m_debugger->runCompiledScript(context, script);
// InjectedScript may be gone after any evaluate call - find it again.
- injectedScript = m_injectedScriptManager->findInjectedScript(executionContextId);
- if (!injectedScript) {
- *errorString = "Inspected frame has gone during script running";
+ injectedScript = m_injectedScriptManager->findInjectedScript(errorString, executionContextId);
+ if (!injectedScript)
return;
- }
- *result = injectedScript->wrapObject(errorString, value, objectGroup.fromMaybe(""));
+ injectedScript->wrapEvaluateResult(errorString, maybeResultValue, tryCatch, objectGroup.fromMaybe(""), false, false, result, nullptr, exceptionDetails);
}
void V8RuntimeAgentImpl::setInspectorState(protocol::DictionaryValue* state)

Powered by Google App Engine
This is Rietveld 408576698