Skip to content
Permalink
Browse files
Web Inspector: Stack traces in console incorrectly show "(anonymous f…
…unction)" for global code

https://bugs.webkit.org/show_bug.cgi?id=152280

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-12-14
Reviewed by Brian Burg.

Source/WebInspectorUI:

* UserInterface/Images/Program.svg: Added.
* UserInterface/Images/gtk/Program.svg: Added.
Copied from TimelineRecordScriptEvaluated.svg.

* UserInterface/Models/CallFrame.js:
(WebInspector.CallFrame):
(WebInspector.CallFrame.prototype.get programCode):
Add a new property to check if this call frame is in program code.

(WebInspector.CallFrame.fromPayload):
Detect different sources of program code (global, eval, module).

* UserInterface/Views/CallFrameIcons.css:
(.program-icon .icon):
* UserInterface/Views/CallFrameView.js:
(WebInspector.CallFrameView.iconClassNameForCallFrame):
Give program code the [S] global script icon like in profiles.

LayoutTests:

* inspector/debugger/js-stacktrace-expected.txt:
* inspector/debugger/js-stacktrace.html:

Canonical link: https://commits.webkit.org/170395@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194083 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
JosephPecoraro authored and webkit-commit-queue committed Dec 15, 2015
1 parent 9f4c8cb commit 43a7e2e364ed4f58b1ea5e4ceb6d5af06ed21a40
@@ -1,3 +1,13 @@
2015-12-14 Joseph Pecoraro <pecoraro@apple.com>

Web Inspector: Stack traces in console incorrectly show "(anonymous function)" for global code
https://bugs.webkit.org/show_bug.cgi?id=152280

Reviewed by Brian Burg.

* inspector/debugger/js-stacktrace-expected.txt:
* inspector/debugger/js-stacktrace.html:

2015-12-14 Ryan Haddad <ryanhaddad@apple.com>

Marking storage/indexeddb/deleted-objects.html as a flaky crash on mac-wk1
@@ -6,13 +6,22 @@ console.trace():
"lineNumber": 15,
"columnNumber": 22,
"functionName": "typeError",
"nativeCode": false
"nativeCode": false,
"programCode": false
},
{
"lineNumber": 6,
"columnNumber": 21,
"functionName": "typeErrorWrap",
"nativeCode": false
"nativeCode": false,
"programCode": false
},
{
"lineNumber": null,
"columnNumber": null,
"functionName": "eval code",
"nativeCode": true,
"programCode": true
}
]

@@ -29,6 +38,12 @@ Error object:
"url": "/inspector/debugger/js-stacktrace.html",
"lineNumber": 7,
"columnNumber": 21
},
{
"functionName": "eval code",
"url": "",
"lineNumber": 0,
"columnNumber": 0
}
]

@@ -38,19 +53,29 @@ console.trace():
"lineNumber": 15,
"columnNumber": 22,
"functionName": "typeError",
"nativeCode": false
"nativeCode": false,
"programCode": false
},
{
"lineNumber": null,
"columnNumber": null,
"functionName": "map",
"nativeCode": true
"nativeCode": true,
"programCode": false
},
{
"lineNumber": 22,
"columnNumber": 20,
"functionName": "testWithNativeCallInBetween",
"nativeCode": false
"nativeCode": false,
"programCode": false
},
{
"lineNumber": null,
"columnNumber": null,
"functionName": "eval code",
"nativeCode": true,
"programCode": true
}
]

@@ -73,6 +98,12 @@ Error object:
"url": "/inspector/debugger/js-stacktrace.html",
"lineNumber": 23,
"columnNumber": 20
},
{
"functionName": "eval code",
"url": "",
"lineNumber": 0,
"columnNumber": 0
}
]

@@ -53,7 +53,8 @@
lineNumber: lineNumber,
columnNumber: columnNumber,
functionName: callFrame.functionName,
nativeCode: callFrame.nativeCode
nativeCode: callFrame.nativeCode,
programCode: callFrame.programCode,
});
}

