Commit e8de841b authored by pfeldman's avatar pfeldman Committed by Commit bot

DevTools: remove ScriptState/Value from the InjectedScript APIs.

BUG=580337

Review URL: https://codereview.chromium.org/1636223002

Cr-Commit-Position: refs/heads/master@{#371825}
parent 2b7cf6ac
...@@ -40,10 +40,10 @@ ...@@ -40,10 +40,10 @@
namespace blink { namespace blink {
ScriptValue InjectedScriptManager::createInjectedScript(const String& scriptSource, ScriptState* inspectedScriptState, int id, InjectedScriptNative* injectedScriptNative) v8::Local<v8::Object> InjectedScriptManager::createInjectedScript(const String& scriptSource, v8::Local<v8::Context> context, int id, InjectedScriptNative* injectedScriptNative)
{ {
v8::Isolate* isolate = inspectedScriptState->isolate(); v8::Isolate* isolate = context->GetIsolate();
ScriptState::Scope scope(inspectedScriptState); v8::Context::Scope scope(context);
v8::Local<v8::FunctionTemplate> wrapperTemplate = m_injectedScriptHost->wrapperTemplate(isolate); v8::Local<v8::FunctionTemplate> wrapperTemplate = m_injectedScriptHost->wrapperTemplate(isolate);
if (wrapperTemplate.IsEmpty()) { if (wrapperTemplate.IsEmpty()) {
...@@ -51,9 +51,9 @@ ScriptValue InjectedScriptManager::createInjectedScript(const String& scriptSour ...@@ -51,9 +51,9 @@ ScriptValue InjectedScriptManager::createInjectedScript(const String& scriptSour
m_injectedScriptHost->setWrapperTemplate(wrapperTemplate, isolate); m_injectedScriptHost->setWrapperTemplate(wrapperTemplate, isolate);
} }
v8::Local<v8::Object> scriptHostWrapper = V8InjectedScriptHost::wrap(wrapperTemplate, inspectedScriptState->context(), m_injectedScriptHost); v8::Local<v8::Object> scriptHostWrapper = V8InjectedScriptHost::wrap(wrapperTemplate, context, m_injectedScriptHost);
if (scriptHostWrapper.IsEmpty()) if (scriptHostWrapper.IsEmpty())
return ScriptValue(); return v8::Local<v8::Object>();
injectedScriptNative->setOnInjectedScriptHost(scriptHostWrapper); injectedScriptNative->setOnInjectedScriptHost(scriptHostWrapper);
...@@ -64,15 +64,17 @@ ScriptValue InjectedScriptManager::createInjectedScript(const String& scriptSour ...@@ -64,15 +64,17 @@ ScriptValue InjectedScriptManager::createInjectedScript(const String& scriptSour
// to create and configure InjectedScript instance that is going to be used by the inspector. // to create and configure InjectedScript instance that is going to be used by the inspector.
v8::Local<v8::Value> value; v8::Local<v8::Value> value;
if (!V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, scriptSource), isolate).ToLocal(&value)) if (!V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, scriptSource), isolate).ToLocal(&value))
return ScriptValue(); return v8::Local<v8::Object>();
ASSERT(value->IsFunction()); ASSERT(value->IsFunction());
v8::Local<v8::Object> windowGlobal = inspectedScriptState->context()->Global(); v8::Local<v8::Object> windowGlobal = context->Global();
v8::Local<v8::Value> info[] = { scriptHostWrapper, windowGlobal, v8::Number::New(inspectedScriptState->isolate(), id) }; v8::Local<v8::Value> info[] = { scriptHostWrapper, windowGlobal, v8::Number::New(context->GetIsolate(), id) };
v8::Local<v8::Value> injectedScriptValue; v8::Local<v8::Value> injectedScriptValue;
if (!V8ScriptRunner::callInternalFunction(v8::Local<v8::Function>::Cast(value), windowGlobal, WTF_ARRAY_LENGTH(info), info, inspectedScriptState->isolate()).ToLocal(&injectedScriptValue)) if (!V8ScriptRunner::callInternalFunction(v8::Local<v8::Function>::Cast(value), windowGlobal, WTF_ARRAY_LENGTH(info), info, context->GetIsolate()).ToLocal(&injectedScriptValue))
return ScriptValue(); return v8::Local<v8::Object>();
return ScriptValue(inspectedScriptState, injectedScriptValue); if (!injectedScriptValue->IsObject())
return v8::Local<v8::Object>();
return injectedScriptValue.As<v8::Object>();
} }
} // namespace blink } // namespace blink
...@@ -106,9 +106,9 @@ static PassRefPtr<TypeBuilder::Debugger::ExceptionDetails> toExceptionDetails(Pa ...@@ -106,9 +106,9 @@ static PassRefPtr<TypeBuilder::Debugger::ExceptionDetails> toExceptionDetails(Pa
return exceptionDetails.release(); return exceptionDetails.release();
} }
InjectedScript::InjectedScript(ScriptValue injectedScriptObject, V8DebuggerClient* client, PassRefPtr<InjectedScriptNative> injectedScriptNative, int contextId) InjectedScript::InjectedScript(v8::Local<v8::Object> injectedScriptObject, V8DebuggerClient* client, PassRefPtr<InjectedScriptNative> injectedScriptNative, int contextId)
: m_isolate(injectedScriptObject.isolate()) : m_isolate(injectedScriptObject->CreationContext()->GetIsolate())
, m_injectedScriptObject(injectedScriptObject) , m_injectedScriptObject(ScriptValue(ScriptState::from(injectedScriptObject->CreationContext()), injectedScriptObject))
, m_client(client) , m_client(client)
, m_native(injectedScriptNative) , m_native(injectedScriptNative)
, m_contextId(contextId) , m_contextId(contextId)
...@@ -347,12 +347,12 @@ PassRefPtr<Array<CallFrame>> InjectedScript::wrapCallFrames(v8::Local<v8::Object ...@@ -347,12 +347,12 @@ PassRefPtr<Array<CallFrame>> InjectedScript::wrapCallFrames(v8::Local<v8::Object
return Array<CallFrame>::create(); return Array<CallFrame>::create();
} }
PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(const ScriptValue& value, const String& groupName, bool generatePreview) const PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(v8::Local<v8::Value> value, const String& groupName, bool generatePreview) const
{ {
ScriptState::Scope scope(m_injectedScriptObject.scriptState()); ScriptState::Scope scope(m_injectedScriptObject.scriptState());
v8::Local<v8::Context> context = v8Context(); v8::Local<v8::Context> context = v8Context();
ScriptFunctionCall function(m_client, context, v8Value(), "wrapObject"); ScriptFunctionCall function(m_client, context, v8Value(), "wrapObject");
function.appendArgument(value.v8Value()); function.appendArgument(value);
function.appendArgument(groupName); function.appendArgument(groupName);
function.appendArgument(canAccessInspectedWindow()); function.appendArgument(canAccessInspectedWindow());
function.appendArgument(generatePreview); function.appendArgument(generatePreview);
...@@ -364,17 +364,17 @@ PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(const ...@@ -364,17 +364,17 @@ PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(const
return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult); return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult);
} }
PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapTable(const ScriptValue& table, const ScriptValue& columns) const PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapTable(v8::Local<v8::Value> table, v8::Local<v8::Value> columns) const
{ {
ScriptState::Scope scope(m_injectedScriptObject.scriptState()); ScriptState::Scope scope(m_injectedScriptObject.scriptState());
v8::Local<v8::Context> context = v8Context(); v8::Local<v8::Context> context = v8Context();
ScriptFunctionCall function(m_client, context, v8Value(), "wrapTable"); ScriptFunctionCall function(m_client, context, v8Value(), "wrapTable");
function.appendArgument(canAccessInspectedWindow()); function.appendArgument(canAccessInspectedWindow());
function.appendArgument(table.v8Value()); function.appendArgument(table);
if (columns.isEmpty()) if (columns.IsEmpty())
function.appendArgument(false); function.appendArgument(false);
else else
function.appendArgument(columns.v8Value()); function.appendArgument(columns);
bool hadException = false; bool hadException = false;
v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException); v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException);
if (hadException) if (hadException)
...@@ -426,7 +426,7 @@ void InjectedScript::setCustomObjectFormatterEnabled(bool enabled) ...@@ -426,7 +426,7 @@ void InjectedScript::setCustomObjectFormatterEnabled(bool enabled)
bool InjectedScript::canAccessInspectedWindow() const bool InjectedScript::canAccessInspectedWindow() const
{ {
ScriptState* scriptState = m_injectedScriptObject.scriptState(); ScriptState* scriptState = m_injectedScriptObject.scriptState();
return scriptState && m_client->canAccessContext(scriptState->context()); return scriptState && m_client->callingContextCanAccessContext(scriptState->context());
} }
v8::Local<v8::Context> InjectedScript::v8Context() const v8::Local<v8::Context> InjectedScript::v8Context() const
......
...@@ -102,8 +102,8 @@ public: ...@@ -102,8 +102,8 @@ public:
PassRefPtr<TypeBuilder::Array<TypeBuilder::Debugger::CallFrame>> wrapCallFrames(v8::Local<v8::Object>, int asyncOrdinal); PassRefPtr<TypeBuilder::Array<TypeBuilder::Debugger::CallFrame>> wrapCallFrames(v8::Local<v8::Object>, int asyncOrdinal);
PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapObject(const ScriptValue&, const String& groupName, bool generatePreview = false) const; PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapObject(v8::Local<v8::Value>, const String& groupName, bool generatePreview = false) const;
PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapTable(const ScriptValue& table, const ScriptValue& columns) const; PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapTable(v8::Local<v8::Value> table, v8::Local<v8::Value> columns) const;
v8::Local<v8::Value> findObject(const RemoteObjectId&) const; v8::Local<v8::Value> findObject(const RemoteObjectId&) const;
String objectIdToObjectGroupName(const String& objectId) const; String objectIdToObjectGroupName(const String& objectId) const;
...@@ -113,8 +113,8 @@ public: ...@@ -113,8 +113,8 @@ public:
int contextId() { return m_contextId; } int contextId() { return m_contextId; }
private: private:
friend InjectedScript* InjectedScriptManager::injectedScriptFor(ScriptState*); friend InjectedScript* InjectedScriptManager::injectedScriptFor(v8::Local<v8::Context>);
InjectedScript(ScriptValue, V8DebuggerClient*, PassRefPtr<InjectedScriptNative>, int contextId); InjectedScript(v8::Local<v8::Object>, V8DebuggerClient*, PassRefPtr<InjectedScriptNative>, int contextId);
bool canAccessInspectedWindow() const; bool canAccessInspectedWindow() const;
v8::Local<v8::Context> v8Context() const; v8::Local<v8::Context> v8Context() const;
......
...@@ -81,9 +81,9 @@ void InjectedScriptHost::clearConsoleMessages() ...@@ -81,9 +81,9 @@ void InjectedScriptHost::clearConsoleMessages()
(*m_clearConsoleCallback)(); (*m_clearConsoleCallback)();
} }
ScriptValue InjectedScriptHost::InspectableObject::get(ScriptState*) v8::Local<v8::Value> InjectedScriptHost::InspectableObject::get(v8::Local<v8::Context>)
{ {
return ScriptValue(); return v8::Local<v8::Value>();
}; };
void InjectedScriptHost::addInspectedObject(PassOwnPtr<InjectedScriptHost::InspectableObject> object) void InjectedScriptHost::addInspectedObject(PassOwnPtr<InjectedScriptHost::InspectableObject> object)
......
...@@ -79,7 +79,7 @@ public: ...@@ -79,7 +79,7 @@ public:
class InspectableObject { class InspectableObject {
USING_FAST_MALLOC(InspectableObject); USING_FAST_MALLOC(InspectableObject);
public: public:
virtual ScriptValue get(ScriptState*); virtual v8::Local<v8::Value> get(v8::Local<v8::Context>);
virtual ~InspectableObject() { } virtual ~InspectableObject() { }
}; };
void addInspectedObject(PassOwnPtr<InspectableObject>); void addInspectedObject(PassOwnPtr<InspectableObject>);
......
...@@ -88,10 +88,9 @@ void InjectedScriptManager::discardInjectedScripts() ...@@ -88,10 +88,9 @@ void InjectedScriptManager::discardInjectedScripts()
m_idToInjectedScript.clear(); m_idToInjectedScript.clear();
} }
int InjectedScriptManager::discardInjectedScriptFor(ScriptState* scriptState) int InjectedScriptManager::discardInjectedScriptFor(v8::Local<v8::Context> context)
{ {
ScriptState::Scope scope(scriptState); int contextId = V8Debugger::contextId(context);
int contextId = V8Debugger::contextId(scriptState->context());
m_idToInjectedScript.remove(contextId); m_idToInjectedScript.remove(contextId);
return contextId; return contextId;
} }
...@@ -122,20 +121,20 @@ String InjectedScriptManager::injectedScriptSource() ...@@ -122,20 +121,20 @@ String InjectedScriptManager::injectedScriptSource()
return String(injectedScriptSourceResource.data(), injectedScriptSourceResource.size()); return String(injectedScriptSourceResource.data(), injectedScriptSourceResource.size());
} }
InjectedScript* InjectedScriptManager::injectedScriptFor(ScriptState* scriptState) InjectedScript* InjectedScriptManager::injectedScriptFor(v8::Local<v8::Context> context)
{ {
ScriptState::Scope scope(scriptState); v8::Context::Scope scope(context);
int contextId = V8Debugger::contextId(scriptState->context()); int contextId = V8Debugger::contextId(context);
IdToInjectedScriptMap::iterator it = m_idToInjectedScript.find(contextId); IdToInjectedScriptMap::iterator it = m_idToInjectedScript.find(contextId);
if (it != m_idToInjectedScript.end()) if (it != m_idToInjectedScript.end())
return it->value.get(); return it->value.get();
if (!m_client->canAccessContext(scriptState->context())) if (!m_client->callingContextCanAccessContext(context))
return nullptr; return nullptr;
RefPtr<InjectedScriptNative> injectedScriptNative = adoptRef(new InjectedScriptNative(scriptState->isolate())); RefPtr<InjectedScriptNative> injectedScriptNative = adoptRef(new InjectedScriptNative(context->GetIsolate()));
ScriptValue injectedScriptValue = createInjectedScript(injectedScriptSource(), scriptState, contextId, injectedScriptNative.get()); v8::Local<v8::Object> injectedScriptValue = createInjectedScript(injectedScriptSource(), context, contextId, injectedScriptNative.get());
OwnPtr<InjectedScript> result = adoptPtr(new InjectedScript(injectedScriptValue, m_client, injectedScriptNative.release(), contextId)); OwnPtr<InjectedScript> result = adoptPtr(new InjectedScript(injectedScriptValue, m_client, injectedScriptNative.release(), contextId));
InjectedScript* resultPtr = result.get(); InjectedScript* resultPtr = result.get();
if (m_customObjectFormatterEnabled) if (m_customObjectFormatterEnabled)
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#ifndef InjectedScriptManager_h #ifndef InjectedScriptManager_h
#define InjectedScriptManager_h #define InjectedScriptManager_h
#include "bindings/core/v8/ScriptState.h"
#include "core/CoreExport.h" #include "core/CoreExport.h"
#include "wtf/Forward.h" #include "wtf/Forward.h"
#include "wtf/HashMap.h" #include "wtf/HashMap.h"
...@@ -43,7 +42,6 @@ class InjectedScript; ...@@ -43,7 +42,6 @@ class InjectedScript;
class InjectedScriptHost; class InjectedScriptHost;
class InjectedScriptNative; class InjectedScriptNative;
class RemoteObjectIdBase; class RemoteObjectIdBase;
class ScriptValue;
class V8DebuggerClient; class V8DebuggerClient;
class CORE_EXPORT InjectedScriptManager { class CORE_EXPORT InjectedScriptManager {
...@@ -57,22 +55,19 @@ public: ...@@ -57,22 +55,19 @@ public:
InjectedScriptHost* injectedScriptHost(); InjectedScriptHost* injectedScriptHost();
InjectedScript* injectedScriptFor(ScriptState*); InjectedScript* injectedScriptFor(v8::Local<v8::Context>);
InjectedScript* findInjectedScript(int) const; InjectedScript* findInjectedScript(int) const;
InjectedScript* findInjectedScript(RemoteObjectIdBase*) const; InjectedScript* findInjectedScript(RemoteObjectIdBase*) const;
void discardInjectedScripts(); void discardInjectedScripts();
int discardInjectedScriptFor(ScriptState*); int discardInjectedScriptFor(v8::Local<v8::Context>);
void releaseObjectGroup(const String& objectGroup); void releaseObjectGroup(const String& objectGroup);
typedef bool (*InspectedStateAccessCheck)(ScriptState*);
void setCustomObjectFormatterEnabled(bool); void setCustomObjectFormatterEnabled(bool);
private: private:
explicit InjectedScriptManager(V8DebuggerClient*); explicit InjectedScriptManager(V8DebuggerClient*);
String injectedScriptSource(); String injectedScriptSource();
ScriptValue createInjectedScript(const String& source, ScriptState*, int id, InjectedScriptNative*); v8::Local<v8::Object> createInjectedScript(const String& source, v8::Local<v8::Context>, int id, InjectedScriptNative*);
typedef HashMap<int, OwnPtr<InjectedScript>> IdToInjectedScriptMap; typedef HashMap<int, OwnPtr<InjectedScript>> IdToInjectedScriptMap;
IdToInjectedScriptMap m_idToInjectedScript; IdToInjectedScriptMap m_idToInjectedScript;
......
...@@ -390,15 +390,12 @@ void InspectorAnimationAgent::resolveAnimation(ErrorString* errorString, const S ...@@ -390,15 +390,12 @@ void InspectorAnimationAgent::resolveAnimation(ErrorString* errorString, const S
ScriptState* scriptState = ScriptState::forMainWorld(frame); ScriptState* scriptState = ScriptState::forMainWorld(frame);
if (!scriptState) if (!scriptState)
return; return;
InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState); ScriptState::Scope scope(scriptState);
InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState->context());
if (!injectedScript) if (!injectedScript)
return; return;
ScriptState::Scope scope(scriptState);
v8::Isolate* isolate = scriptState->isolate();
ScriptValue scriptValue = ScriptValue(scriptState, toV8(animation, scriptState->context()->Global(), isolate));
injectedScript->releaseObjectGroup("animation"); injectedScript->releaseObjectGroup("animation");
result = injectedScript->wrapObject(scriptValue, "animation"); result = injectedScript->wrapObject(toV8(animation, scriptState->context()->Global(), scriptState->isolate()), "animation");
} }
static CSSPropertyID animationProperties[] = { static CSSPropertyID animationProperties[] = {
......
...@@ -196,12 +196,13 @@ void InspectorConsoleAgent::sendConsoleMessageToFrontend(ConsoleMessage* console ...@@ -196,12 +196,13 @@ void InspectorConsoleAgent::sendConsoleMessageToFrontend(ConsoleMessage* console
jsonObj->setNetworkRequestId(IdentifiersFactory::requestId(consoleMessage->requestIdentifier())); jsonObj->setNetworkRequestId(IdentifiersFactory::requestId(consoleMessage->requestIdentifier()));
RefPtrWillBeRawPtr<ScriptArguments> arguments = consoleMessage->scriptArguments(); RefPtrWillBeRawPtr<ScriptArguments> arguments = consoleMessage->scriptArguments();
if (arguments && arguments->argumentCount()) { if (arguments && arguments->argumentCount()) {
InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(arguments->scriptState()); ScriptState::Scope scope(arguments->scriptState());
InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(arguments->scriptState()->context());
if (injectedScript) { if (injectedScript) {
RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::RemoteObject> > jsonArgs = TypeBuilder::Array<TypeBuilder::Runtime::RemoteObject>::create(); RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::RemoteObject> > jsonArgs = TypeBuilder::Array<TypeBuilder::Runtime::RemoteObject>::create();
if (consoleMessage->type() == TableMessageType && generatePreview && arguments->argumentCount()) { if (consoleMessage->type() == TableMessageType && generatePreview && arguments->argumentCount()) {
ScriptValue table = arguments->argumentAt(0); v8::Local<v8::Value> table = arguments->argumentAt(0).v8Value();
ScriptValue columns = arguments->argumentCount() > 1 ? arguments->argumentAt(1) : ScriptValue(); v8::Local<v8::Value> columns = arguments->argumentCount() > 1 ? arguments->argumentAt(1).v8Value() : v8::Local<v8::Value>();
RefPtr<TypeBuilder::Runtime::RemoteObject> inspectorValue = injectedScript->wrapTable(table, columns); RefPtr<TypeBuilder::Runtime::RemoteObject> inspectorValue = injectedScript->wrapTable(table, columns);
if (!inspectorValue) { if (!inspectorValue) {
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
...@@ -210,7 +211,7 @@ void InspectorConsoleAgent::sendConsoleMessageToFrontend(ConsoleMessage* console ...@@ -210,7 +211,7 @@ void InspectorConsoleAgent::sendConsoleMessageToFrontend(ConsoleMessage* console
jsonArgs->addItem(inspectorValue); jsonArgs->addItem(inspectorValue);
} else { } else {
for (unsigned i = 0; i < arguments->argumentCount(); ++i) { for (unsigned i = 0; i < arguments->argumentCount(); ++i) {
RefPtr<TypeBuilder::Runtime::RemoteObject> inspectorValue = injectedScript->wrapObject(arguments->argumentAt(i), "console", generatePreview); RefPtr<TypeBuilder::Runtime::RemoteObject> inspectorValue = injectedScript->wrapObject(arguments->argumentAt(i).v8Value(), "console", generatePreview);
if (!inspectorValue) { if (!inspectorValue) {
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
return; return;
......
...@@ -153,14 +153,13 @@ bool parseQuad(const RefPtr<JSONArray>& quadArray, FloatQuad* quad) ...@@ -153,14 +153,13 @@ bool parseQuad(const RefPtr<JSONArray>& quadArray, FloatQuad* quad)
return true; return true;
} }
ScriptValue nodeAsScriptValue(ScriptState* scriptState, Node* node) v8::Local<v8::Value> nodeV8Value(v8::Local<v8::Context> context, Node* node)
{ {
ScriptState::Scope scope(scriptState); v8::Isolate* isolate = context->GetIsolate();
v8::Isolate* isolate = scriptState->isolate(); ExceptionState exceptionState(ExceptionState::ExecutionContext, "nodeV8Value", "InjectedScriptHost", context->Global(), isolate);
ExceptionState exceptionState(ExceptionState::ExecutionContext, "nodeAsScriptValue", "InjectedScriptHost", scriptState->context()->Global(), isolate);
if (!node || !BindingSecurity::shouldAllowAccessTo(isolate, callingDOMWindow(isolate), node, exceptionState)) if (!node || !BindingSecurity::shouldAllowAccessTo(isolate, callingDOMWindow(isolate), node, exceptionState))
return ScriptValue(scriptState, v8::Null(isolate)); return v8::Null(isolate);
return ScriptValue(scriptState, toV8(node, scriptState->context()->Global(), isolate)); return toV8(node, context->Global(), isolate);
} }
} // namespace } // namespace
...@@ -2067,9 +2066,9 @@ class InspectableNode final : public InjectedScriptHost::InspectableObject { ...@@ -2067,9 +2066,9 @@ class InspectableNode final : public InjectedScriptHost::InspectableObject {
public: public:
explicit InspectableNode(Node* node) : m_nodeId(DOMNodeIds::idForNode(node)) { } explicit InspectableNode(Node* node) : m_nodeId(DOMNodeIds::idForNode(node)) { }
ScriptValue get(ScriptState* state) override v8::Local<v8::Value> get(v8::Local<v8::Context> context) override
{ {
return nodeAsScriptValue(state, DOMNodeIds::nodeForId(m_nodeId)); return nodeV8Value(context, DOMNodeIds::nodeForId(m_nodeId));
} }
private: private:
int m_nodeId; int m_nodeId;
...@@ -2120,12 +2119,12 @@ PassRefPtr<TypeBuilder::Runtime::RemoteObject> InspectorDOMAgent::resolveNode(No ...@@ -2120,12 +2119,12 @@ PassRefPtr<TypeBuilder::Runtime::RemoteObject> InspectorDOMAgent::resolveNode(No
ScriptState* scriptState = ScriptState::forMainWorld(frame); ScriptState* scriptState = ScriptState::forMainWorld(frame);
if (!scriptState) if (!scriptState)
return nullptr; return nullptr;
InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState);
ScriptState::Scope scope(scriptState);
InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState->context());
if (!injectedScript) if (!injectedScript)
return nullptr; return nullptr;
return injectedScript->wrapObject(nodeV8Value(scriptState->context(), node), objectGroup);
ScriptValue scriptValue = nodeAsScriptValue(scriptState, node);
return injectedScript->wrapObject(scriptValue, objectGroup);
} }
bool InspectorDOMAgent::pushDocumentUponHandlelessOperation(ErrorString* errorString) bool InspectorDOMAgent::pushDocumentUponHandlelessOperation(ErrorString* errorString)
......
...@@ -428,8 +428,8 @@ PassRefPtr<TypeBuilder::DOMDebugger::EventListener> InspectorDOMDebuggerAgent::b ...@@ -428,8 +428,8 @@ PassRefPtr<TypeBuilder::DOMDebugger::EventListener> InspectorDOMDebuggerAgent::b
.setUseCapture(info.useCapture) .setUseCapture(info.useCapture)
.setLocation(location); .setLocation(location);
if (!objectGroupId.isEmpty()) { if (!objectGroupId.isEmpty()) {
value->setHandler(injectedScript->wrapObject(ScriptValue(scriptState, function), objectGroupId)); value->setHandler(injectedScript->wrapObject(function, objectGroupId));
value->setOriginalHandler(injectedScript->wrapObject(ScriptValue(scriptState, info.handler), objectGroupId)); value->setOriginalHandler(injectedScript->wrapObject(info.handler, objectGroupId));
} }
return value.release(); return value.release();
} }
......
...@@ -104,13 +104,12 @@ private: ...@@ -104,13 +104,12 @@ private:
InspectorFrontend::HeapProfiler* m_frontend; InspectorFrontend::HeapProfiler* m_frontend;
}; };
ScriptValue objectByHeapObjectId(v8::Isolate* isolate, unsigned id) v8::Local<v8::Object> objectByHeapObjectId(v8::Isolate* isolate, unsigned id)
{ {
v8::HeapProfiler* profiler = isolate->GetHeapProfiler(); v8::HeapProfiler* profiler = isolate->GetHeapProfiler();
v8::HandleScope handleScope(isolate);
v8::Local<v8::Value> value = profiler->FindObjectById(id); v8::Local<v8::Value> value = profiler->FindObjectById(id);
if (value.IsEmpty() || !value->IsObject()) if (value.IsEmpty() || !value->IsObject())
return ScriptValue(); return v8::Local<v8::Object>();
v8::Local<v8::Object> object = value.As<v8::Object>(); v8::Local<v8::Object> object = value.As<v8::Object>();
...@@ -119,19 +118,18 @@ ScriptValue objectByHeapObjectId(v8::Isolate* isolate, unsigned id) ...@@ -119,19 +118,18 @@ ScriptValue objectByHeapObjectId(v8::Isolate* isolate, unsigned id)
// Skip wrapper boilerplates which are like regular wrappers but don't have // Skip wrapper boilerplates which are like regular wrappers but don't have
// native object. // native object.
if (!wrapper.IsEmpty() && wrapper->IsUndefined()) if (!wrapper.IsEmpty() && wrapper->IsUndefined())
return ScriptValue(); return v8::Local<v8::Object>();
} }
ScriptState* scriptState = ScriptState::from(object->CreationContext()); return object;
return ScriptValue(scriptState, object);
} }
class InspectableHeapObject final : public InjectedScriptHost::InspectableObject { class InspectableHeapObject final : public InjectedScriptHost::InspectableObject {
public: public:
explicit InspectableHeapObject(unsigned heapObjectId) : m_heapObjectId(heapObjectId) { } explicit InspectableHeapObject(unsigned heapObjectId) : m_heapObjectId(heapObjectId) { }
ScriptValue get(ScriptState* state) override v8::Local<v8::Value> get(v8::Local<v8::Context> context) override
{ {
return objectByHeapObjectId(state->isolate(), m_heapObjectId); return objectByHeapObjectId(context->GetIsolate(), m_heapObjectId);
} }
private: private:
unsigned m_heapObjectId; unsigned m_heapObjectId;
...@@ -328,12 +326,14 @@ void InspectorHeapProfilerAgent::getObjectByHeapObjectId(ErrorString* error, con ...@@ -328,12 +326,14 @@ void InspectorHeapProfilerAgent::getObjectByHeapObjectId(ErrorString* error, con
*error = "Invalid heap snapshot object id"; *error = "Invalid heap snapshot object id";
return; return;
} }
ScriptValue heapObject = objectByHeapObjectId(m_isolate, id);
if (heapObject.isEmpty()) { v8::HandleScope handles(m_isolate);
v8::Local<v8::Object> heapObject = objectByHeapObjectId(m_isolate, id);
if (heapObject.IsEmpty()) {
*error = "Object is not available"; *error = "Object is not available";
return; return;
} }
InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(heapObject.scriptState()); InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(heapObject->CreationContext());
if (!injectedScript) { if (!injectedScript) {
*error = "Object is not available. Inspected context is gone"; *error = "Object is not available. Inspected context is gone";
return; return;
......
...@@ -94,7 +94,8 @@ void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& exp ...@@ -94,7 +94,8 @@ void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& exp
if (optExecutionContextId) { if (optExecutionContextId) {
executionContextId = *optExecutionContextId; executionContextId = *optExecutionContextId;
} else { } else {
InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(defaultScriptState()); v8::HandleScope handles(defaultScriptState()->isolate());
InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(defaultScriptState()->context());
ASSERT(injectedScript); ASSERT(injectedScript);
executionContextId = injectedScript->contextId(); executionContextId = injectedScript->contextId();
} }
...@@ -165,12 +166,14 @@ void InspectorRuntimeAgent::disable(ErrorString* errorString) ...@@ -165,12 +166,14 @@ void InspectorRuntimeAgent::disable(ErrorString* errorString)
void InspectorRuntimeAgent::reportExecutionContextCreated(ScriptState* scriptState, const String& type, const String& origin, const String& humanReadableName, const String& frameId) void InspectorRuntimeAgent::reportExecutionContextCreated(ScriptState* scriptState, const String& type, const String& origin, const String& humanReadableName, const String& frameId)
{ {
m_v8RuntimeAgent->reportExecutionContextCreated(scriptState, type, origin, humanReadableName, frameId); v8::HandleScope handles(scriptState->isolate());
m_v8RuntimeAgent->reportExecutionContextCreated(scriptState->context(), type, origin, humanReadableName, frameId);
} }
void InspectorRuntimeAgent::reportExecutionContextDestroyed(ScriptState* scriptState) void InspectorRuntimeAgent::reportExecutionContextDestroyed(ScriptState* scriptState)
{ {
m_v8RuntimeAgent->reportExecutionContextDestroyed(scriptState); v8::HandleScope handles(scriptState->isolate());
m_v8RuntimeAgent->reportExecutionContextDestroyed(scriptState->context());
} }
} // namespace blink } // namespace blink
...@@ -124,7 +124,7 @@ void MainThreadDebugger::quitMessageLoopOnPause() ...@@ -124,7 +124,7 @@ void MainThreadDebugger::quitMessageLoopOnPause()
m_clientMessageLoop->quitNow(); m_clientMessageLoop->quitNow();
} }
bool MainThreadDebugger::canAccessContext(v8::Local<v8::Context> context) bool MainThreadDebugger::callingContextCanAccessContext(v8::Local<v8::Context> context)
{ {
if (context.IsEmpty()) if (context.IsEmpty())
return false; return false;
......
...@@ -77,7 +77,7 @@ private: ...@@ -77,7 +77,7 @@ private:
// V8DebuggerClient implementation. // V8DebuggerClient implementation.
void runMessageLoopOnPause(int contextGroupId) override; void runMessageLoopOnPause(int contextGroupId) override;
void quitMessageLoopOnPause() override; void quitMessageLoopOnPause() override;
bool canAccessContext(v8::Local<v8::Context>) override; bool callingContextCanAccessContext(v8::Local<v8::Context>) override;
static WTF::Mutex& creationMutex(); static WTF::Mutex& creationMutex();
......
...@@ -34,9 +34,9 @@ v8::Local<v8::Object> ThreadDebugger::compileDebuggerScript() ...@@ -34,9 +34,9 @@ v8::Local<v8::Object> ThreadDebugger::compileDebuggerScript()
return value.As<v8::Object>(); return value.As<v8::Object>();
} }
void ThreadDebugger::eventListeners(v8::Isolate* isolate, v8::Local<v8::Value> value, EventListenerInfoMap& result) void ThreadDebugger::eventListeners(v8::Local<v8::Value> value, EventListenerInfoMap& result)
{ {
InspectorDOMDebuggerAgent::eventListenersInfoForTarget(isolate, value, result); InspectorDOMDebuggerAgent::eventListenersInfoForTarget(m_isolate, value, result);
} }
v8::MaybeLocal<v8::Value> ThreadDebugger::callFunction(v8::Local<v8::Function> function, v8::Local<v8::Context> context, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[]) v8::MaybeLocal<v8::Value> ThreadDebugger::callFunction(v8::Local<v8::Function> function, v8::Local<v8::Context> context, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[])
......
...@@ -24,7 +24,7 @@ public: ...@@ -24,7 +24,7 @@ public:
// V8DebuggerClient implementation. // V8DebuggerClient implementation.
v8::Local<v8::Object> compileDebuggerScript() override; v8::Local<v8::Object> compileDebuggerScript() override;
void eventListeners(v8::Isolate*, v8::Local<v8::Value>, EventListenerInfoMap&) override; void eventListeners(v8::Local<v8::Value>, EventListenerInfoMap&) override;
v8::MaybeLocal<v8::Value> callFunction(v8::Local<v8::Function>, v8::Local<v8::Context>, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[]) override; v8::MaybeLocal<v8::Value> callFunction(v8::Local<v8::Function>, v8::Local<v8::Context>, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[]) override;
V8Debugger* debugger() const { return m_debugger.get(); } V8Debugger* debugger() const { return m_debugger.get(); }
......
...@@ -78,7 +78,7 @@ void WorkerThreadDebugger::quitMessageLoopOnPause() ...@@ -78,7 +78,7 @@ void WorkerThreadDebugger::quitMessageLoopOnPause()
m_paused = false; m_paused = false;
} }
bool WorkerThreadDebugger::canAccessContext(v8::Local<v8::Context> context) bool WorkerThreadDebugger::callingContextCanAccessContext(v8::Local<v8::Context> context)
{ {
return true; return true;
} }
......
...@@ -49,7 +49,7 @@ public: ...@@ -49,7 +49,7 @@ public:
// V8DebuggerClient implementation. // V8DebuggerClient implementation.
void runMessageLoopOnPause(int contextGroupId) override; void runMessageLoopOnPause(int contextGroupId) override;
void quitMessageLoopOnPause() override; void quitMessageLoopOnPause() override;
bool canAccessContext(v8::Local<v8::Context>) override; bool callingContextCanAccessContext(v8::Local<v8::Context>) override;
private: private:
WorkerThread* m_workerThread; WorkerThread* m_workerThread;
......
...@@ -1035,22 +1035,19 @@ void V8DebuggerAgentImpl::runScript(ErrorString* errorString, const ScriptId& sc ...@@ -1035,22 +1035,19 @@ void V8DebuggerAgentImpl::runScript(ErrorString* errorString, const ScriptId& sc
} }
v8::TryCatch tryCatch(m_isolate); v8::TryCatch tryCatch(m_isolate);
v8::Local<v8::Value> value; v8::Local<v8::Value> value;
ScriptValue scriptValue; if (!v8Call(V8ScriptRunner::runCompiledScript(m_isolate, script, scriptState->executionContext()), value, tryCatch)) {
if (v8Call(V8ScriptRunner::runCompiledScript(m_isolate, script, scriptState->executionContext()), value, tryCatch)) { value = tryCatch.Exception();
scriptValue = ScriptValue(scriptState, value);
} else {
scriptValue = ScriptValue(scriptState, tryCatch.Exception());
v8::Local<v8::Message> message = tryCatch.Message(); v8::Local<v8::Message> message = tryCatch.Message();
if (!message.IsEmpty()) if (!message.IsEmpty())
exceptionDetails = createExceptionDetails(m_isolate, message); exceptionDetails = createExceptionDetails(m_isolate, message);
} }
if (scriptValue.isEmpty()) { if (value.IsEmpty()) {
*errorString = "Script execution failed"; *errorString = "Script execution failed";
return; return;
} }
result = injectedScript->wrapObject(scriptValue, objectGroup ? *objectGroup : ""); result = injectedScript->wrapObject(value, objectGroup ? *objectGroup : "");
} }
void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString, int scopeNumber, const String& variableName, const RefPtr<JSONObject>& newValue, const String* callFrameId, const String* functionObjectId) void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString, int scopeNumber, const String& variableName, const RefPtr<JSONObject>& newValue, const String* callFrameId, const String* functionObjectId)
...@@ -1153,8 +1150,9 @@ void V8DebuggerAgentImpl::getPromiseById(ErrorString* errorString, int promiseId ...@@ -1153,8 +1150,9 @@ void V8DebuggerAgentImpl::getPromiseById(ErrorString* errorString, int promiseId
*errorString = "Promise with specified ID not found."; *errorString = "Promise with specified ID not found.";
return; return;
} }
InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(value.scriptState()); ScriptState::Scope scope(value.scriptState());
promise = injectedScript->wrapObject(value, objectGroup ? *objectGroup : ""); InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(value.context());
promise = injectedScript->wrapObject(value.v8Value(), objectGroup ? *objectGroup : "");
} }
void V8DebuggerAgentImpl::didUpdatePromise(InspectorFrontend::Debugger::EventType::Enum eventType, PassRefPtr<TypeBuilder::Debugger::PromiseDetails> promise) void V8DebuggerAgentImpl::didUpdatePromise(InspectorFrontend::Debugger::EventType::Enum eventType, PassRefPtr<TypeBuilder::Debugger::PromiseDetails> promise)
...@@ -1434,13 +1432,13 @@ PassRefPtr<Array<CallFrame>> V8DebuggerAgentImpl::currentCallFrames() ...@@ -1434,13 +1432,13 @@ PassRefPtr<Array<CallFrame>> V8DebuggerAgentImpl::currentCallFrames()
{ {
if (!m_pausedScriptState || m_currentCallStack.IsEmpty()) if (!m_pausedScriptState || m_currentCallStack.IsEmpty())
return Array<CallFrame>::create(); return Array<CallFrame>::create();
InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(m_pausedScriptState.get()); v8::HandleScope handles(m_isolate);
InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(m_pausedScriptState->context());
if (!injectedScript) { if (!injectedScript) {
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
return Array<CallFrame>::create(); return Array<CallFrame>::create();
} }
v8::HandleScope scope(m_isolate);
v8::Local<v8::Object> currentCallStack = m_currentCallStack.Get(m_isolate); v8::Local<v8::Object> currentCallStack = m_currentCallStack.Get(m_isolate);
return injectedScript->wrapCallFrames(currentCallStack, 0); return injectedScript->wrapCallFrames(currentCallStack, 0);
} }
...@@ -1461,7 +1459,7 @@ PassRefPtr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace() ...@@ -1461,7 +1459,7 @@ PassRefPtr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace()
v8::HandleScope scope(m_isolate); v8::HandleScope scope(m_isolate);
v8::Local<v8::Object> callFrames = (*it)->callFrames(m_isolate); v8::Local<v8::Object> callFrames = (*it)->callFrames(m_isolate);
ScriptState* scriptState = ScriptState::from(callFrames->CreationContext()); ScriptState* scriptState = ScriptState::from(callFrames->CreationContext());
InjectedScript* injectedScript = scriptState ? m_injectedScriptManager->injectedScriptFor(scriptState) : nullptr; InjectedScript* injectedScript = scriptState ? m_injectedScriptManager->injectedScriptFor(scriptState->context()) : nullptr;
if (!injectedScript) { if (!injectedScript) {
result.clear(); result.clear();
continue; continue;
...@@ -1560,7 +1558,7 @@ void V8DebuggerAgentImpl::didParseSource(const V8DebuggerParsedScript& parsedScr ...@@ -1560,7 +1558,7 @@ void V8DebuggerAgentImpl::didParseSource(const V8DebuggerParsedScript& parsedScr
} }
} }
V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8::Context> context, v8::Local<v8::Object> callFrames, v8::Local<v8::Value> v8exception, const Vector<String>& hitBreakpoints, bool isPromiseRejection) V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8::Context> context, v8::Local<v8::Object> callFrames, v8::Local<v8::Value> exception, const Vector<String>& hitBreakpoints, bool isPromiseRejection)
{ {
ScriptState* scriptState = ScriptState::from(context); ScriptState* scriptState = ScriptState::from(context);
if (!scriptState->contextIsValid()) if (!scriptState->contextIsValid())
...@@ -1569,14 +1567,12 @@ V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8 ...@@ -1569,14 +1567,12 @@ V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8
if (isMuteBreakpointInstalled()) if (isMuteBreakpointInstalled())
return RequestContinue; return RequestContinue;
ScriptValue exception(scriptState, v8exception);
V8DebuggerAgentImpl::SkipPauseRequest result; V8DebuggerAgentImpl::SkipPauseRequest result;
if (m_skipAllPauses) if (m_skipAllPauses)
result = RequestContinue; result = RequestContinue;
else if (!hitBreakpoints.isEmpty()) else if (!hitBreakpoints.isEmpty())
result = RequestNoSkip; // Don't skip explicit breakpoints even if set in frameworks. result = RequestNoSkip; // Don't skip explicit breakpoints even if set in frameworks.
else if (!exception.isEmpty()) else if (!exception.IsEmpty())
result = shouldSkipExceptionPause(); result = shouldSkipExceptionPause();
else if (m_scheduledDebuggerStep != NoStep || m_javaScriptPauseScheduled || m_pausingOnNativeEvent) else if (m_scheduledDebuggerStep != NoStep || m_javaScriptPauseScheduled || m_pausingOnNativeEvent)
result = shouldSkipStepPause(); result = shouldSkipStepPause();
...@@ -1595,9 +1591,10 @@ V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8 ...@@ -1595,9 +1591,10 @@ V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8
ASSERT(!m_pausedScriptState); ASSERT(!m_pausedScriptState);
m_pausedScriptState = scriptState; m_pausedScriptState = scriptState;
m_currentCallStack.Reset(m_isolate, callFrames); m_currentCallStack.Reset(m_isolate, callFrames);
v8::HandleScope handles(m_isolate);
if (!exception.isEmpty()) { if (!exception.IsEmpty()) {
InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState); InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState->context());
if (injectedScript) { if (injectedScript) {
m_breakReason = isPromiseRejection ? InspectorFrontend::Debugger::Reason::PromiseRejection : InspectorFrontend::Debugger::Reason::Exception; m_breakReason = isPromiseRejection ? InspectorFrontend::Debugger::Reason::PromiseRejection : InspectorFrontend::Debugger::Reason::Exception;
m_breakAuxData = injectedScript->wrapObject(exception, V8DebuggerAgentImpl::backtraceObjectGroup)->openAccessors(); m_breakAuxData = injectedScript->wrapObject(exception, V8DebuggerAgentImpl::backtraceObjectGroup)->openAccessors();
......
...@@ -19,8 +19,8 @@ public: ...@@ -19,8 +19,8 @@ public:
virtual v8::Local<v8::Object> compileDebuggerScript() = 0; virtual v8::Local<v8::Object> compileDebuggerScript() = 0;
virtual void runMessageLoopOnPause(int contextGroupId) = 0; virtual void runMessageLoopOnPause(int contextGroupId) = 0;
virtual void quitMessageLoopOnPause() = 0; virtual void quitMessageLoopOnPause() = 0;
virtual void eventListeners(v8::Isolate*, v8::Local<v8::Value>, EventListenerInfoMap&) = 0; virtual void eventListeners(v8::Local<v8::Value>, EventListenerInfoMap&) = 0;
virtual bool canAccessContext(v8::Local<v8::Context>) = 0; virtual bool callingContextCanAccessContext(v8::Local<v8::Context>) = 0;
virtual v8::MaybeLocal<v8::Value> callFunction(v8::Local<v8::Function>, v8::Local<v8::Context>, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[]) = 0; virtual v8::MaybeLocal<v8::Value> callFunction(v8::Local<v8::Function>, v8::Local<v8::Context>, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[]) = 0;
}; };
......
...@@ -47,9 +47,10 @@ void V8InjectedScriptHost::inspectedObjectCallback(const v8::FunctionCallbackInf ...@@ -47,9 +47,10 @@ void V8InjectedScriptHost::inspectedObjectCallback(const v8::FunctionCallbackInf
return; return;
} }
InjectedScriptHost* host = V8InjectedScriptHost::unwrap(info.GetIsolate()->GetCurrentContext(), info.Holder()); v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
InjectedScriptHost* host = V8InjectedScriptHost::unwrap(context, info.Holder());
InjectedScriptHost::InspectableObject* object = host->inspectedObject(info[0].As<v8::Int32>()->Value()); InjectedScriptHost::InspectableObject* object = host->inspectedObject(info[0].As<v8::Int32>()->Value());
v8SetReturnValue(info, object->get(ScriptState::current(info.GetIsolate())).v8Value()); v8SetReturnValue(info, object->get(context));
} }
static v8::Local<v8::String> functionDisplayName(v8::Local<v8::Function> function) static v8::Local<v8::String> functionDisplayName(v8::Local<v8::Function> function)
...@@ -239,7 +240,7 @@ void V8InjectedScriptHost::getEventListenersCallback(const v8::FunctionCallbackI ...@@ -239,7 +240,7 @@ void V8InjectedScriptHost::getEventListenersCallback(const v8::FunctionCallbackI
InjectedScriptHost* host = V8InjectedScriptHost::unwrap(info.GetIsolate()->GetCurrentContext(), info.Holder()); InjectedScriptHost* host = V8InjectedScriptHost::unwrap(info.GetIsolate()->GetCurrentContext(), info.Holder());
V8DebuggerClient* client = static_cast<V8DebuggerImpl&>(host->debugger()).client(); V8DebuggerClient* client = static_cast<V8DebuggerImpl&>(host->debugger()).client();
EventListenerInfoMap listenerInfo; EventListenerInfoMap listenerInfo;
client->eventListeners(info.GetIsolate(), info[0], listenerInfo); client->eventListeners(info[0], listenerInfo);
v8::Local<v8::Object> result = v8::Object::New(info.GetIsolate()); v8::Local<v8::Object> result = v8::Object::New(info.GetIsolate());
Vector<String> types; Vector<String> types;
......
...@@ -11,13 +11,14 @@ ...@@ -11,13 +11,14 @@
#include "wtf/Forward.h" #include "wtf/Forward.h"
#include "wtf/Noncopyable.h" #include "wtf/Noncopyable.h"
#include <v8.h>
namespace blink { namespace blink {
class InjectedScript; class InjectedScript;
class InjectedScriptManager; class InjectedScriptManager;
class JSONArray; class JSONArray;
class JSONObject; class JSONObject;
class ScriptState;
class V8Debugger; class V8Debugger;
typedef String ErrorString; typedef String ErrorString;
...@@ -65,8 +66,8 @@ public: ...@@ -65,8 +66,8 @@ public:
virtual void setCustomObjectFormatterEnabled(ErrorString*, bool) = 0; virtual void setCustomObjectFormatterEnabled(ErrorString*, bool) = 0;
// Embedder callbacks. // Embedder callbacks.
virtual void reportExecutionContextCreated(ScriptState*, const String& type, const String& origin, const String& humanReadableName, const String& frameId) = 0; virtual void reportExecutionContextCreated(v8::Local<v8::Context>, const String& type, const String& origin, const String& humanReadableName, const String& frameId) = 0;
virtual void reportExecutionContextDestroyed(ScriptState*) = 0; virtual void reportExecutionContextDestroyed(v8::Local<v8::Context>) = 0;
}; };
} // namespace blink } // namespace blink
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "core/inspector/v8/V8RuntimeAgentImpl.h" #include "core/inspector/v8/V8RuntimeAgentImpl.h"
#include "bindings/core/v8/ScriptState.h"
#include "core/inspector/InjectedScript.h" #include "core/inspector/InjectedScript.h"
#include "core/inspector/InjectedScriptManager.h" #include "core/inspector/InjectedScriptManager.h"
#include "core/inspector/RemoteObjectId.h" #include "core/inspector/RemoteObjectId.h"
...@@ -207,11 +206,11 @@ void V8RuntimeAgentImpl::disable(ErrorString* errorString) ...@@ -207,11 +206,11 @@ void V8RuntimeAgentImpl::disable(ErrorString* errorString)
m_enabled = false; m_enabled = false;
} }
void V8RuntimeAgentImpl::reportExecutionContextCreated(ScriptState* scriptState, const String& type, const String& origin, const String& humanReadableName, const String& frameId) void V8RuntimeAgentImpl::reportExecutionContextCreated(v8::Local<v8::Context> context, const String& type, const String& origin, const String& humanReadableName, const String& frameId)
{ {
if (!m_enabled) if (!m_enabled)
return; return;
InjectedScript* injectedScript = injectedScriptManager()->injectedScriptFor(scriptState); InjectedScript* injectedScript = injectedScriptManager()->injectedScriptFor(context);
if (!injectedScript) if (!injectedScript)
return; return;
RefPtr<ExecutionContextDescription> description = ExecutionContextDescription::create() RefPtr<ExecutionContextDescription> description = ExecutionContextDescription::create()
...@@ -225,9 +224,9 @@ void V8RuntimeAgentImpl::reportExecutionContextCreated(ScriptState* scriptState, ...@@ -225,9 +224,9 @@ void V8RuntimeAgentImpl::reportExecutionContextCreated(ScriptState* scriptState,
} }
void V8RuntimeAgentImpl::reportExecutionContextDestroyed(ScriptState* scriptState) void V8RuntimeAgentImpl::reportExecutionContextDestroyed(v8::Local<v8::Context> context)
{ {
int contextId = injectedScriptManager()->discardInjectedScriptFor(scriptState); int contextId = injectedScriptManager()->discardInjectedScriptFor(context);
if (m_enabled) if (m_enabled)
m_frontend->executionContextDestroyed(contextId); m_frontend->executionContextDestroyed(contextId);
} }
......
...@@ -44,7 +44,6 @@ namespace blink { ...@@ -44,7 +44,6 @@ namespace blink {
class InjectedScript; class InjectedScript;
class InjectedScriptManager; class InjectedScriptManager;
class JSONArray; class JSONArray;
class ScriptState;
class V8DebuggerImpl; class V8DebuggerImpl;
typedef String ErrorString; typedef String ErrorString;
...@@ -93,8 +92,8 @@ public: ...@@ -93,8 +92,8 @@ public:
private: private:
InjectedScriptManager* injectedScriptManager() { return m_injectedScriptManager; } InjectedScriptManager* injectedScriptManager() { return m_injectedScriptManager; }
void reportExecutionContextCreated(ScriptState*, const String& type, const String& origin, const String& humanReadableName, const String& frameId) override; void reportExecutionContextCreated(v8::Local<v8::Context>, const String& type, const String& origin, const String& humanReadableName, const String& frameId) override;
void reportExecutionContextDestroyed(ScriptState*) override; void reportExecutionContextDestroyed(v8::Local<v8::Context>) override;
RefPtr<JSONObject> m_state; RefPtr<JSONObject> m_state;
InspectorFrontend::Runtime* m_frontend; InspectorFrontend::Runtime* m_frontend;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment