OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
4 * Copyright (C) 2009 Joseph Pecoraro | 4 * Copyright (C) 2009 Joseph Pecoraro |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 default: | 185 default: |
186 if (consoleMessage.parameters && consoleMessage.paramete
rs.length === 1 && consoleMessage.parameters[0].type === "string") | 186 if (consoleMessage.parameters && consoleMessage.paramete
rs.length === 1 && consoleMessage.parameters[0].type === "string") |
187 this._messageElement = this._tryFormatAsError(/**@t
ype {string} */(consoleMessage.parameters[0].value)); | 187 this._messageElement = this._tryFormatAsError(/**@t
ype {string} */(consoleMessage.parameters[0].value)); |
188 | 188 |
189 var args = consoleMessage.parameters || [consoleMessage.
messageText]; | 189 var args = consoleMessage.parameters || [consoleMessage.
messageText]; |
190 this._messageElement = this._messageElement || this._for
mat(args); | 190 this._messageElement = this._messageElement || this._for
mat(args); |
191 } | 191 } |
192 } else if (consoleMessage.source === WebInspector.ConsoleMessage.Mes
sageSource.Network) { | 192 } else if (consoleMessage.source === WebInspector.ConsoleMessage.Mes
sageSource.Network) { |
193 if (consoleMessage.request) { | 193 if (consoleMessage.request) { |
194 this._messageElement = createElement("span"); | 194 this._messageElement = createElement("span"); |
195 if (consoleMessage.level === WebInspector.ConsoleMessage.Mes
sageLevel.Error || consoleMessage.level === WebInspector.ConsoleMessage.MessageL
evel.RevokedError) { | 195 if (consoleMessage.level === WebInspector.ConsoleMessage.Mes
sageLevel.Error) { |
196 this._messageElement.createTextChildren(consoleMessage.r
equest.requestMethod, " "); | 196 this._messageElement.createTextChildren(consoleMessage.r
equest.requestMethod, " "); |
197 this._messageElement.appendChild(WebInspector.Linkifier.
linkifyUsingRevealer(consoleMessage.request, consoleMessage.request.url, console
Message.request.url)); | 197 this._messageElement.appendChild(WebInspector.Linkifier.
linkifyUsingRevealer(consoleMessage.request, consoleMessage.request.url, console
Message.request.url)); |
198 if (consoleMessage.request.failed) | 198 if (consoleMessage.request.failed) |
199 this._messageElement.createTextChildren(" ", console
Message.request.localizedFailDescription); | 199 this._messageElement.createTextChildren(" ", console
Message.request.localizedFailDescription); |
200 else | 200 else |
201 this._messageElement.createTextChildren(" ", String(
consoleMessage.request.statusCode), " (", consoleMessage.request.statusText, ")"
); | 201 this._messageElement.createTextChildren(" ", String(
consoleMessage.request.statusCode), " (", consoleMessage.request.statusText, ")"
); |
202 } else { | 202 } else { |
203 var fragment = WebInspector.linkifyStringAsFragmentWithC
ustomLinkifier(consoleMessage.messageText, linkifyRequest.bind(consoleMessage)); | 203 var fragment = WebInspector.linkifyStringAsFragmentWithC
ustomLinkifier(consoleMessage.messageText, linkifyRequest.bind(consoleMessage)); |
204 this._messageElement.appendChild(fragment); | 204 this._messageElement.appendChild(fragment); |
205 } | 205 } |
(...skipping 24 matching lines...) Expand all Loading... |
230 } | 230 } |
231 } | 231 } |
232 | 232 |
233 this._formattedMessage.appendChild(this._messageElement); | 233 this._formattedMessage.appendChild(this._messageElement); |
234 if (this._anchorElement) { | 234 if (this._anchorElement) { |
235 // Append a space to prevent the anchor text from being glued to the
console message when the user selects and copies the console messages. | 235 // Append a space to prevent the anchor text from being glued to the
console message when the user selects and copies the console messages. |
236 this._anchorElement.appendChild(createTextNode(" ")); | 236 this._anchorElement.appendChild(createTextNode(" ")); |
237 this._formattedMessage.insertBefore(this._anchorElement, this._forma
ttedMessage.firstChild); | 237 this._formattedMessage.insertBefore(this._anchorElement, this._forma
ttedMessage.firstChild); |
238 } | 238 } |
239 | 239 |
240 var dumpStackTrace = !!consoleMessage.stackTrace && consoleMessage.stack
Trace.length && (consoleMessage.source === WebInspector.ConsoleMessage.MessageSo
urce.Network || consoleMessage.level === WebInspector.ConsoleMessage.MessageLeve
l.Error || consoleMessage.level === WebInspector.ConsoleMessage.MessageLevel.Rev
okedError || consoleMessage.type === WebInspector.ConsoleMessage.MessageType.Tra
ce); | 240 var dumpStackTrace = !!consoleMessage.stackTrace && consoleMessage.stack
Trace.length && (consoleMessage.source === WebInspector.ConsoleMessage.MessageSo
urce.Network || consoleMessage.level === WebInspector.ConsoleMessage.MessageLeve
l.Error || consoleMessage.type === WebInspector.ConsoleMessage.MessageType.Trace
); |
241 if (dumpStackTrace) { | 241 if (dumpStackTrace) { |
242 var treeOutline = new TreeOutline(); | 242 var treeOutline = new TreeOutline(); |
243 treeOutline.element.classList.add("outline-disclosure", "outline-dis
closure-no-padding"); | 243 treeOutline.element.classList.add("outline-disclosure", "outline-dis
closure-no-padding"); |
244 var content = this._formattedMessage; | 244 var content = this._formattedMessage; |
245 var root = new TreeElement(content); | 245 var root = new TreeElement(content); |
246 root.toggleOnClick = true; | 246 root.toggleOnClick = true; |
247 root.selectable = false; | 247 root.selectable = false; |
248 content.treeElementForTest = root; | 248 content.treeElementForTest = root; |
249 treeOutline.appendChild(root); | 249 treeOutline.appendChild(root); |
250 if (consoleMessage.type === WebInspector.ConsoleMessage.MessageType.
Trace) | 250 if (consoleMessage.type === WebInspector.ConsoleMessage.MessageType.
Trace) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 { | 312 { |
313 var target = this._target(); | 313 var target = this._target(); |
314 if (!target) | 314 if (!target) |
315 return null; | 315 return null; |
316 // FIXME(62725): stack trace line/column numbers are one-based. | 316 // FIXME(62725): stack trace line/column numbers are one-based. |
317 lineNumber = lineNumber ? lineNumber - 1 : 0; | 317 lineNumber = lineNumber ? lineNumber - 1 : 0; |
318 columnNumber = columnNumber ? columnNumber - 1 : 0; | 318 columnNumber = columnNumber ? columnNumber - 1 : 0; |
319 return this._linkifier.linkifyScriptLocation(target, scriptId, url, line
Number, columnNumber, "console-message-url"); | 319 return this._linkifier.linkifyScriptLocation(target, scriptId, url, line
Number, columnNumber, "console-message-url"); |
320 }, | 320 }, |
321 | 321 |
| 322 /** |
| 323 * @return {boolean} |
| 324 */ |
| 325 isErrorOrWarning: function() |
| 326 { |
| 327 return (this._message.level === WebInspector.ConsoleMessage.MessageLevel
.Warning || this._message.level === WebInspector.ConsoleMessage.MessageLevel.Err
or); |
| 328 }, |
| 329 |
322 _format: function(parameters) | 330 _format: function(parameters) |
323 { | 331 { |
324 // This node is used like a Builder. Values are continually appended ont
o it. | 332 // This node is used like a Builder. Values are continually appended ont
o it. |
325 var formattedResult = createElement("span"); | 333 var formattedResult = createElement("span"); |
326 if (!parameters.length) | 334 if (!parameters.length) |
327 return formattedResult; | 335 return formattedResult; |
328 | 336 |
329 var target = this._target(); | 337 var target = this._target(); |
330 | 338 |
331 // Formatting code below assumes that parameters are all wrappers wherea
s frontend console | 339 // Formatting code below assumes that parameters are all wrappers wherea
s frontend console |
332 // API allows passing arbitrary values as messages (strings, numbers, et
c.). Wrap them here. | 340 // API allows passing arbitrary values as messages (strings, numbers, et
c.). Wrap them here. |
333 for (var i = 0; i < parameters.length; ++i) { | 341 for (var i = 0; i < parameters.length; ++i) { |
334 // FIXME: Only pass runtime wrappers here. | 342 // FIXME: Only pass runtime wrappers here. |
335 if (parameters[i] instanceof WebInspector.RemoteObject) | 343 if (parameters[i] instanceof WebInspector.RemoteObject) |
336 continue; | 344 continue; |
337 | 345 |
338 if (!target) { | 346 if (!target) { |
339 parameters[i] = WebInspector.RemoteObject.fromLocalObject(parame
ters[i]); | 347 parameters[i] = WebInspector.RemoteObject.fromLocalObject(parame
ters[i]); |
340 continue; | 348 continue; |
341 } | 349 } |
342 | 350 |
343 if (typeof parameters[i] === "object") | 351 if (typeof parameters[i] === "object") |
344 parameters[i] = target.runtimeModel.createRemoteObject(parameter
s[i]); | 352 parameters[i] = target.runtimeModel.createRemoteObject(parameter
s[i]); |
345 else | 353 else |
346 parameters[i] = target.runtimeModel.createRemoteObjectFromPrimit
iveValue(parameters[i]); | 354 parameters[i] = target.runtimeModel.createRemoteObjectFromPrimit
iveValue(parameters[i]); |
347 } | 355 } |
348 | 356 |
349 // There can be string log and string eval result. We distinguish betwee
n them based on message type. | 357 // There can be string log and string eval result. We distinguish betwee
n them based on message type. |
350 var shouldFormatMessage = WebInspector.RemoteObject.type(parameters[0])
=== "string" && (this._message.type !== WebInspector.ConsoleMessage.MessageType.
Result || this._message.level === WebInspector.ConsoleMessage.MessageLevel.Error
|| this._message.level === WebInspector.ConsoleMessage.MessageLevel.RevokedErro
r); | 358 var shouldFormatMessage = WebInspector.RemoteObject.type(parameters[0])
=== "string" && (this._message.type !== WebInspector.ConsoleMessage.MessageType.
Result || this._message.level === WebInspector.ConsoleMessage.MessageLevel.Error
); |
351 | 359 |
352 // Multiple parameters with the first being a format string. Save unused
substitutions. | 360 // Multiple parameters with the first being a format string. Save unused
substitutions. |
353 if (shouldFormatMessage) { | 361 if (shouldFormatMessage) { |
354 // Multiple parameters with the first being a format string. Save un
used substitutions. | 362 // Multiple parameters with the first being a format string. Save un
used substitutions. |
355 var result = this._formatWithSubstitutionString(parameters[0].descri
ption, parameters.slice(1), formattedResult); | 363 var result = this._formatWithSubstitutionString(parameters[0].descri
ption, parameters.slice(1), formattedResult); |
356 parameters = result.unusedSubstitutions; | 364 parameters = result.unusedSubstitutions; |
357 if (parameters.length) | 365 if (parameters.length) |
358 formattedResult.createTextChild(" "); | 366 formattedResult.createTextChild(" "); |
359 } | 367 } |
360 | 368 |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 }, | 937 }, |
930 | 938 |
931 /** | 939 /** |
932 * @return {!Element} | 940 * @return {!Element} |
933 */ | 941 */ |
934 toMessageElement: function() | 942 toMessageElement: function() |
935 { | 943 { |
936 if (this._wrapperElement) | 944 if (this._wrapperElement) |
937 return this._wrapperElement; | 945 return this._wrapperElement; |
938 | 946 |
939 this._wrapperElement = createElement("div"); | 947 this._wrapperElement = createElementWithClass("div", "console-message-wr
apper"); |
940 this.updateMessageElement(); | |
941 return this._wrapperElement; | |
942 }, | |
943 | |
944 updateMessageElement: function() | |
945 { | |
946 if (!this._wrapperElement) | |
947 return; | |
948 | |
949 this._wrapperElement.className = "console-message-wrapper"; | |
950 this._wrapperElement.removeChildren(); | |
951 | |
952 this._nestingLevelMarkers = []; | 948 this._nestingLevelMarkers = []; |
953 for (var i = 0; i < this._nestingLevel; ++i) | 949 for (var i = 0; i < this._nestingLevel; ++i) |
954 this._nestingLevelMarkers.push(this._wrapperElement.createChild("div
", "nesting-level-marker")); | 950 this._nestingLevelMarkers.push(this._wrapperElement.createChild("div
", "nesting-level-marker")); |
955 this._updateCloseGroupDecorations(); | 951 this._updateCloseGroupDecorations(); |
956 this._wrapperElement.message = this; | 952 this._wrapperElement.message = this; |
957 | 953 |
958 switch (this._message.level) { | 954 switch (this._message.level) { |
959 case WebInspector.ConsoleMessage.MessageLevel.Log: | 955 case WebInspector.ConsoleMessage.MessageLevel.Log: |
960 this._wrapperElement.classList.add("console-log-level"); | 956 this._wrapperElement.classList.add("console-log-level"); |
961 break; | 957 break; |
962 case WebInspector.ConsoleMessage.MessageLevel.Debug: | 958 case WebInspector.ConsoleMessage.MessageLevel.Debug: |
963 this._wrapperElement.classList.add("console-debug-level"); | 959 this._wrapperElement.classList.add("console-debug-level"); |
964 break; | 960 break; |
965 case WebInspector.ConsoleMessage.MessageLevel.Warning: | 961 case WebInspector.ConsoleMessage.MessageLevel.Warning: |
966 this._wrapperElement.classList.add("console-warning-level"); | 962 this._wrapperElement.classList.add("console-warning-level"); |
967 break; | 963 break; |
968 case WebInspector.ConsoleMessage.MessageLevel.Error: | 964 case WebInspector.ConsoleMessage.MessageLevel.Error: |
969 this._wrapperElement.classList.add("console-error-level"); | 965 this._wrapperElement.classList.add("console-error-level"); |
970 break; | 966 break; |
971 case WebInspector.ConsoleMessage.MessageLevel.RevokedError: | |
972 this._wrapperElement.classList.add("console-revokedError-level"); | |
973 break; | |
974 case WebInspector.ConsoleMessage.MessageLevel.Info: | 967 case WebInspector.ConsoleMessage.MessageLevel.Info: |
975 this._wrapperElement.classList.add("console-info-level"); | 968 this._wrapperElement.classList.add("console-info-level"); |
976 break; | 969 break; |
977 } | 970 } |
978 | 971 |
979 this._wrapperElement.appendChild(this.contentElement()); | 972 this._wrapperElement.appendChild(this.contentElement()); |
| 973 return this._wrapperElement; |
980 }, | 974 }, |
981 | 975 |
982 /** | 976 /** |
983 * @param {!TreeElement} parentTreeElement | 977 * @param {!TreeElement} parentTreeElement |
984 */ | 978 */ |
985 _populateStackTraceTreeElement: function(parentTreeElement) | 979 _populateStackTraceTreeElement: function(parentTreeElement) |
986 { | 980 { |
987 var target = this._target(); | 981 var target = this._target(); |
988 if (!target) | 982 if (!target) |
989 return; | 983 return; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 break; | 1099 break; |
1106 case WebInspector.ConsoleMessage.MessageLevel.Warning: | 1100 case WebInspector.ConsoleMessage.MessageLevel.Warning: |
1107 levelString = "Warning"; | 1101 levelString = "Warning"; |
1108 break; | 1102 break; |
1109 case WebInspector.ConsoleMessage.MessageLevel.Debug: | 1103 case WebInspector.ConsoleMessage.MessageLevel.Debug: |
1110 levelString = "Debug"; | 1104 levelString = "Debug"; |
1111 break; | 1105 break; |
1112 case WebInspector.ConsoleMessage.MessageLevel.Error: | 1106 case WebInspector.ConsoleMessage.MessageLevel.Error: |
1113 levelString = "Error"; | 1107 levelString = "Error"; |
1114 break; | 1108 break; |
1115 case WebInspector.ConsoleMessage.MessageLevel.RevokedError: | |
1116 levelString = "RevokedError"; | |
1117 break; | |
1118 case WebInspector.ConsoleMessage.MessageLevel.Info: | 1109 case WebInspector.ConsoleMessage.MessageLevel.Info: |
1119 levelString = "Info"; | 1110 levelString = "Info"; |
1120 break; | 1111 break; |
1121 } | 1112 } |
1122 | 1113 |
1123 return sourceString + " " + typeString + " " + levelString + ": " + this
.formattedMessage().textContent + "\n" + this._message.url + " line " + this._me
ssage.line; | 1114 return sourceString + " " + typeString + " " + levelString + ": " + this
.formattedMessage().textContent + "\n" + this._message.url + " line " + this._me
ssage.line; |
1124 }, | 1115 }, |
1125 | 1116 |
1126 get text() | 1117 get text() |
1127 { | 1118 { |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 { | 1287 { |
1297 if (!this._wrapperElement) { | 1288 if (!this._wrapperElement) { |
1298 WebInspector.ConsoleViewMessage.prototype.toMessageElement.call(this
); | 1289 WebInspector.ConsoleViewMessage.prototype.toMessageElement.call(this
); |
1299 this._wrapperElement.classList.toggle("collapsed", this._collapsed); | 1290 this._wrapperElement.classList.toggle("collapsed", this._collapsed); |
1300 } | 1291 } |
1301 return this._wrapperElement; | 1292 return this._wrapperElement; |
1302 }, | 1293 }, |
1303 | 1294 |
1304 __proto__: WebInspector.ConsoleViewMessage.prototype | 1295 __proto__: WebInspector.ConsoleViewMessage.prototype |
1305 } | 1296 } |
OLD | NEW |