@@ -112,9 +113,9 @@
{
var index = 0;
for (var frame of stackTrace) {
if (frame.nativeCode && frame.functionName === null)
break;
index++;
if (frame.nativeCode && frame.functionName === "eval code")
break;
}
return stackTrace.slice(0, index);
}
@@ -123,9 +124,9 @@
{
var index = 0;
for (var frame of payload) {
index++;
if (frame.functionName === "eval code")
break;
index++;
}
return payload.slice(0, index);
}
@@ -1,3 +1,28 @@
2015-12-14 Joseph Pecoraro <pecoraro@apple.com>

Web Inspector: Stack traces in console incorrectly show "(anonymous function)" for global code
https://bugs.webkit.org/show_bug.cgi?id=152280

Reviewed by Brian Burg.

* UserInterface/Images/Program.svg: Added.
* UserInterface/Images/gtk/Program.svg: Added.
Copied from TimelineRecordScriptEvaluated.svg.

* UserInterface/Models/CallFrame.js:
(WebInspector.CallFrame):
(WebInspector.CallFrame.prototype.get programCode):
Add a new property to check if this call frame is in program code.

(WebInspector.CallFrame.fromPayload):
Detect different sources of program code (global, eval, module).

* UserInterface/Views/CallFrameIcons.css:
(.program-icon .icon):
* UserInterface/Views/CallFrameView.js:
(WebInspector.CallFrameView.iconClassNameForCallFrame):
Give program code the [S] global script icon like in profiles.

2015-12-14 Joseph Pecoraro <pecoraro@apple.com>

Web Inspector: Copy message from console with a stack trace does not include source code locations
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -25,7 +25,7 @@

WebInspector.CallFrame = class CallFrame extends WebInspector.Object
{
constructor(id, sourceCodeLocation, functionName, thisObject, scopeChain, nativeCode)
constructor(id, sourceCodeLocation, functionName, thisObject, scopeChain, nativeCode, programCode)
{
super();

@@ -39,6 +39,7 @@ WebInspector.CallFrame = class CallFrame extends WebInspector.Object
this._thisObject = thisObject || null;
this._scopeChain = scopeChain || [];
this._nativeCode = nativeCode || false;
this._programCode = programCode || false;
}

// Public
@@ -63,6 +64,11 @@ WebInspector.CallFrame = class CallFrame extends WebInspector.Object
return this._nativeCode;
}

get programCode()
{
return this._programCode;
}

get thisObject()
{
return this._thisObject;
@@ -108,6 +114,7 @@ WebInspector.CallFrame = class CallFrame extends WebInspector.Object

var url = payload.url;
var nativeCode = false;
var programCode = false;
var sourceCodeLocation = null;

if (!url || url === "[native code]") {
@@ -125,10 +132,12 @@ WebInspector.CallFrame = class CallFrame extends WebInspector.Object
}
}

var functionName = null;
if (payload.functionName !== "global code" && payload.functionName !== "eval code")
functionName = payload.functionName;
var functionName = payload.functionName;
if (payload.functionName === "global code"
|| payload.functionName === "eval code"
|| payload.functionName === "module code")
programCode = true;

return new WebInspector.CallFrame(null, sourceCodeLocation, functionName, null, null, nativeCode);
return new WebInspector.CallFrame(null, sourceCodeLocation, functionName, null, null, nativeCode, programCode);
}
};
@@ -23,6 +23,10 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/

.program-icon .icon {
content: url(../Images/Program.svg);
}

.function-icon .icon {
content: url(../Images/Function.svg);
}
@@ -73,6 +73,9 @@ WebInspector.CallFrameView = class CallFrameView extends WebInspector.Object

static iconClassNameForCallFrame(callFrame)
{
if (callFrame.programCode)
return WebInspector.CallFrameView.ProgramIconStyleClassName;

// This is more than likely an event listener function with an "on" prefix and it is
// as long or longer than the shortest event listener name -- "oncut".
if (callFrame.functionName && callFrame.functionName.startsWith("on") && callFrame.functionName.length >= 5)
@@ -85,6 +88,7 @@ WebInspector.CallFrameView = class CallFrameView extends WebInspector.Object
}
};

WebInspector.CallFrameView.ProgramIconStyleClassName = "program-icon";
WebInspector.CallFrameView.FunctionIconStyleClassName = "function-icon";
WebInspector.CallFrameView.EventListenerIconStyleClassName = "event-listener-icon";
WebInspector.CallFrameView.NativeIconStyleClassName = "native-icon";

0 comments on commit 43a7e2e

Please sign in to comment.