From 38152e7ee5c9daace6e192d9478ad01740defaee Mon Sep 17 00:00:00 2001 From: kozyatinskiy Date: Fri, 20 Nov 2015 11:41:58 -0800 Subject: [DevTools] Use JSFunction::GetDebugName V8 API for getting function name JSFunction::GetDebugName returns first of Function.displayName, Function.name, SharedFunctionInfo::name, inferred_name which is set and string. This function names is used in callstack sidebar on pause and in console message's callstack. R=pfeldman@chromium.org BUG=17356 Review URL: https://codereview.chromium.org/1455703002 Cr-Commit-Position: refs/heads/master@{#360884} --- ...tion-name-in-console-message-stack-expected.txt | 8 +++ .../function-name-in-console-message-stack.html | 49 ++++++++++++++++++ .../function-name-in-callstack-expected.txt | 11 ++++ .../debugger-pause/function-name-in-callstack.html | 59 ++++++++++++++++++++++ .../debugger/properties-special-expected.txt | 2 +- .../WebKit/Source/core/inspector/DebuggerScript.js | 15 +----- .../core/inspector/v8/V8InjectedScriptHost.cpp | 11 +--- 7 files changed, 131 insertions(+), 24 deletions(-) create mode 100644 third_party/WebKit/LayoutTests/inspector/console/function-name-in-console-message-stack-expected.txt create mode 100644 third_party/WebKit/LayoutTests/inspector/console/function-name-in-console-message-stack.html create mode 100644 third_party/WebKit/LayoutTests/inspector/sources/debugger-pause/function-name-in-callstack-expected.txt create mode 100644 third_party/WebKit/LayoutTests/inspector/sources/debugger-pause/function-name-in-callstack.html diff --git a/third_party/WebKit/LayoutTests/inspector/console/function-name-in-console-message-stack-expected.txt b/third_party/WebKit/LayoutTests/inspector/console/function-name-in-console-message-stack-expected.txt new file mode 100644 index 0000000..eee1aff --- /dev/null +++ b/third_party/WebKit/LayoutTests/inspector/console/function-name-in-console-message-stack-expected.txt @@ -0,0 +1,8 @@ +CONSOLE ERROR: line 8: Uncaught Error +Tests exception message contains stack with correct function name. + + function-name-in-console-message-stack.html:8 Uncaught Error +foo.displayName @ function-name-in-console-message-stack.html:8 +bar.displayName @ function-name-in-console-message-stack.html:16 +baz.function.name @ function-name-in-console-message-stack.html:23 + diff --git a/third_party/WebKit/LayoutTests/inspector/console/function-name-in-console-message-stack.html b/third_party/WebKit/LayoutTests/inspector/console/function-name-in-console-message-stack.html new file mode 100644 index 0000000..d222c30 --- /dev/null +++ b/third_party/WebKit/LayoutTests/inspector/console/function-name-in-console-message-stack.html @@ -0,0 +1,49 @@ + + + + + + + +

Tests exception message contains stack with correct function name.

+ + diff --git a/third_party/WebKit/LayoutTests/inspector/sources/debugger-pause/function-name-in-callstack-expected.txt b/third_party/WebKit/LayoutTests/inspector/sources/debugger-pause/function-name-in-callstack-expected.txt new file mode 100644 index 0000000..07494cc --- /dev/null +++ b/third_party/WebKit/LayoutTests/inspector/sources/debugger-pause/function-name-in-callstack-expected.txt @@ -0,0 +1,11 @@ +Tests that callFrames on pause contains function name taking into account displayName and Function.name. + +Set timer for test function. +Script execution paused. +callFrames.length = 4 +functionName: foo.displayName +functionName: bar.displayName +functionName: baz.function.name +functionName: testFunction +Script execution resumed. + diff --git a/third_party/WebKit/LayoutTests/inspector/sources/debugger-pause/function-name-in-callstack.html b/third_party/WebKit/LayoutTests/inspector/sources/debugger-pause/function-name-in-callstack.html new file mode 100644 index 0000000..0959900 --- /dev/null +++ b/third_party/WebKit/LayoutTests/inspector/sources/debugger-pause/function-name-in-callstack.html @@ -0,0 +1,59 @@ + + + + + + + + +

+Tests that callFrames on pause contains function name taking into account displayName and Function.name. +

+ + + diff --git a/third_party/WebKit/LayoutTests/inspector/sources/debugger/properties-special-expected.txt b/third_party/WebKit/LayoutTests/inspector/sources/debugger/properties-special-expected.txt index 427e428..bc4d62d 100644 --- a/third_party/WebKit/LayoutTests/inspector/sources/debugger/properties-special-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector/sources/debugger/properties-special-expected.txt @@ -14,7 +14,7 @@ properties-special.html:11 anonymous(a, b) prototype: Object __proto__: () -properties-special.html:12 anonymous() +properties-special.html:12 bound () arguments: (...) caller: (...) length: 1 diff --git a/third_party/WebKit/Source/core/inspector/DebuggerScript.js b/third_party/WebKit/Source/core/inspector/DebuggerScript.js index 9eb6285..fd1b976 100644 --- a/third_party/WebKit/Source/core/inspector/DebuggerScript.js +++ b/third_party/WebKit/Source/core/inspector/DebuggerScript.js @@ -87,7 +87,7 @@ DebuggerScript.getGeneratorObjectDetails = function(object) return null; var result = { "function": funcMirror.value(), - "functionName": DebuggerScript._displayFunctionName(funcMirror) || "", + "functionName": funcMirror.debugName(), "status": mirror.status() }; var script = funcMirror.script(); @@ -362,17 +362,6 @@ DebuggerScript.isEvalCompilation = function(eventData) return (script.compilationType() === Debug.ScriptCompilationType.Eval); } -DebuggerScript._displayFunctionName = function(funcMirror) -{ - if (!funcMirror.resolved()) - return undefined - var displayName; - var valueMirror = funcMirror.property("displayName").value(); - if (valueMirror && valueMirror.isString()) - displayName = valueMirror.value(); - return displayName || funcMirror.name() || funcMirror.inferredName(); -} - // NOTE: This function is performance critical, as it can be run on every // statement that generates an async event (like addEventListener) to support // asynchronous call stacks. Thus, when possible, initialize the data lazily. @@ -485,7 +474,7 @@ DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror, callerFrame, sc function functionName() { - return DebuggerScript._displayFunctionName(ensureFuncMirror()); + return ensureFuncMirror().debugName(); } function functionLine() diff --git a/third_party/WebKit/Source/core/inspector/v8/V8InjectedScriptHost.cpp b/third_party/WebKit/Source/core/inspector/v8/V8InjectedScriptHost.cpp index f1298a2..c6d33dc 100644 --- a/third_party/WebKit/Source/core/inspector/v8/V8InjectedScriptHost.cpp +++ b/third_party/WebKit/Source/core/inspector/v8/V8InjectedScriptHost.cpp @@ -66,18 +66,9 @@ void V8InjectedScriptHost::inspectedObjectCallback(const v8::FunctionCallbackInf static v8::Local functionDisplayName(v8::Local function) { - v8::Local value = function->GetDisplayName(); + v8::Local value = function->GetDebugName(); if (value->IsString() && v8::Local::Cast(value)->Length()) return v8::Local::Cast(value); - - value = function->GetName(); - if (value->IsString() && v8::Local::Cast(value)->Length()) - return v8::Local::Cast(value); - - value = function->GetInferredName(); - if (value->IsString() && v8::Local::Cast(value)->Length()) - return v8::Local::Cast(value); - return v8::Local(); } -- cgit v1.1