Index: third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp |
diff --git a/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp b/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp |
index ea1c691e2fe090c600725aa937a2641ff18b0c64..6880c65fe26d6d3a23ad9e5aacc197882495471c 100644 |
--- a/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp |
+++ b/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp |
@@ -35,6 +35,7 @@ |
#include "platform/v8_inspector/InjectedScriptHost.h" |
#include "platform/v8_inspector/InjectedScriptManager.h" |
#include "platform/v8_inspector/RemoteObjectId.h" |
+#include "platform/v8_inspector/V8DebuggerImpl.h" |
#include "platform/v8_inspector/V8FunctionCall.h" |
#include "platform/v8_inspector/V8StringUtil.h" |
#include "platform/v8_inspector/public/V8Debugger.h" |
@@ -115,12 +116,11 @@ static void weakCallback(const v8::WeakCallbackInfo<InjectedScript>& data) |
data.GetParameter()->dispose(); |
} |
-InjectedScript::InjectedScript(InjectedScriptManager* manager, v8::Local<v8::Context> context, v8::Local<v8::Object> object, V8DebuggerClient* client, PassOwnPtr<InjectedScriptNative> injectedScriptNative, int contextId) |
+InjectedScript::InjectedScript(InjectedScriptManager* manager, v8::Local<v8::Context> context, v8::Local<v8::Object> object, PassOwnPtr<InjectedScriptNative> injectedScriptNative, int contextId) |
: m_manager(manager) |
, m_isolate(context->GetIsolate()) |
, m_context(m_isolate, context) |
, m_value(m_isolate, object) |
- , m_client(client) |
, m_native(injectedScriptNative) |
, m_contextId(contextId) |
{ |
@@ -134,7 +134,7 @@ InjectedScript::~InjectedScript() |
void InjectedScript::evaluate(ErrorString* errorString, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe<bool>* wasThrown, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) |
{ |
v8::HandleScope handles(m_isolate); |
- V8FunctionCall function(m_client, context(), v8Value(), "evaluate"); |
+ V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "evaluate"); |
function.appendArgument(expression); |
function.appendArgument(objectGroup); |
function.appendArgument(includeCommandLineAPI); |
@@ -146,7 +146,7 @@ void InjectedScript::evaluate(ErrorString* errorString, const String& expression |
void InjectedScript::callFunctionOn(ErrorString* errorString, const String& objectId, const String& expression, const String& arguments, bool returnByValue, bool generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe<bool>* wasThrown) |
{ |
v8::HandleScope handles(m_isolate); |
- V8FunctionCall function(m_client, context(), v8Value(), "callFunctionOn"); |
+ V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "callFunctionOn"); |
function.appendArgument(objectId); |
function.appendArgument(expression); |
function.appendArgument(arguments); |
@@ -158,7 +158,7 @@ void InjectedScript::callFunctionOn(ErrorString* errorString, const String& obje |
void InjectedScript::evaluateOnCallFrame(ErrorString* errorString, v8::Local<v8::Object> callFrames, const String& callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, OwnPtr<RemoteObject>* result, Maybe<bool>* wasThrown, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) |
{ |
v8::HandleScope handles(m_isolate); |
- V8FunctionCall function(m_client, context(), v8Value(), "evaluateOnCallFrame"); |
+ V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "evaluateOnCallFrame"); |
function.appendArgument(callFrames); |
function.appendArgument(callFrameId); |
function.appendArgument(expression); |
@@ -172,7 +172,7 @@ void InjectedScript::evaluateOnCallFrame(ErrorString* errorString, v8::Local<v8: |
void InjectedScript::restartFrame(ErrorString* errorString, v8::Local<v8::Object> callFrames, const String& callFrameId) |
{ |
v8::HandleScope handles(m_isolate); |
- V8FunctionCall function(m_client, context(), v8Value(), "restartFrame"); |
+ V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "restartFrame"); |
function.appendArgument(callFrames); |
function.appendArgument(callFrameId); |
OwnPtr<protocol::Value> resultValue = makeCall(function); |
@@ -191,7 +191,7 @@ void InjectedScript::restartFrame(ErrorString* errorString, v8::Local<v8::Object |
void InjectedScript::getStepInPositions(ErrorString* errorString, v8::Local<v8::Object> callFrames, const String& callFrameId, Maybe<Array<protocol::Debugger::Location>>* positions) |
{ |
v8::HandleScope handles(m_isolate); |
- V8FunctionCall function(m_client, context(), v8Value(), "getStepInPositions"); |
+ V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getStepInPositions"); |
function.appendArgument(callFrames); |
function.appendArgument(callFrameId); |
OwnPtr<protocol::Value> resultValue = makeCall(function); |
@@ -218,7 +218,7 @@ void InjectedScript::setVariableValue(ErrorString* errorString, |
const String& newValueStr) |
{ |
v8::HandleScope handles(m_isolate); |
- V8FunctionCall function(m_client, context(), v8Value(), "setVariableValue"); |
+ V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "setVariableValue"); |
if (callFrameIdOpt.isJust()) { |
function.appendArgument(callFrames); |
function.appendArgument(callFrameIdOpt.fromJust()); |
@@ -248,7 +248,7 @@ void InjectedScript::setVariableValue(ErrorString* errorString, |
void InjectedScript::getFunctionDetails(ErrorString* errorString, const String& functionId, OwnPtr<FunctionDetails>* result) |
{ |
v8::HandleScope handles(m_isolate); |
- V8FunctionCall function(m_client, context(), v8Value(), "getFunctionDetails"); |
+ V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getFunctionDetails"); |
function.appendArgument(functionId); |
OwnPtr<protocol::Value> resultValue = makeCall(function); |
protocol::ErrorSupport errors(errorString); |
@@ -258,7 +258,7 @@ void InjectedScript::getFunctionDetails(ErrorString* errorString, const String& |
void InjectedScript::getGeneratorObjectDetails(ErrorString* errorString, const String& objectId, OwnPtr<GeneratorObjectDetails>* result) |
{ |
v8::HandleScope handles(m_isolate); |
- V8FunctionCall function(m_client, context(), v8Value(), "getGeneratorObjectDetails"); |
+ V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getGeneratorObjectDetails"); |
function.appendArgument(objectId); |
OwnPtr<protocol::Value> resultValue = makeCall(function); |
protocol::ErrorSupport errors(errorString); |
@@ -268,7 +268,7 @@ void InjectedScript::getGeneratorObjectDetails(ErrorString* errorString, const S |
void InjectedScript::getCollectionEntries(ErrorString* errorString, const String& objectId, OwnPtr<Array<CollectionEntry>>* result) |
{ |
v8::HandleScope handles(m_isolate); |
- V8FunctionCall function(m_client, context(), v8Value(), "getCollectionEntries"); |
+ V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getCollectionEntries"); |
function.appendArgument(objectId); |
OwnPtr<protocol::Value> resultValue = makeCall(function); |
protocol::ErrorSupport errors(errorString); |
@@ -278,7 +278,7 @@ void InjectedScript::getCollectionEntries(ErrorString* errorString, const String |
void InjectedScript::getProperties(ErrorString* errorString, const String& objectId, bool ownProperties, bool accessorPropertiesOnly, bool generatePreview, OwnPtr<Array<PropertyDescriptor>>* properties, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) |
{ |
v8::HandleScope handles(m_isolate); |
- V8FunctionCall function(m_client, context(), v8Value(), "getProperties"); |
+ V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getProperties"); |
function.appendArgument(objectId); |
function.appendArgument(ownProperties); |
function.appendArgument(accessorPropertiesOnly); |
@@ -297,7 +297,7 @@ void InjectedScript::getProperties(ErrorString* errorString, const String& objec |
void InjectedScript::getInternalProperties(ErrorString* errorString, const String& objectId, Maybe<Array<InternalPropertyDescriptor>>* properties, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) |
{ |
v8::HandleScope handles(m_isolate); |
- V8FunctionCall function(m_client, context(), v8Value(), "getInternalProperties"); |
+ V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getInternalProperties"); |
function.appendArgument(objectId); |
OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exceptionDetails); |
@@ -325,17 +325,24 @@ void InjectedScript::releaseObject(const String& objectId) |
v8::MaybeLocal<v8::Value> InjectedScript::runCompiledScript(v8::Local<v8::Script> script, bool includeCommandLineAPI) |
{ |
+ // TODO(dgozman): get rid of this check. |
+ if (!m_manager->debugger()->client()->isExecutionAllowed()) |
+ return v8::MaybeLocal<v8::Value>(); |
+ |
v8::Local<v8::Symbol> commandLineAPISymbolValue = V8Debugger::commandLineAPISymbol(m_isolate); |
v8::Local<v8::Object> global = context()->Global(); |
if (includeCommandLineAPI) { |
- V8FunctionCall function(m_client, context(), v8Value(), "commandLineAPI"); |
+ V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "commandLineAPI"); |
bool hadException = false; |
v8::Local<v8::Value> commandLineAPI = function.call(hadException, false); |
if (!hadException) |
global->Set(commandLineAPISymbolValue, commandLineAPI); |
} |
- v8::MaybeLocal<v8::Value> maybeValue = m_client->runCompiledScript(context(), script); |
+ v8::MicrotasksScope microtasksScope(m_isolate, v8::MicrotasksScope::kRunMicrotasks); |
+ int cookie = m_manager->debugger()->willExecuteScript(context(), script->GetUnboundScript()->GetId()); |
pfeldman
2016/03/08 01:44:20
m_debugger->runCompiledScript?
dgozman
2016/03/08 02:23:00
Done.
|
+ v8::MaybeLocal<v8::Value> maybeValue = script->Run(context()); |
+ m_manager->debugger()->didExecuteScript(cookie); |
if (includeCommandLineAPI) |
global->Delete(context(), commandLineAPISymbolValue); |
@@ -345,7 +352,7 @@ v8::MaybeLocal<v8::Value> InjectedScript::runCompiledScript(v8::Local<v8::Script |
PassOwnPtr<Array<CallFrame>> InjectedScript::wrapCallFrames(v8::Local<v8::Object> callFrames) |
{ |
v8::HandleScope handles(m_isolate); |
- V8FunctionCall function(m_client, context(), v8Value(), "wrapCallFrames"); |
+ V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapCallFrames"); |
function.appendArgument(callFrames); |
bool hadException = false; |
v8::Local<v8::Value> callFramesValue = callFunctionWithEvalEnabled(function, hadException); |
@@ -360,7 +367,7 @@ PassOwnPtr<Array<CallFrame>> InjectedScript::wrapCallFrames(v8::Local<v8::Object |
PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(v8::Local<v8::Value> value, const String& groupName, bool generatePreview) const |
{ |
v8::HandleScope handles(m_isolate); |
- V8FunctionCall function(m_client, context(), v8Value(), "wrapObject"); |
+ V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapObject"); |
function.appendArgument(value); |
function.appendArgument(groupName); |
function.appendArgument(canAccessInspectedWindow()); |
@@ -376,7 +383,7 @@ PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(v8::Local |
PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(v8::Local<v8::Value> table, v8::Local<v8::Value> columns) const |
{ |
v8::HandleScope handles(m_isolate); |
- V8FunctionCall function(m_client, context(), v8Value(), "wrapTable"); |
+ V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapTable"); |
function.appendArgument(canAccessInspectedWindow()); |
function.appendArgument(table); |
if (columns.IsEmpty()) |
@@ -406,7 +413,7 @@ void InjectedScript::releaseObjectGroup(const String& objectGroup) |
v8::HandleScope handles(m_isolate); |
m_native->releaseObjectGroup(objectGroup); |
if (objectGroup == "console") { |
- V8FunctionCall function(m_client, context(), v8Value(), "clearLastEvaluationResult"); |
+ V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "clearLastEvaluationResult"); |
bool hadException = false; |
callFunctionWithEvalEnabled(function, hadException); |
ASSERT(!hadException); |
@@ -416,7 +423,7 @@ void InjectedScript::releaseObjectGroup(const String& objectGroup) |
void InjectedScript::setCustomObjectFormatterEnabled(bool enabled) |
{ |
v8::HandleScope handles(m_isolate); |
- V8FunctionCall function(m_client, context(), v8Value(), "setCustomObjectFormatterEnabled"); |
+ V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "setCustomObjectFormatterEnabled"); |
function.appendArgument(enabled); |
makeCall(function); |
} |
@@ -426,7 +433,7 @@ bool InjectedScript::canAccessInspectedWindow() const |
v8::Local<v8::Context> callingContext = m_isolate->GetCallingContext(); |
if (callingContext.IsEmpty()) |
return true; |
- return m_client->callingContextCanAccessContext(callingContext, context()); |
+ return m_manager->debugger()->client()->callingContextCanAccessContext(callingContext, context()); |
} |
v8::Local<v8::Context> InjectedScript::context() const |