bool eventListenerHandlerLocation(Document* document, EventListener* listener, String& sourceName, String& scriptId, int& lineNumber) { if (listener->type() != EventListener::JSEventListenerType) return false; v8::HandleScope scope(toIsolate(document)); V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>(listener); v8::Handle<v8::Context> context = toV8Context(document, v8Listener->world()); v8::Context::Scope contextScope(context); v8::Local<v8::Object> object = v8Listener->getListenerObject(document); if (object.IsEmpty()) return false; v8::Handle<v8::Function> function = eventListenerEffectiveFunction(scope.GetIsolate(), object); if (function.IsEmpty()) return false; v8::Handle<v8::Function> originalFunction = getBoundFunction(function); int scriptIdValue = originalFunction->ScriptId(); scriptId = String::number(scriptIdValue); v8::ScriptOrigin origin = originalFunction->GetScriptOrigin(); if (!origin.ResourceName().IsEmpty() && origin.ResourceName()->IsString()) sourceName = toCoreString(origin.ResourceName().As<v8::String>()); else sourceName = ""; lineNumber = originalFunction->GetScriptLineNumber(); return true; }
v8::Local<v8::Value> V8WorkerGlobalScopeEventListener::callListenerFunction(ExecutionContext* context, v8::Handle<v8::Value> jsEvent, Event* event) { v8::Local<v8::Function> handlerFunction = getListenerFunction(context); v8::Local<v8::Object> receiver = getReceiverObject(context, event); if (handlerFunction.IsEmpty() || receiver.IsEmpty()) return v8::Local<v8::Value>(); InspectorInstrumentationCookie cookie; if (InspectorInstrumentation::timelineAgentEnabled(context)) { String resourceName("undefined"); int lineNumber = 1; v8::Handle<v8::Function> originalFunction = getBoundFunction(handlerFunction); v8::ScriptOrigin origin = originalFunction->GetScriptOrigin(); if (!origin.ResourceName().IsEmpty()) { V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringResourceName, origin.ResourceName(), v8::Local<v8::Value>()); resourceName = stringResourceName; lineNumber = originalFunction->GetScriptLineNumber() + 1; } cookie = InspectorInstrumentation::willCallFunction(context, resourceName, lineNumber); } v8::Isolate* isolate = toIsolate(context); v8::Handle<v8::Value> parameters[1] = { jsEvent }; v8::Local<v8::Value> result = V8ScriptRunner::callFunction(handlerFunction, context, receiver, WTF_ARRAY_LENGTH(parameters), parameters, isolate); InspectorInstrumentation::didCallFunction(cookie); return result; }
v8::Local<v8::Value> ScriptController::callFunction(ExecutionContext* context, v8::Handle<v8::Function> function, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> info[], v8::Isolate* isolate) { InspectorInstrumentationCookie cookie; if (InspectorInstrumentation::timelineAgentEnabled(context)) { String resourceName; int lineNumber; if (!resourceInfo(getBoundFunction(function), resourceName, lineNumber)) return v8::Local<v8::Value>(); cookie = InspectorInstrumentation::willCallFunction(context, resourceName, lineNumber); } v8::Local<v8::Value> result = V8ScriptRunner::callFunction(function, context, receiver, argc, info, isolate); InspectorInstrumentation::didCallFunction(cookie); return result; }
void DevToolsFunctionInfo::ensureInitialized() const { if (m_function.IsEmpty()) return; v8::HandleScope scope(m_function->GetIsolate()); v8::Local<v8::Function> originalFunction = getBoundFunction(m_function); m_scriptId = originalFunction->ScriptId(); // v8::ScriptOrigin origin = originalFunction->GetScriptOrigin(); // if (!origin.ResourceName().IsEmpty()) { // V8StringResource<> stringResource(origin.ResourceName()); // stringResource.prepare(); // m_resourceName = stringResource; // m_lineNumber = originalFunction->GetScriptLineNumber() + 1; // } // if (m_resourceName.isEmpty()) { // m_resourceName = ""; // m_lineNumber = 1; // } m_resourceName = "FIXME"; m_lineNumber = 1; m_function.Clear(); }