OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 WebInspector.ConsoleMessage.MessageSource.Other, | 111 WebInspector.ConsoleMessage.MessageSource.Other, |
112 messageLevel || WebInspector.ConsoleMessage.MessageLevel.Debug, | 112 messageLevel || WebInspector.ConsoleMessage.MessageLevel.Debug, |
113 messageText); | 113 messageText); |
114 | 114 |
115 this.addMessage(message); | 115 this.addMessage(message); |
116 if (showConsole) | 116 if (showConsole) |
117 this.show(); | 117 this.show(); |
118 }, | 118 }, |
119 | 119 |
120 /** | 120 /** |
121 * @param {string} error | |
122 */ | |
123 showErrorMessage: function(error) | |
124 { | |
125 this.log(error, WebInspector.ConsoleMessage.MessageLevel.Error, true); | |
126 }, | |
127 | |
128 /** | |
129 * @param {!WebInspector.ConsoleMessage} msg | 121 * @param {!WebInspector.ConsoleMessage} msg |
130 */ | 122 */ |
131 _incrementErrorWarningCount: function(msg) | 123 _incrementErrorWarningCount: function(msg) |
132 { | 124 { |
133 switch (msg.level) { | 125 switch (msg.level) { |
134 case WebInspector.ConsoleMessage.MessageLevel.Warning: | 126 case WebInspector.ConsoleMessage.MessageLevel.Warning: |
135 this.warnings++; | 127 this.warnings++; |
136 break; | 128 break; |
137 case WebInspector.ConsoleMessage.MessageLevel.Error: | 129 case WebInspector.ConsoleMessage.MessageLevel.Error: |
138 this.errors++; | 130 this.errors++; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 } | 178 } |
187 | 179 |
188 executionContext.evaluate(text, "console", useCommandLineAPI, false, false, true, printResult.bind(target.consoleModel)); | 180 executionContext.evaluate(text, "console", useCommandLineAPI, false, false, true, printResult.bind(target.consoleModel)); |
189 | 181 |
190 WebInspector.userMetrics.ConsoleEvaluated.record(); | 182 WebInspector.userMetrics.ConsoleEvaluated.record(); |
191 }, | 183 }, |
192 | 184 |
193 | 185 |
194 /** | 186 /** |
195 * @constructor | 187 * @constructor |
196 * @extends {WebInspector.TargetAware} | 188 * @param {?WebInspector.Target} target |
197 * @param {!WebInspector.Target} target | |
198 * @param {string} source | 189 * @param {string} source |
199 * @param {?string} level | 190 * @param {?string} level |
200 * @param {string} messageText | 191 * @param {string} messageText |
201 * @param {string=} type | 192 * @param {string=} type |
202 * @param {?string=} url | 193 * @param {?string=} url |
203 * @param {number=} line | 194 * @param {number=} line |
204 * @param {number=} column | 195 * @param {number=} column |
205 * @param {!NetworkAgent.RequestId=} requestId | 196 * @param {!NetworkAgent.RequestId=} requestId |
206 * @param {!Array.<!RuntimeAgent.RemoteObject>=} parameters | 197 * @param {!Array.<!RuntimeAgent.RemoteObject>=} parameters |
207 * @param {!Array.<!ConsoleAgent.CallFrame>=} stackTrace | 198 * @param {!Array.<!ConsoleAgent.CallFrame>=} stackTrace |
208 * @param {number=} timestamp | 199 * @param {number=} timestamp |
209 * @param {boolean=} isOutdated | 200 * @param {boolean=} isOutdated |
210 * @param {!RuntimeAgent.ExecutionContextId=} executionContextId | 201 * @param {!RuntimeAgent.ExecutionContextId=} executionContextId |
211 */ | 202 */ |
212 WebInspector.ConsoleMessage = function(target, source, level, messageText, type, url, line, column, requestId, parameters, stackTrace, timestamp, isOutdated, ex ecutionContextId) | 203 WebInspector.ConsoleMessage = function(target, source, level, messageText, type, url, line, column, requestId, parameters, stackTrace, timestamp, isOutdated, ex ecutionContextId) |
213 { | 204 { |
214 WebInspector.TargetAware.call(this, target); | 205 this._target = target; |
215 this.source = source; | 206 this.source = source; |
216 this.level = level; | 207 this.level = level; |
217 this.messageText = messageText; | 208 this.messageText = messageText; |
218 this.type = type || WebInspector.ConsoleMessage.MessageType.Log; | 209 this.type = type || WebInspector.ConsoleMessage.MessageType.Log; |
219 this.url = url || null; | 210 this.url = url || null; |
220 this.line = line || 0; | 211 this.line = line || 0; |
221 this.column = column || 0; | 212 this.column = column || 0; |
222 this.parameters = parameters; | 213 this.parameters = parameters; |
223 this.stackTrace = stackTrace; | 214 this.stackTrace = stackTrace; |
224 this.timestamp = timestamp || Date.now(); | 215 this.timestamp = timestamp || Date.now(); |
225 this.isOutdated = isOutdated; | 216 this.isOutdated = isOutdated; |
226 this.executionContextId = executionContextId || 0; | 217 this.executionContextId = executionContextId || 0; |
227 | 218 |
228 this.request = requestId ? target.networkLog.requestForId(requestId) : null; | 219 this.request = requestId ? target.networkLog.requestForId(requestId) : null; |
229 | 220 |
230 if (this.request) { | 221 if (this.request) { |
231 this.stackTrace = this.request.initiator.stackTrace; | 222 this.stackTrace = this.request.initiator.stackTrace; |
232 if (this.request.initiator && this.request.initiator.url) { | 223 if (this.request.initiator && this.request.initiator.url) { |
233 this.url = this.request.initiator.url; | 224 this.url = this.request.initiator.url; |
234 this.line = this.request.initiator.lineNumber; | 225 this.line = this.request.initiator.lineNumber; |
235 } | 226 } |
236 } | 227 } |
237 } | 228 } |
238 | 229 |
239 WebInspector.ConsoleMessage.prototype = { | 230 WebInspector.ConsoleMessage.prototype = { |
240 /** | 231 /** |
232 * @return {?WebInspector.Target} | |
233 */ | |
234 target: function() | |
235 { | |
236 return this._target; | |
237 }, | |
238 | |
239 /** | |
241 * @param {!WebInspector.ConsoleMessage} originatingMessage | 240 * @param {!WebInspector.ConsoleMessage} originatingMessage |
242 */ | 241 */ |
243 setOriginatingMessage: function(originatingMessage) | 242 setOriginatingMessage: function(originatingMessage) |
244 { | 243 { |
245 this._originatingConsoleMessage = originatingMessage; | 244 this._originatingConsoleMessage = originatingMessage; |
246 }, | 245 }, |
247 | 246 |
248 /** | 247 /** |
249 * @return {?WebInspector.ConsoleMessage} | 248 * @return {?WebInspector.ConsoleMessage} |
250 */ | 249 */ |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
337 | 336 |
338 return (this.target() === msg.target()) | 337 return (this.target() === msg.target()) |
339 && (this.source === msg.source) | 338 && (this.source === msg.source) |
340 && (this.type === msg.type) | 339 && (this.type === msg.type) |
341 && (this.level === msg.level) | 340 && (this.level === msg.level) |
342 && (this.line === msg.line) | 341 && (this.line === msg.line) |
343 && (this.url === msg.url) | 342 && (this.url === msg.url) |
344 && (this.messageText === msg.messageText) | 343 && (this.messageText === msg.messageText) |
345 && (this.request === msg.request) | 344 && (this.request === msg.request) |
346 && (this.executionContextId === msg.executionContextId); | 345 && (this.executionContextId === msg.executionContextId); |
347 }, | 346 } |
348 | |
349 __proto__: WebInspector.TargetAware.prototype | |
350 } | 347 } |
351 | 348 |
352 // Note: Keep these constants in sync with the ones in Console.h | 349 // Note: Keep these constants in sync with the ones in Console.h |
353 /** | 350 /** |
354 * @enum {string} | 351 * @enum {string} |
355 */ | 352 */ |
356 WebInspector.ConsoleMessage.MessageSource = { | 353 WebInspector.ConsoleMessage.MessageSource = { |
357 XML: "xml", | 354 XML: "xml", |
358 JS: "javascript", | 355 JS: "javascript", |
359 Network: "network", | 356 Network: "network", |
360 ConsoleAPI: "console-api", | 357 ConsoleAPI: "console-api", |
361 Storage: "storage", | 358 Storage: "storage", |
362 AppCache: "appcache", | 359 AppCache: "appcache", |
363 Rendering: "rendering", | 360 Rendering: "rendering", |
364 CSS: "css", | 361 CSS: "css", |
365 Security: "security", | 362 Security: "security", |
366 Other: "other", | 363 Other: "other", |
367 Deprecation: "deprecation" | 364 Deprecation: "deprecation" |
368 } | 365 } |
369 | 366 |
367 | |
368 /** | |
369 * @enum {string} | |
370 */ | |
371 WebInspector.ConsoleMessage.MessageLevel = { | |
sergeyv
2014/05/29 12:44:06
Why did you move it?
apavlov
2014/05/29 13:47:46
Oops, missed the original location...
| |
372 Log: "log", | |
373 Info: "info", | |
374 Warning: "warning", | |
375 Error: "error", | |
376 Debug: "debug" | |
377 } | |
378 | |
370 /** | 379 /** |
371 * @enum {string} | 380 * @enum {string} |
372 */ | 381 */ |
373 WebInspector.ConsoleMessage.MessageType = { | 382 WebInspector.ConsoleMessage.MessageType = { |
374 Log: "log", | 383 Log: "log", |
375 Dir: "dir", | 384 Dir: "dir", |
376 DirXML: "dirxml", | 385 DirXML: "dirxml", |
377 Table: "table", | 386 Table: "table", |
378 Trace: "trace", | 387 Trace: "trace", |
379 Clear: "clear", | 388 Clear: "clear", |
380 StartGroup: "startGroup", | 389 StartGroup: "startGroup", |
381 StartGroupCollapsed: "startGroupCollapsed", | 390 StartGroupCollapsed: "startGroupCollapsed", |
382 EndGroup: "endGroup", | 391 EndGroup: "endGroup", |
383 Assert: "assert", | 392 Assert: "assert", |
384 Result: "result", | 393 Result: "result", |
385 Profile: "profile", | 394 Profile: "profile", |
386 ProfileEnd: "profileEnd", | 395 ProfileEnd: "profileEnd", |
387 Command: "command" | 396 Command: "command" |
388 } | 397 } |
389 | 398 |
390 /** | 399 /** |
391 * @enum {string} | |
392 */ | |
393 WebInspector.ConsoleMessage.MessageLevel = { | |
394 Log: "log", | |
395 Info: "info", | |
396 Warning: "warning", | |
397 Error: "error", | |
398 Debug: "debug" | |
399 } | |
400 | |
401 /** | |
402 * @param {!WebInspector.ConsoleMessage} a | 400 * @param {!WebInspector.ConsoleMessage} a |
403 * @param {!WebInspector.ConsoleMessage} b | 401 * @param {!WebInspector.ConsoleMessage} b |
404 * @return number | 402 * @return {number} |
405 */ | 403 */ |
406 WebInspector.ConsoleMessage.timestampComparator = function (a, b) | 404 WebInspector.ConsoleMessage.timestampComparator = function (a, b) |
407 { | 405 { |
408 return a.timestamp - b.timestamp; | 406 return a.timestamp - b.timestamp; |
409 } | 407 } |
410 | 408 |
411 /** | 409 /** |
412 * @constructor | 410 * @constructor |
413 * @implements {ConsoleAgent.Dispatcher} | 411 * @implements {ConsoleAgent.Dispatcher} |
414 * @param {!WebInspector.ConsoleModel} console | 412 * @param {!WebInspector.ConsoleModel} console |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
453 { | 451 { |
454 if (!WebInspector.settings.preserveConsoleLog.get()) | 452 if (!WebInspector.settings.preserveConsoleLog.get()) |
455 this._console.clearMessages(); | 453 this._console.clearMessages(); |
456 } | 454 } |
457 } | 455 } |
458 | 456 |
459 /** | 457 /** |
460 * @type {!WebInspector.ConsoleModel} | 458 * @type {!WebInspector.ConsoleModel} |
461 */ | 459 */ |
462 WebInspector.console; | 460 WebInspector.console; |
OLD | NEW |