summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp')
-rw-r--r--WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp55
1 files changed, 44 insertions, 11 deletions
diff --git a/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp b/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
index 054f9ba..4c091c8 100644
--- a/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
@@ -39,10 +39,14 @@
#include "InspectorController.h"
#include "Node.h"
#include "Page.h"
+#include "ScriptDebugServer.h"
#include "SerializedScriptValue.h"
#include "V8Binding.h"
+#include "V8BindingState.h"
+#include "V8DOMWindow.h"
#include "V8Database.h"
+#include "V8JavaScriptCallFrame.h"
#include "V8Node.h"
#include "V8Proxy.h"
#include "V8Storage.h"
@@ -59,7 +63,6 @@ static void WeakReferenceCallback(v8::Persistent<v8::Value> object, void* parame
static v8::Local<v8::Object> createInjectedScriptHostV8Wrapper(InjectedScriptHost* host)
{
- V8ClassIndex::V8WrapperType descriptorType = V8ClassIndex::INJECTEDSCRIPTHOST;
v8::Local<v8::Function> function = V8InjectedScriptHost::GetTemplate()->GetFunction();
if (function.IsEmpty()) {
// Return if allocation failed.
@@ -70,7 +73,7 @@ static v8::Local<v8::Object> createInjectedScriptHostV8Wrapper(InjectedScriptHos
// Avoid setting the wrapper if allocation failed.
return v8::Local<v8::Object>();
}
- V8DOMWrapper::setDOMWrapper(instance, V8ClassIndex::ToInt(descriptorType), host);
+ V8DOMWrapper::setDOMWrapper(instance, &V8InjectedScriptHost::info, host);
// Create a weak reference to the v8 wrapper of InspectorBackend to deref
// InspectorBackend when the wrapper is garbage collected.
host->ref();
@@ -79,7 +82,7 @@ static v8::Local<v8::Object> createInjectedScriptHostV8Wrapper(InjectedScriptHos
return instance;
}
-static ScriptObject createInjectedScript(const String& scriptSource, InjectedScriptHost* injectedScriptHost, ScriptState* inspectedScriptState, long id)
+ScriptObject InjectedScriptHost::createInjectedScript(const String& scriptSource, ScriptState* inspectedScriptState, long id)
{
v8::HandleScope scope;
@@ -90,7 +93,7 @@ static ScriptObject createInjectedScript(const String& scriptSource, InjectedScr
// instead of calling toV8() that would create the
// wrapper in the current context.
// FIXME: make it possible to use generic bindings factory for InjectedScriptHost.
- v8::Local<v8::Object> scriptHostWrapper = createInjectedScriptHostV8Wrapper(injectedScriptHost);
+ v8::Local<v8::Object> scriptHostWrapper = createInjectedScriptHostV8Wrapper(this);
if (scriptHostWrapper.IsEmpty())
return ScriptObject();
@@ -109,9 +112,10 @@ static ScriptObject createInjectedScript(const String& scriptSource, InjectedScr
v8::Handle<v8::Value> args[] = {
scriptHostWrapper,
windowGlobal,
- v8::Number::New(id)
+ v8::Number::New(id),
+ v8::String::New("v8")
};
- v8::Local<v8::Value> injectedScriptValue = v8::Function::Cast(*v)->Call(windowGlobal, 3, args);
+ v8::Local<v8::Value> injectedScriptValue = v8::Function::Cast(*v)->Call(windowGlobal, 4, args);
v8::Local<v8::Object> injectedScript(v8::Object::Cast(*injectedScriptValue));
return ScriptObject(inspectedScriptState, injectedScript);
}
@@ -151,6 +155,20 @@ v8::Handle<v8::Value> V8InjectedScriptHost::pushNodePathToFrontendCallback(const
return v8::Undefined();
}
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+v8::Handle<v8::Value> V8InjectedScriptHost::currentCallFrameCallback(const v8::Arguments& args)
+{
+ INC_STATS("InjectedScriptHost.currentCallFrame()");
+ return toV8(ScriptDebugServer::shared().currentCallFrame());
+}
+
+v8::Handle<v8::Value> V8InjectedScriptHost::isActivationCallback(const v8::Arguments& args)
+{
+ INC_STATS("InjectedScriptHost.isActivation()");
+ return v8::Boolean::New(true);
+}
+#endif
+
#if ENABLE(DATABASE)
v8::Handle<v8::Value> V8InjectedScriptHost::databaseForIdCallback(const v8::Arguments& args)
{
@@ -226,12 +244,27 @@ InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* inspectedScrip
return InjectedScript(ScriptObject(inspectedScriptState, v8::Local<v8::Object>::Cast(val)));
ASSERT(!m_injectedScriptSource.isEmpty());
- ScriptObject injectedScriptObject = createInjectedScript(m_injectedScriptSource, this, inspectedScriptState, m_nextInjectedScriptId);
- InjectedScript result(injectedScriptObject);
- m_idToInjectedScript.set(m_nextInjectedScriptId, result);
- ++m_nextInjectedScriptId;
- global->SetHiddenValue(key, injectedScriptObject.v8Object());
+ pair<long, ScriptObject> injectedScript = injectScript(m_injectedScriptSource, inspectedScriptState);
+ InjectedScript result(injectedScript.second);
+ m_idToInjectedScript.set(injectedScript.first, result);
+ global->SetHiddenValue(key, injectedScript.second.v8Object());
return result;
}
+bool InjectedScriptHost::canAccessInspectedWindow(ScriptState* scriptState)
+{
+ v8::HandleScope handleScope;
+ v8::Local<v8::Context> context = scriptState->context();
+ v8::Local<v8::Object> global = context->Global();
+ if (global.IsEmpty())
+ return false;
+ v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8DOMWindow::GetTemplate(), global);
+ if (holder.IsEmpty())
+ return false;
+ Frame* frame = V8DOMWindow::toNative(holder)->frame();
+
+ v8::Context::Scope contextScope(context);
+ return V8BindingSecurity::canAccessFrame(V8BindingState::Only(), frame, false);
+}
+
} // namespace WebCore