Index: Source/bindings/v8/custom/V8InjectedScriptManager.cpp |
diff --git a/Source/bindings/v8/custom/V8InjectedScriptManager.cpp b/Source/bindings/v8/custom/V8InjectedScriptManager.cpp |
index 199b84cd120eeefbb4dd63614032b5c7dce8a3f0..cc880e48eba6def5ea85cea92be19e8d223002b8 100644 |
--- a/Source/bindings/v8/custom/V8InjectedScriptManager.cpp |
+++ b/Source/bindings/v8/custom/V8InjectedScriptManager.cpp |
@@ -37,6 +37,7 @@ |
#include "bindings/v8/ScriptDebugServer.h" |
#include "bindings/v8/ScriptObject.h" |
#include "bindings/v8/V8Binding.h" |
+#include "bindings/v8/V8HiddenPropertyName.h" |
#include "bindings/v8/V8ObjectConstructor.h" |
#include "bindings/v8/V8ScriptRunner.h" |
#include "core/inspector/InjectedScriptHost.h" |
@@ -82,6 +83,13 @@ ScriptObject InjectedScriptManager::createInjectedScript(const String& scriptSou |
if (scriptHostWrapper.IsEmpty()) |
return ScriptObject(); |
+ // Store the inspectedScriptState on the scriptHostWrapper if it is |
+ // different from the ScriptState associated with the context. |
+ // This is needed to support Dart as Dart does not create a separate V8 |
+ // context for every Dart library. |
+ if (inspectedScriptState != ScriptState::forContext(inspectedContext)) |
+ scriptHostWrapper->SetHiddenValue(V8HiddenPropertyName::scriptState(), v8::External::New(inspectedScriptState)); |
+ |
// Inject javascript into the context. The compiled script is supposed to evaluate into |
// a single anonymous function(it's anonymous to avoid cluttering the global object with |
// inspector's stuff) the function is called a few lines below with InjectedScriptHost wrapper, |
@@ -94,6 +102,7 @@ ScriptObject InjectedScriptManager::createInjectedScript(const String& scriptSou |
v8::Local<v8::Object> windowGlobal = inspectedContext->Global(); |
v8::Handle<v8::Value> args[] = { scriptHostWrapper, windowGlobal, v8::Number::New(id) }; |
v8::Local<v8::Value> injectedScriptValue = V8ScriptRunner::callInternalFunction(v8::Local<v8::Function>::Cast(value), windowGlobal, WTF_ARRAY_LENGTH(args), args, inspectedContext->GetIsolate()); |
+ |
return ScriptObject(inspectedScriptState, v8::Handle<v8::Object>::Cast(injectedScriptValue)); |
} |