Web Inspector: function remote objetct should provide access to function position in the script
https://bugs.webkit.org/show_bug.cgi?id=71808
Source/JavaScriptCore:
Exposed accessor for function source code.
Reviewed by Pavel Feldman.
* JavaScriptCore.exp:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* runtime/JSFunction.cpp:
(JSC::JSFunction::sourceCode):
* runtime/JSFunction.h:
Source/WebCore:
Added Debugger.getFunctionLocation command for resolving function location including
start line, column and script id.
Reviewed by Pavel Feldman.
Test: inspector/debugger/function-location.html
* bindings/js/JSInjectedScriptHostCustom.cpp:
(WebCore::JSInjectedScriptHost::functionLocation):
* bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
(WebCore::V8InjectedScriptHost::functionLocationCallback):
* inspector/InjectedScript.cpp:
(WebCore::InjectedScript::getFunctionLocation):
* inspector/InjectedScript.h:
* inspector/InjectedScriptHost.idl:
* inspector/InjectedScriptSource.js:
(.):
* inspector/Inspector.json:
* inspector/InspectorDebuggerAgent.cpp:
(WebCore::InspectorDebuggerAgent::getFunctionLocation):
* inspector/InspectorDebuggerAgent.h:
LayoutTests:
Added test for Debugger.getFunctionLocation command.
Reviewed by Pavel Feldman.
* inspector/debugger/function-location-expected.txt: Added.
* inspector/debugger/function-location.html: Added.
* platform/chromium/inspector/debugger/function-location-expected.txt: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@100113 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/inspector/InjectedScript.cpp b/Source/WebCore/inspector/InjectedScript.cpp
index 95b12bb..c49f815 100644
--- a/Source/WebCore/inspector/InjectedScript.cpp
+++ b/Source/WebCore/inspector/InjectedScript.cpp
@@ -88,6 +88,20 @@
makeEvalCall(errorString, function, result, wasThrown);
}
+void InjectedScript::getFunctionLocation(ErrorString* errorString, const String& functionId, RefPtr<InspectorObject>* result)
+{
+ ScriptFunctionCall function(m_injectedScriptObject, "getFunctionLocation");
+ function.appendArgument(functionId);
+ RefPtr<InspectorValue> resultValue;
+ makeCall(function, &resultValue);
+ if (!resultValue || resultValue->type() != InspectorValue::TypeObject) {
+ if (!resultValue->asString(errorString))
+ *errorString = "Internal error";
+ return;
+ }
+ *result = resultValue->asObject();
+}
+
void InjectedScript::getProperties(ErrorString* errorString, const String& objectId, bool ownProperties, RefPtr<InspectorArray>* properties)
{
ScriptFunctionCall function(m_injectedScriptObject, "getProperties");