Diff
Modified: branches/safari-601-branch/LayoutTests/ChangeLog (193068 => 193069)
--- branches/safari-601-branch/LayoutTests/ChangeLog 2015-12-03 18:42:41 UTC (rev 193068)
+++ branches/safari-601-branch/LayoutTests/ChangeLog 2015-12-03 18:42:52 UTC (rev 193069)
@@ -1,3 +1,19 @@
+2015-12-02 Timothy Hatcher <[email protected]>
+
+ Merge r188017. rdar://problem/23221163
+
+ 2015-08-05 Nikita Vasilyev <[email protected]>
+
+ Web Inspector: Logging error objects should have a better UI
+ https://bugs.webkit.org/show_bug.cgi?id=143853
+
+ Add tests for stack trace format in case it changes.
+
+ Reviewed by Brian Burg.
+
+ * inspector/debugger/js-stacktrace-expected.txt: Added.
+ * inspector/debugger/js-stacktrace.html: Added.
+
2015-12-01 Timothy Hatcher <[email protected]>
Merge r187903. rdar://problem/23221163
Added: branches/safari-601-branch/LayoutTests/inspector/debugger/js-stacktrace-expected.txt (0 => 193069)
--- branches/safari-601-branch/LayoutTests/inspector/debugger/js-stacktrace-expected.txt (rev 0)
+++ branches/safari-601-branch/LayoutTests/inspector/debugger/js-stacktrace-expected.txt 2015-12-03 18:42:52 UTC (rev 193069)
@@ -0,0 +1,78 @@
+Test that the inspector can parse the stack trace format used by JSC for Error instances and console.trace.
+
+console.trace():
+[
+ {
+ "lineNumber": 15,
+ "columnNumber": 22,
+ "functionName": "typeError",
+ "nativeCode": false
+ },
+ {
+ "lineNumber": 6,
+ "columnNumber": 21,
+ "functionName": "typeErrorWrap",
+ "nativeCode": false
+ }
+]
+
+Error object:
+[
+ {
+ "functionName": "typeError",
+ "url": "/inspector/debugger/js-stacktrace.html",
+ "lineNumber": "14",
+ "columnNumber": "30"
+ },
+ {
+ "functionName": "typeErrorWrap",
+ "url": "/inspector/debugger/js-stacktrace.html",
+ "lineNumber": "7",
+ "columnNumber": "21"
+ }
+]
+
+console.trace():
+[
+ {
+ "lineNumber": 15,
+ "columnNumber": 22,
+ "functionName": "typeError",
+ "nativeCode": false
+ },
+ {
+ "lineNumber": null,
+ "columnNumber": null,
+ "functionName": "map",
+ "nativeCode": true
+ },
+ {
+ "lineNumber": 22,
+ "columnNumber": 20,
+ "functionName": "testWithNativeCallInBetween",
+ "nativeCode": false
+ }
+]
+
+Error object:
+[
+ {
+ "functionName": "typeError",
+ "url": "/inspector/debugger/js-stacktrace.html",
+ "lineNumber": "14",
+ "columnNumber": "30"
+ },
+ {
+ "functionName": "map",
+ "url": "[native code]",
+ "lineNumber": 0,
+ "columnNumber": 0
+ },
+ {
+ "functionName": "testWithNativeCallInBetween",
+ "url": "/inspector/debugger/js-stacktrace.html",
+ "lineNumber": "23",
+ "columnNumber": "20"
+ }
+]
+
Added: branches/safari-601-branch/LayoutTests/inspector/debugger/js-stacktrace.html (0 => 193069)
--- branches/safari-601-branch/LayoutTests/inspector/debugger/js-stacktrace.html (rev 0)
+++ branches/safari-601-branch/LayoutTests/inspector/debugger/js-stacktrace.html 2015-12-03 18:42:52 UTC (rev 193069)
@@ -0,0 +1,112 @@
+<html>
+<head>
+<script src=""
+<script>
+function typeErrorWrap()
+{
+ return typeError();
+}
+
+function typeError()
+{
+ var object = {};
+ try {
+ object.propertyDoesnt.exist;
+ } catch (e) {
+ console.trace();
+ return e.stack;
+ }
+}
+
+function testWithNativeCallInBetween()
+{
+ return [42].map(typeError)[0];
+}
+
+
+function test()
+{
+ WebInspector.logManager.addEventListener(WebInspector.LogManager.Event.MessageAdded, function(event) {
+ InspectorTest.log("\nconsole.trace():");
+
+ var stackTrace = [];
+ var callFramesBeforeEval = stripCallFramesAfterEval(event.data.message.stackTrace.callFrames);
+ for (var callFrame of callFramesBeforeEval) {
+ var lineNumber = callFrame.sourceCodeLocation ? callFrame.sourceCodeLocation.lineNumber : null;
+ var columnNumber = callFrame.sourceCodeLocation ? callFrame.sourceCodeLocation.columnNumber : null;
+ stackTrace.push({
+ lineNumber: lineNumber,
+ columnNumber: columnNumber,
+ functionName: callFrame.functionName,
+ nativeCode: callFrame.nativeCode
+ });
+ }
+
+ InspectorTest.log(JSON.stringify(stackTrace, null, 4));
+ });
+
+ InspectorTest.evaluateInPage("typeErrorWrap()", function(error, result) {
+ InspectorTest.log("\nError object:");
+
+ if (error)
+ InspectorTest.log(error);
+
+ var stackTrace = stripPayloadAfterEval(WebInspector.StackTrace._parseStackTrace(result.value));
+ stackTrace = stripFilePaths(stackTrace);
+
+ InspectorTest.log(JSON.stringify(stackTrace, null, 4));
+ InspectorTest.completeTest();
+ });
+
+ InspectorTest.evaluateInPage("testWithNativeCallInBetween()", function(error, result) {
+ InspectorTest.log("\nError object:");
+
+ if (error)
+ InspectorTest.log(error);
+
+ var stackTrace = stripPayloadAfterEval(WebInspector.StackTrace._parseStackTrace(result.value));
+ stackTrace = stripFilePaths(stackTrace);
+
+ InspectorTest.log(JSON.stringify(stackTrace, null, 4));
+ InspectorTest.completeTest();
+ });
+
+ function stripFilePaths(stackTrace)
+ {
+ for (var frame of stackTrace) {
+ if (typeof frame.url ="" "string")
+ frame.url = "" "");
+ }
+ return stackTrace;
+ }
+
+ function stripCallFramesAfterEval(stackTrace)
+ {
+ var index = 0;
+ for (var frame of stackTrace) {
+ if (frame.nativeCode && frame.functionName === null)
+ break;
+ index++;
+ }
+ return stackTrace.slice(0, index);
+ }
+
+ function stripPayloadAfterEval(payload)
+ {
+ var index = 0;
+ for (var frame of payload) {
+ if (frame.functionName === "eval code")
+ break;
+ index++;
+ }
+ return payload.slice(0, index);
+ }
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>
+Test that the inspector can parse the stack trace format used by JSC for Error instances and console.trace.<br>
+</p>
+</body>
+</html>
Modified: branches/safari-601-branch/Source/WebInspectorUI/ChangeLog (193068 => 193069)
--- branches/safari-601-branch/Source/WebInspectorUI/ChangeLog 2015-12-03 18:42:41 UTC (rev 193068)
+++ branches/safari-601-branch/Source/WebInspectorUI/ChangeLog 2015-12-03 18:42:52 UTC (rev 193069)
@@ -1,5 +1,94 @@
2015-12-02 Timothy Hatcher <[email protected]>
+ Merge r188017. rdar://problem/23221163
+
+ 2015-08-05 Nikita Vasilyev <[email protected]>
+
+ Web Inspector: Logging error objects should have a better UI
+ https://bugs.webkit.org/show_bug.cgi?id=143853
+
+ Previously, an error object looked like any other object, which wasn't very useful.
+ Source links couldn't be clicked and stacktraces were unreadable.
+
+ Unify console.trace, caught and uncaught exceptions. The following examples use
+ the same StaceTraceView:
+ - ({}).x.y
+ - try { ({}).x.y } catch (e) { console.log(e); }
+ - console.trace()
+
+ Reviewed by Brian Burg.
+
+ * UserInterface/Main.html:
+ * UserInterface/Models/CallFrame.js:
+ (WebInspector.CallFrame.fromPayload):
+ (WebInspector.CallFrame):
+ * UserInterface/Protocol/RemoteObject.js:
+ (WebInspector.RemoteObject.prototype.getOwnPropertyDescriptorsAsObject):
+ * UserInterface/Test.html:
+ * UserInterface/Views/CallFrameView.css:
+ (.call-frame .separator):
+ (.call-frame .subtitle .source-link): Deleted.
+ (.call-frame:focus .subtitle .source-link): Deleted.
+ (.call-frame .subtitle:empty): Deleted.
+ (.call-frame .subtitle): Deleted.
+ * UserInterface/Views/CallFrameView.js:
+ (WebInspector.CallFrameView):
+ - Start usind CallFrameView in stacktraces.
+ - Introduce showFunctionName optional argument. In stacktraces anonymous functions
+ are shown as "(anonymous function)" but in console message location
+ links (the ones on the right side of a console message) we omit them.
+ - Dash was a pseudo-element and it couldn't be copied to the clipboard.
+ Make it an actual HTML element.
+
+ * UserInterface/Views/ConsoleMessageView.css:
+ (.console-message-location.call-frame):
+ (.console-message-location.call-frame > .title):
+ (.console-message-location.call-frame > .subtitle > .source-link):
+ Since .call-frame rules are now used in stacktraces, move console message
+ specific rules from CallFrameView.css to ConsoleMessageView.css.
+
+ * UserInterface/Views/ConsoleMessageView.js:
+ (WebInspector.ConsoleMessageView.prototype._appendLocationLink):
+ (WebInspector.ConsoleMessageView.prototype._appendStackTrace):
+ (WebInspector.ConsoleMessageView.prototype._formatParameter):
+ (WebInspector.ConsoleMessageView.prototype._formatParameterAsError): Added.
+ Format errors differently from other objects.
+
+ * UserInterface/Views/ErrorObjectView.css: Added.
+ (.error-object::before):
+ (.error-object.expanded::before):
+ (.error-object-link-container):
+ (.error-object.expanded > .formatted-error > .error-object-link-container):
+ (.error-object:not(.expanded) .error-object-outline):
+ (.error-object-outline):
+ * UserInterface/Views/ErrorObjectView.js: Added.
+ (WebInspector.ErrorObjectView):
+ (WebInspector.ErrorObjectView.parseStackTrace):
+ (WebInspector.ErrorObjectView.makeSourceLinkWithPrefix):
+ (WebInspector.ErrorObjectView.prototype.get object):
+ (WebInspector.ErrorObjectView.prototype.get element):
+ (WebInspector.ErrorObjectView.prototype.get treeOutline):
+ (WebInspector.ErrorObjectView.prototype.get expanded):
+ (WebInspector.ErrorObjectView.prototype.update):
+ (WebInspector.ErrorObjectView.prototype.expand):
+ (WebInspector.ErrorObjectView.prototype.collapse):
+ (WebInspector.ErrorObjectView.prototype._handlePreviewOrTitleElementClick):
+ (WebInspector.ErrorObjectView.prototype._buildStackTrace):
+ ErrorObjectView is used to log caught exceptions, e.g.:
+ try { i.dont.exist++ } catch (e) { console.log(e) }
+
+ * UserInterface/Views/FormattedValue.js:
+ (WebInspector.FormattedValue.createElementForError): Added.
+ Create error preview.
+
+ (WebInspector.FormattedValue.createElementForTypesAndValue):
+ Fix typo.
+
+ (WebInspector.FormattedValue.createObjectPreviewOrFormattedValueForRemoteObject):
+ Format errors differently from other objects.
+
+2015-12-02 Timothy Hatcher <[email protected]>
+
Merge r188015. rdar://problem/23221163
2015-08-05 Matt Baker <[email protected]>
Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Main.html (193068 => 193069)
--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Main.html 2015-12-03 18:42:41 UTC (rev 193068)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Main.html 2015-12-03 18:42:52 UTC (rev 193069)
@@ -78,6 +78,7 @@
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
+ <link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
@@ -137,6 +138,7 @@
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
+ <link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
@@ -428,6 +430,7 @@
<script src=""
<script src=""
<script src=""
+ <script src=""
<script src=""
<script src=""
<script src=""
@@ -517,6 +520,7 @@
<script src=""
<script src=""
<script src=""
+ <script src=""
<script src=""
<script src=""
<script src=""
Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Models/CallFrame.js (193068 => 193069)
--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Models/CallFrame.js 2015-12-03 18:42:41 UTC (rev 193068)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Models/CallFrame.js 2015-12-03 18:42:52 UTC (rev 193069)
@@ -125,7 +125,9 @@
}
}
- var functionName = payload.functionName !== "global code" ? payload.functionName : null;
+ var functionName = null;
+ if (payload.functionName !== "global code" && payload.functionName !== "eval code")
+ functionName = payload.functionName;
return new WebInspector.CallFrame(null, sourceCodeLocation, functionName, null, null, nativeCode);
}
Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Models/StackTrace.js (193068 => 193069)
--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Models/StackTrace.js 2015-12-03 18:42:41 UTC (rev 193068)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Models/StackTrace.js 2015-12-03 18:42:52 UTC (rev 193069)
@@ -42,6 +42,48 @@
return new WebInspector.StackTrace(callFrames);
}
+ static fromString(stack)
+ {
+ var payload = WebInspector.StackTrace._parseStackTrace(stack);
+ return WebInspector.StackTrace.fromPayload(payload);
+ }
+
+ static _parseStackTrace(stack)
+ {
+ var lines = stack.split(/\n/g);
+ var result = [];
+
+ for (var line of lines) {
+ var functionName = "";
+ var url = ""
+ var lineNumber = 0;
+ var columnNumber = 0;
+
+ var index = line.indexOf("@");
+ if (index !== -1) {
+ functionName = line.slice(0, index);
+ url = "" + 1);
+
+ var columnIndex = url.lastIndexOf(":");
+ if (columnIndex !== -1) {
+ columnNumber = url.slice(columnIndex + 1);
+
+ url = "" columnIndex);
+ var lineIndex = url.lastIndexOf(":", columnIndex);
+ if (lineIndex !== -1) {
+ lineNumber = url.slice(lineIndex + 1, columnIndex);
+ url = "" lineIndex);
+ }
+ }
+ } else
+ functionName = line;
+
+ result.push({functionName, url, lineNumber, columnNumber});
+ }
+
+ return result;
+ }
+
// Public
get callFrames()
Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js (193068 => 193069)
--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js 2015-12-03 18:42:41 UTC (rev 193068)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js 2015-12-03 18:42:52 UTC (rev 193069)
@@ -535,6 +535,19 @@
RuntimeAgent.getProperties(this._objectId, ownProperties, true, this._getPropertyDescriptorsResolver.bind(this, callback));
}
+ getOwnPropertyDescriptorsAsObject(callback)
+ {
+ this.getOwnPropertyDescriptors(function(properties) {
+ var propertiesResult = {};
+ var internalPropertiesResult = {};
+ for (var propertyDescriptor of properties) {
+ var object = propertyDescriptor.isInternalProperty ? internalPropertiesResult : propertiesResult;
+ object[propertyDescriptor.name] = propertyDescriptor;
+ }
+ callback(propertiesResult, internalPropertiesResult);
+ });
+ }
+
_getPropertyDescriptorsResolver(callback, error, properties, internalProperties)
{
if (error) {
Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/CallFrameView.css (193068 => 193069)
--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/CallFrameView.css 2015-12-03 18:42:41 UTC (rev 193068)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/CallFrameView.css 2015-12-03 18:42:52 UTC (rev 193069)
@@ -40,24 +40,6 @@
display: inline-block;
}
-.call-frame .title {
- max-width: 20vw;
- overflow: hidden;
- text-overflow: ellipsis;
- display: inline-block;
-}
-
-.call-frame .source-link {
- max-width: 50vw;
- overflow: hidden;
- text-overflow: ellipsis;
- display: inline-block;
-}
-
-.call-frame .title + .subtitle > .source-link {
- max-width: 30vw;
-}
-
.call-frame .subtitle,
.call-frame .subtitle .source-link {
color: hsla(0, 0%, 0%, 0.6);
@@ -81,7 +63,7 @@
background-color: red;
}
-.call-frame .title + .subtitle::before {
- content: " — ";
- color: hsla(0, 0%, 0%, 0.4);
+.call-frame .separator {
+ white-space: nowrap;
+ color: hsla(0, 0%, 0%, 0.2);
}
Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/CallFrameView.js (193068 => 193069)
--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/CallFrameView.js 2015-12-03 18:42:41 UTC (rev 193068)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/CallFrameView.js 2015-12-03 18:42:52 UTC (rev 193069)
@@ -25,7 +25,7 @@
WebInspector.CallFrameView = class CallFrameView extends WebInspector.Object
{
- constructor(callFrame)
+ constructor(callFrame, showFunctionName)
{
console.assert(callFrame instanceof WebInspector.CallFrame);
@@ -40,32 +40,36 @@
WebInspector.linkifyElement(callFrameElement, sourceCodeLocation);
var linkElement = document.createElement("a");
- linkElement.className = "source-link";
+ linkElement.classList.add("source-link");
linkElement.href = ""
+
+ if (showFunctionName) {
+ var separatorElement = document.createElement("span");
+ separatorElement.classList.add("separator");
+ separatorElement.textContent = " — ";
+ subtitleElement.appendChild(separatorElement);
+ }
+
subtitleElement.appendChild(linkElement);
sourceCodeLocation.populateLiveDisplayLocationTooltip(linkElement);
sourceCodeLocation.populateLiveDisplayLocationString(linkElement, "textContent");
}
- if (callFrame.functionName) {
+ var titleElement = document.createElement("span");
+ titleElement.classList.add("title");
+
+ if (showFunctionName) {
var imgElement = document.createElement("img");
- imgElement.className = "icon";
- callFrameElement.appendChild(imgElement);
+ imgElement.classList.add("icon");
- var titlesElement = document.createElement("div");
- titlesElement.className = "titles";
- callFrameElement.appendChild(titlesElement);
+ titleElement.appendChild(imgElement);
+ titleElement.appendChild(document.createTextNode(callFrame.functionName || WebInspector.UIString("(anonymous function)")));
+ }
- var titleElement = document.createElement("span");
- titleElement.className = "title";
- titleElement.textContent = callFrame.functionName;
- titlesElement.appendChild(titleElement);
+ callFrameElement.appendChild(titleElement);
+ callFrameElement.appendChild(subtitleElement);
- titlesElement.appendChild(subtitleElement);
- } else
- callFrameElement.appendChild(subtitleElement);
-
return callFrameElement;
}
Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.css (193068 => 193069)
--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.css 2015-12-03 18:42:41 UTC (rev 193068)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.css 2015-12-03 18:42:52 UTC (rev 193069)
@@ -236,11 +236,27 @@
-webkit-user-select: text;
}
-.console-message .call-frame {
+.console-message-location.call-frame {
+ display: inline-block;
-webkit-user-select: text;
- height: 1.2em;
+ max-height: 16px;
+
+ max-width: 50vw;
+ overflow: hidden;
+ text-overflow: ellipsis;
}
+.console-message-location.call-frame > .title {
+ max-width: 20vw;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ display: inline-block;
+}
+
+.console-message-location.call-frame > .subtitle > .source-link {
+ max-width: 30vw;
+}
+
.console-message .go-to-link {
color: hsla(0, 0%, 0%, 0.6);
text-decoration: none;
Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js (193068 => 193069)
--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js 2015-12-03 18:42:41 UTC (rev 193068)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js 2015-12-03 18:42:52 UTC (rev 193069)
@@ -319,7 +319,8 @@
}
if (callFrame) {
- var locationElement = new WebInspector.CallFrameView(callFrame);
+ const showFunctionName = !!callFrame.functionName;
+ var locationElement = new WebInspector.CallFrameView(callFrame, showFunctionName);
locationElement.classList.add("console-message-location");
this._element.appendChild(locationElement);
@@ -377,18 +378,11 @@
if (this._message.type === WebInspector.ConsoleMessage.MessageType.Trace)
this.expand();
- this._stackTraceElement = this._element.appendChild(document.createElement("ul"));
- this._stackTraceElement.classList.add("console-message-stack-trace-container");
- this._stackTraceElement.classList.add("console-message-text");
+ this._stackTraceElement = this._element.appendChild(document.createElement("div"));
+ this._stackTraceElement.classList.add("console-message-text", "console-message-stack-trace-container");
- for (var callFrame of this._message.stackTrace.callFrames) {
- var callFrameElement = this._stackTraceElement.appendChild(document.createElement("li"));
- callFrameElement.classList.add("console-message-stack-trace-call-frame");
- callFrameElement.textContent = callFrame.functionName || WebInspector.UIString("(anonymous function)");
- var url = "" && callFrame.sourceCodeLocation.sourceCode && callFrame.sourceCodeLocation.sourceCode.url) || "";
- if (url && !this._shouldHideURL(url))
- callFrameElement.appendChild(this._linkifyCallFrame(callFrame));
- }
+ var callFramesElement = new WebInspector.StackTraceView(this._message.stackTrace).element;
+ this._stackTraceElement.appendChild(callFramesElement);
}
_createRemoteObjectIfNeeded(parameter)
@@ -486,7 +480,7 @@
var formatters = {
"object": this._formatParameterAsObject,
- "error": this._formatParameterAsObject,
+ "error": this._formatParameterAsError,
"map": this._formatParameterAsObject,
"set": this._formatParameterAsObject,
"weakmap": this._formatParameterAsObject,
@@ -527,6 +521,12 @@
element.appendChild(this._objectTree.element);
}
+ _formatParameterAsError(object, element)
+ {
+ var errorObjectView = new WebInspector.ErrorObjectView(object);
+ element.appendChild(errorObjectView.element);
+ }
+
_formatParameterAsArray(array, element)
{
this._objectTree = new WebInspector.ObjectTreeView(array, WebInspector.ObjectTreeView.Mode.Properties, this._rootPropertyPathForObject(array));
@@ -648,30 +648,6 @@
return WebInspector.linkifyLocation(url, lineNumber, columnNumber, "console-message-url");
}
- _linkifyCallFrameLocation(url, lineNumber, columnNumber)
- {
- // ConsoleMessage stack trace line numbers are one-based.
- lineNumber = lineNumber ? lineNumber - 1 : 0;
- columnNumber = columnNumber ? columnNumber - 1 : 0;
- return this._linkifyLocation(url, lineNumber, columnNumber);
- }
-
- _linkifyCallFrame(callFrame)
- {
- var url = ""
- var lineNumber = 0;
- var columnNumber = 0;
-
- var sourceCodeLocation = callFrame._sourceCodeLocation;
- if (sourceCodeLocation) {
- lineNumber = sourceCodeLocation.lineNumber;
- columnNumber = sourceCodeLocation.columnNumber;
- url = "" && sourceCodeLocation.sourceCode.url || "";
- }
-
- return this._linkifyCallFrameLocation(url, lineNumber, columnNumber);
- }
-
_userProvidedColumnNames(columnNamesArgument)
{
if (!columnNamesArgument)
Copied: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ErrorObjectView.css (from rev 193068, branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Models/StackTrace.js) (0 => 193069)
--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ErrorObjectView.css (rev 0)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ErrorObjectView.css 2015-12-03 18:42:52 UTC (rev 193069)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+.error-object::before {
+ display: inline-block;
+ vertical-align: baseline;
+ margin-bottom: -2px;
+ margin-right: 2px;
+ width: 13px;
+ height: 13px;
+ background-image: -webkit-canvas(navigation-sidebar-panel-disclosure-triangle-closed-normal);
+ background-size: 13px 13px;
+ background-repeat: no-repeat;
+ background-position: center;
+ content: "";
+}
+
+.error-object.expanded::before {
+ background-image: -webkit-canvas(navigation-sidebar-panel-disclosure-triangle-open-normal);
+}
+
+.error-object-link-container {
+ color: hsla(0, 0%, 0%, 0.2);
+}
+
+.error-object.expanded > .formatted-error > .error-object-link-container {
+ display: none;
+}
+
+.error-object:not(.expanded) .error-object-outline {
+ display: none;
+}
+
+.error-object-outline {
+ padding-left: 16px
+}
Added: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ErrorObjectView.js (0 => 193069)
--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ErrorObjectView.js (rev 0)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ErrorObjectView.js 2015-12-03 18:42:52 UTC (rev 193069)
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.ErrorObjectView = class ErrorObjectView extends WebInspector.Object
+{
+ constructor(object)
+ {
+ super();
+
+ console.assert(object instanceof WebInspector.RemoteObject && object.subtype === "error", object);
+
+ this._object = object;
+
+ this._element = document.createElement("div");
+ this._element.classList.add("error-object");
+ var previewElement = WebInspector.FormattedValue.createElementForError(this._object);
+ this._element.appendChild(previewElement);
+ previewElement.addEventListener("click", this._handlePreviewOrTitleElementClick.bind(this));
+
+ this._outlineElement = this._element.appendChild(document.createElement("div"));
+ this._outlineElement.classList.add("error-object-outline");
+ this._outline = new WebInspector.TreeOutline(this._outlineElement);
+ }
+
+ // Static
+
+ static makeSourceLinkWithPrefix(sourceURL, lineNumber, columnNumber)
+ {
+ if (!sourceURL)
+ return null;
+
+ var span = document.createElement("span");
+ span.classList.add("error-object-link-container");
+ span.textContent = " — ";
+
+ var a = WebInspector.linkifyLocation(sourceURL, parseInt(lineNumber) - 1, parseInt(columnNumber));
+ a.classList.add("error-object-link");
+ span.appendChild(a);
+
+ return span;
+ }
+
+ // Public
+
+ get object()
+ {
+ return this._object;
+ }
+
+ get element()
+ {
+ return this._element;
+ }
+
+ get treeOutline()
+ {
+ return this._outline;
+ }
+
+ get expanded()
+ {
+ return this._expanded;
+ }
+
+ update()
+ {
+ this._object.getOwnPropertyDescriptorsAsObject(function(properties) {
+ console.assert(properties && properties.stack && properties.stack.value);
+
+ if (!this._hasStackTrace)
+ this._buildStackTrace(properties.stack.value.value);
+
+ this._hasStackTrace = true;
+ }.bind(this));
+ }
+
+ expand()
+ {
+ if (this._expanded)
+ return;
+
+ this._expanded = true;
+ this._element.classList.add("expanded");
+
+ if (this._previewView)
+ this._previewView.showTitle();
+
+ this.update();
+ }
+
+ collapse()
+ {
+ if (!this._expanded)
+ return;
+
+ this._expanded = false;
+ this._element.classList.remove("expanded");
+
+ if (this._previewView)
+ this._previewView.showPreview();
+ }
+
+ // Private
+
+ _handlePreviewOrTitleElementClick(event)
+ {
+ if (!this._expanded)
+ this.expand();
+ else
+ this.collapse();
+
+ event.stopPropagation();
+ }
+
+ _buildStackTrace(stackString)
+ {
+ var stackTrace = WebInspector.StackTrace.fromString(stackString);
+ var stackTraceElement = new WebInspector.StackTraceView(stackTrace).element;
+ this._outlineElement.appendChild(stackTraceElement);
+ }
+};
Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js (193068 => 193069)
--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js 2015-12-03 18:42:41 UTC (rev 193068)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js 2015-12-03 18:42:52 UTC (rev 193069)
@@ -67,6 +67,33 @@
return span;
};
+WebInspector.FormattedValue.createElementForError = function(object)
+{
+ var span = document.createElement("span");
+ span.classList.add("formatted-error");
+ span.textContent = object.description;
+
+ if (!object.preview)
+ return span;
+
+ function previewToObject(preview)
+ {
+ var result = {};
+ for (var property of preview.propertyPreviews)
+ result[property.name] = property.value;
+
+ return result;
+ }
+
+ var preview = previewToObject(object.preview);
+ if (!preview.sourceURL)
+ return span;
+
+ var sourceLinkWithPrefix = WebInspector.ErrorObjectView.makeSourceLinkWithPrefix(preview.sourceURL, preview.line, preview.column);
+ span.appendChild(sourceLinkWithPrefix);
+ return span;
+};
+
WebInspector.FormattedValue.createElementForNodePreview = function(preview)
{
var value = preview.value;
@@ -145,7 +172,7 @@
return span;
}
- // Function: if class, show the description, otherwise ellide in previews.
+ // Function: if class, show the description, otherwise elide in previews.
if (type === "function") {
if (subtype === "class")
span.textContent = displayString;
@@ -187,6 +214,9 @@
if (object.subtype === "node")
return WebInspector.FormattedValue.createElementForNode(object);
+ if (object.subtype === "error")
+ return WebInspector.FormattedValue.createElementForError(object);
+
if (object.preview)
return new WebInspector.ObjectPreviewView(object.preview, previewViewMode);
Copied: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/StackTraceView.css (from rev 193068, branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Models/StackTrace.js) (0 => 193069)
--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/StackTraceView.css (rev 0)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/StackTraceView.css 2015-12-03 18:42:52 UTC (rev 193069)
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+.stack-trace > .call-frame {
+ margin: 1px 0;
+}
Copied: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/StackTraceView.js (from rev 193068, branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Models/StackTrace.js) (0 => 193069)
--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/StackTraceView.js (rev 0)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/StackTraceView.js 2015-12-03 18:42:52 UTC (rev 193069)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.StackTraceView = class StackTraceView extends WebInspector.Object
+{
+ constructor(stackTrace)
+ {
+ super();
+
+ var element = this._element = document.createElement("div");
+ element.classList.add("stack-trace");
+
+ for (var callFrame of stackTrace.callFrames) {
+ if (!callFrame.sourceCodeLocation && callFrame.functionName === null)
+ continue;
+
+ var callFrameElement = new WebInspector.CallFrameView(callFrame, true);
+ element.appendChild(callFrameElement);
+ }
+ }
+
+ get element()
+ {
+ return this._element;
+ }
+};