| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 /** @type {!Map<number, !WebInspector.ConsoleMessage>} */ | 43 /** @type {!Map<number, !WebInspector.ConsoleMessage>} */ |
| 44 this._messageByExceptionId = new Map(); | 44 this._messageByExceptionId = new Map(); |
| 45 this._warnings = 0; | 45 this._warnings = 0; |
| 46 this._errors = 0; | 46 this._errors = 0; |
| 47 this._revokedErrors = 0; | 47 this._revokedErrors = 0; |
| 48 this._logAgent = logAgent; | 48 this._logAgent = logAgent; |
| 49 if (this._logAgent) { | 49 if (this._logAgent) { |
| 50 target.registerLogDispatcher(new WebInspector.LogDispatcher(this)); | 50 target.registerLogDispatcher(new WebInspector.LogDispatcher(this)); |
| 51 this._logAgent.enable(); | 51 this._logAgent.enable(); |
| 52 } | 52 } |
| 53 } | 53 }; |
| 54 | 54 |
| 55 /** @enum {symbol} */ | 55 /** @enum {symbol} */ |
| 56 WebInspector.ConsoleModel.Events = { | 56 WebInspector.ConsoleModel.Events = { |
| 57 ConsoleCleared: Symbol("ConsoleCleared"), | 57 ConsoleCleared: Symbol("ConsoleCleared"), |
| 58 MessageAdded: Symbol("MessageAdded"), | 58 MessageAdded: Symbol("MessageAdded"), |
| 59 MessageUpdated: Symbol("MessageUpdated"), | 59 MessageUpdated: Symbol("MessageUpdated"), |
| 60 CommandEvaluated: Symbol("CommandEvaluated") | 60 CommandEvaluated: Symbol("CommandEvaluated") |
| 61 } | 61 }; |
| 62 | 62 |
| 63 WebInspector.ConsoleModel.prototype = { | 63 WebInspector.ConsoleModel.prototype = { |
| 64 /** | 64 /** |
| 65 * @param {!WebInspector.ConsoleMessage} msg | 65 * @param {!WebInspector.ConsoleMessage} msg |
| 66 */ | 66 */ |
| 67 addMessage: function(msg) | 67 addMessage: function(msg) |
| 68 { | 68 { |
| 69 if (this._isBlacklisted(msg)) | 69 if (this._isBlacklisted(msg)) |
| 70 return; | 70 return; |
| 71 | 71 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 169 |
| 170 /** | 170 /** |
| 171 * @return {number} | 171 * @return {number} |
| 172 */ | 172 */ |
| 173 warnings: function() | 173 warnings: function() |
| 174 { | 174 { |
| 175 return this._warnings; | 175 return this._warnings; |
| 176 }, | 176 }, |
| 177 | 177 |
| 178 __proto__: WebInspector.SDKModel.prototype | 178 __proto__: WebInspector.SDKModel.prototype |
| 179 } | 179 }; |
| 180 | 180 |
| 181 /** | 181 /** |
| 182 * @param {!WebInspector.ExecutionContext} executionContext | 182 * @param {!WebInspector.ExecutionContext} executionContext |
| 183 * @param {string} text | 183 * @param {string} text |
| 184 * @param {boolean=} useCommandLineAPI | 184 * @param {boolean=} useCommandLineAPI |
| 185 */ | 185 */ |
| 186 WebInspector.ConsoleModel.evaluateCommandInConsole = function(executionContext,
text, useCommandLineAPI) | 186 WebInspector.ConsoleModel.evaluateCommandInConsole = function(executionContext,
text, useCommandLineAPI) |
| 187 { | 187 { |
| 188 var target = executionContext.target(); | 188 var target = executionContext.target(); |
| 189 var requestedText = text; | 189 var requestedText = text; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 } catch (e) { | 230 } catch (e) { |
| 231 return false; | 231 return false; |
| 232 } | 232 } |
| 233 } | 233 } |
| 234 | 234 |
| 235 if (looksLikeAnObjectLiteral(text)) | 235 if (looksLikeAnObjectLiteral(text)) |
| 236 text = "(" + text + ")"; | 236 text = "(" + text + ")"; |
| 237 | 237 |
| 238 executionContext.evaluate(text, "console", !!useCommandLineAPI, false, false
, true, true, printResult); | 238 executionContext.evaluate(text, "console", !!useCommandLineAPI, false, false
, true, true, printResult); |
| 239 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.Console
Evaluated); | 239 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.Console
Evaluated); |
| 240 } | 240 }; |
| 241 | 241 |
| 242 /** | 242 /** |
| 243 * @constructor | 243 * @constructor |
| 244 * @param {?WebInspector.Target} target | 244 * @param {?WebInspector.Target} target |
| 245 * @param {string} source | 245 * @param {string} source |
| 246 * @param {?string} level | 246 * @param {?string} level |
| 247 * @param {string} messageText | 247 * @param {string} messageText |
| 248 * @param {string=} type | 248 * @param {string=} type |
| 249 * @param {?string=} url | 249 * @param {?string=} url |
| 250 * @param {number=} line | 250 * @param {number=} line |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 if (this.request) { | 284 if (this.request) { |
| 285 var initiator = this.request.initiator(); | 285 var initiator = this.request.initiator(); |
| 286 if (initiator) { | 286 if (initiator) { |
| 287 this.stackTrace = initiator.stack || undefined; | 287 this.stackTrace = initiator.stack || undefined; |
| 288 if (initiator.url) { | 288 if (initiator.url) { |
| 289 this.url = initiator.url; | 289 this.url = initiator.url; |
| 290 this.line = initiator.lineNumber || 0; | 290 this.line = initiator.lineNumber || 0; |
| 291 } | 291 } |
| 292 } | 292 } |
| 293 } | 293 } |
| 294 } | 294 }; |
| 295 | 295 |
| 296 WebInspector.ConsoleMessage.prototype = { | 296 WebInspector.ConsoleMessage.prototype = { |
| 297 /** | 297 /** |
| 298 * @return {?WebInspector.Target} | 298 * @return {?WebInspector.Target} |
| 299 */ | 299 */ |
| 300 target: function() | 300 target: function() |
| 301 { | 301 { |
| 302 return this._target; | 302 return this._target; |
| 303 }, | 303 }, |
| 304 | 304 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 return false; | 427 return false; |
| 428 for (var i = 0, n = callFrames1.length; i < n; ++i) { | 428 for (var i = 0, n = callFrames1.length; i < n; ++i) { |
| 429 if (callFrames1[i].url !== callFrames2[i].url || | 429 if (callFrames1[i].url !== callFrames2[i].url || |
| 430 callFrames1[i].functionName !== callFrames2[i].functionName || | 430 callFrames1[i].functionName !== callFrames2[i].functionName || |
| 431 callFrames1[i].lineNumber !== callFrames2[i].lineNumber || | 431 callFrames1[i].lineNumber !== callFrames2[i].lineNumber || |
| 432 callFrames1[i].columnNumber !== callFrames2[i].columnNumber) | 432 callFrames1[i].columnNumber !== callFrames2[i].columnNumber) |
| 433 return false; | 433 return false; |
| 434 } | 434 } |
| 435 return this._isEqualStackTraces(stackTrace1.parent, stackTrace2.parent); | 435 return this._isEqualStackTraces(stackTrace1.parent, stackTrace2.parent); |
| 436 } | 436 } |
| 437 } | 437 }; |
| 438 | 438 |
| 439 // Note: Keep these constants in sync with the ones in Console.h | 439 // Note: Keep these constants in sync with the ones in Console.h |
| 440 /** | 440 /** |
| 441 * @enum {string} | 441 * @enum {string} |
| 442 */ | 442 */ |
| 443 WebInspector.ConsoleMessage.MessageSource = { | 443 WebInspector.ConsoleMessage.MessageSource = { |
| 444 XML: "xml", | 444 XML: "xml", |
| 445 JS: "javascript", | 445 JS: "javascript", |
| 446 Network: "network", | 446 Network: "network", |
| 447 ConsoleAPI: "console-api", | 447 ConsoleAPI: "console-api", |
| 448 Storage: "storage", | 448 Storage: "storage", |
| 449 AppCache: "appcache", | 449 AppCache: "appcache", |
| 450 Rendering: "rendering", | 450 Rendering: "rendering", |
| 451 CSS: "css", | 451 CSS: "css", |
| 452 Security: "security", | 452 Security: "security", |
| 453 Other: "other", | 453 Other: "other", |
| 454 Deprecation: "deprecation", | 454 Deprecation: "deprecation", |
| 455 Worker: "worker" | 455 Worker: "worker" |
| 456 } | 456 }; |
| 457 | 457 |
| 458 /** | 458 /** |
| 459 * @enum {string} | 459 * @enum {string} |
| 460 */ | 460 */ |
| 461 WebInspector.ConsoleMessage.MessageType = { | 461 WebInspector.ConsoleMessage.MessageType = { |
| 462 Log: "log", | 462 Log: "log", |
| 463 Debug: "debug", | 463 Debug: "debug", |
| 464 Info: "info", | 464 Info: "info", |
| 465 Error: "error", | 465 Error: "error", |
| 466 Warning: "warning", | 466 Warning: "warning", |
| 467 Dir: "dir", | 467 Dir: "dir", |
| 468 DirXML: "dirxml", | 468 DirXML: "dirxml", |
| 469 Table: "table", | 469 Table: "table", |
| 470 Trace: "trace", | 470 Trace: "trace", |
| 471 Clear: "clear", | 471 Clear: "clear", |
| 472 StartGroup: "startGroup", | 472 StartGroup: "startGroup", |
| 473 StartGroupCollapsed: "startGroupCollapsed", | 473 StartGroupCollapsed: "startGroupCollapsed", |
| 474 EndGroup: "endGroup", | 474 EndGroup: "endGroup", |
| 475 Assert: "assert", | 475 Assert: "assert", |
| 476 Result: "result", | 476 Result: "result", |
| 477 Profile: "profile", | 477 Profile: "profile", |
| 478 ProfileEnd: "profileEnd", | 478 ProfileEnd: "profileEnd", |
| 479 Command: "command" | 479 Command: "command" |
| 480 } | 480 }; |
| 481 | 481 |
| 482 /** | 482 /** |
| 483 * @enum {string} | 483 * @enum {string} |
| 484 */ | 484 */ |
| 485 WebInspector.ConsoleMessage.MessageLevel = { | 485 WebInspector.ConsoleMessage.MessageLevel = { |
| 486 Log: "log", | 486 Log: "log", |
| 487 Info: "info", | 487 Info: "info", |
| 488 Warning: "warning", | 488 Warning: "warning", |
| 489 Error: "error", | 489 Error: "error", |
| 490 Debug: "debug", | 490 Debug: "debug", |
| 491 RevokedError: "revokedError" // This is frontend-only level, used to put ex
ceptions to console. | 491 RevokedError: "revokedError" // This is frontend-only level, used to put ex
ceptions to console. |
| 492 }; | 492 }; |
| 493 | 493 |
| 494 /** | 494 /** |
| 495 * @param {!WebInspector.ConsoleMessage} a | 495 * @param {!WebInspector.ConsoleMessage} a |
| 496 * @param {!WebInspector.ConsoleMessage} b | 496 * @param {!WebInspector.ConsoleMessage} b |
| 497 * @return {number} | 497 * @return {number} |
| 498 */ | 498 */ |
| 499 WebInspector.ConsoleMessage.timestampComparator = function(a, b) | 499 WebInspector.ConsoleMessage.timestampComparator = function(a, b) |
| 500 { | 500 { |
| 501 return a.timestamp - b.timestamp; | 501 return a.timestamp - b.timestamp; |
| 502 } | 502 }; |
| 503 | 503 |
| 504 /** | 504 /** |
| 505 * @param {!RuntimeAgent.ExceptionDetails} exceptionDetails | 505 * @param {!RuntimeAgent.ExceptionDetails} exceptionDetails |
| 506 * @return {string} | 506 * @return {string} |
| 507 */ | 507 */ |
| 508 WebInspector.ConsoleMessage.simpleTextFromException = function(exceptionDetails) | 508 WebInspector.ConsoleMessage.simpleTextFromException = function(exceptionDetails) |
| 509 { | 509 { |
| 510 var text = exceptionDetails.text; | 510 var text = exceptionDetails.text; |
| 511 if (exceptionDetails.exception && exceptionDetails.exception.description) { | 511 if (exceptionDetails.exception && exceptionDetails.exception.description) { |
| 512 var description = exceptionDetails.exception.description; | 512 var description = exceptionDetails.exception.description; |
| 513 if (description.indexOf("\n") !== -1) | 513 if (description.indexOf("\n") !== -1) |
| 514 description = description.substring(0, description.indexOf("\n")); | 514 description = description.substring(0, description.indexOf("\n")); |
| 515 text += " " + description; | 515 text += " " + description; |
| 516 } | 516 } |
| 517 return text; | 517 return text; |
| 518 } | 518 }; |
| 519 | 519 |
| 520 /** | 520 /** |
| 521 * @param {!WebInspector.Target} target | 521 * @param {!WebInspector.Target} target |
| 522 * @param {!RuntimeAgent.ExceptionDetails} exceptionDetails | 522 * @param {!RuntimeAgent.ExceptionDetails} exceptionDetails |
| 523 * @param {string=} messageType | 523 * @param {string=} messageType |
| 524 * @param {number=} timestamp | 524 * @param {number=} timestamp |
| 525 * @param {string=} forceUrl | 525 * @param {string=} forceUrl |
| 526 * @return {!WebInspector.ConsoleMessage} | 526 * @return {!WebInspector.ConsoleMessage} |
| 527 */ | 527 */ |
| 528 WebInspector.ConsoleMessage.fromException = function(target, exceptionDetails, m
essageType, timestamp, forceUrl) | 528 WebInspector.ConsoleMessage.fromException = function(target, exceptionDetails, m
essageType, timestamp, forceUrl) |
| 529 { | 529 { |
| 530 return new WebInspector.ConsoleMessage( | 530 return new WebInspector.ConsoleMessage( |
| 531 target, | 531 target, |
| 532 WebInspector.ConsoleMessage.MessageSource.JS, | 532 WebInspector.ConsoleMessage.MessageSource.JS, |
| 533 WebInspector.ConsoleMessage.MessageLevel.Error, | 533 WebInspector.ConsoleMessage.MessageLevel.Error, |
| 534 WebInspector.ConsoleMessage.simpleTextFromException(exceptionDetails), | 534 WebInspector.ConsoleMessage.simpleTextFromException(exceptionDetails), |
| 535 messageType, | 535 messageType, |
| 536 forceUrl || exceptionDetails.url, | 536 forceUrl || exceptionDetails.url, |
| 537 exceptionDetails.lineNumber, | 537 exceptionDetails.lineNumber, |
| 538 exceptionDetails.columnNumber, | 538 exceptionDetails.columnNumber, |
| 539 undefined, | 539 undefined, |
| 540 exceptionDetails.exception ? [WebInspector.RemoteObject.fromLocalObject(
exceptionDetails.text), exceptionDetails.exception] : undefined, | 540 exceptionDetails.exception ? [WebInspector.RemoteObject.fromLocalObject(
exceptionDetails.text), exceptionDetails.exception] : undefined, |
| 541 exceptionDetails.stackTrace, | 541 exceptionDetails.stackTrace, |
| 542 timestamp, | 542 timestamp, |
| 543 exceptionDetails.executionContextId, | 543 exceptionDetails.executionContextId, |
| 544 exceptionDetails.scriptId); | 544 exceptionDetails.scriptId); |
| 545 } | 545 }; |
| 546 | 546 |
| 547 /** | 547 /** |
| 548 * @constructor | 548 * @constructor |
| 549 * @implements {LogAgent.Dispatcher} | 549 * @implements {LogAgent.Dispatcher} |
| 550 * @param {!WebInspector.ConsoleModel} console | 550 * @param {!WebInspector.ConsoleModel} console |
| 551 */ | 551 */ |
| 552 WebInspector.LogDispatcher = function(console) | 552 WebInspector.LogDispatcher = function(console) |
| 553 { | 553 { |
| 554 this._console = console; | 554 this._console = console; |
| 555 } | 555 }; |
| 556 | 556 |
| 557 WebInspector.LogDispatcher.prototype = { | 557 WebInspector.LogDispatcher.prototype = { |
| 558 /** | 558 /** |
| 559 * @override | 559 * @override |
| 560 * @param {!LogAgent.LogEntry} payload | 560 * @param {!LogAgent.LogEntry} payload |
| 561 */ | 561 */ |
| 562 entryAdded: function(payload) | 562 entryAdded: function(payload) |
| 563 { | 563 { |
| 564 var consoleMessage = new WebInspector.ConsoleMessage( | 564 var consoleMessage = new WebInspector.ConsoleMessage( |
| 565 this._console.target(), | 565 this._console.target(), |
| 566 payload.source, | 566 payload.source, |
| 567 payload.level, | 567 payload.level, |
| 568 payload.text, | 568 payload.text, |
| 569 undefined, | 569 undefined, |
| 570 payload.url, | 570 payload.url, |
| 571 payload.lineNumber, | 571 payload.lineNumber, |
| 572 undefined, | 572 undefined, |
| 573 payload.networkRequestId, | 573 payload.networkRequestId, |
| 574 undefined, | 574 undefined, |
| 575 payload.stackTrace, | 575 payload.stackTrace, |
| 576 payload.timestamp, | 576 payload.timestamp, |
| 577 undefined, | 577 undefined, |
| 578 undefined, | 578 undefined, |
| 579 payload.workerId); | 579 payload.workerId); |
| 580 this._console.addMessage(consoleMessage); | 580 this._console.addMessage(consoleMessage); |
| 581 } | 581 } |
| 582 } | 582 }; |
| 583 | 583 |
| 584 /** | 584 /** |
| 585 * @constructor | 585 * @constructor |
| 586 * @extends {WebInspector.Object} | 586 * @extends {WebInspector.Object} |
| 587 * @implements {WebInspector.TargetManager.Observer} | 587 * @implements {WebInspector.TargetManager.Observer} |
| 588 */ | 588 */ |
| 589 WebInspector.MultitargetConsoleModel = function() | 589 WebInspector.MultitargetConsoleModel = function() |
| 590 { | 590 { |
| 591 WebInspector.targetManager.observeTargets(this); | 591 WebInspector.targetManager.observeTargets(this); |
| 592 WebInspector.targetManager.addModelListener(WebInspector.ConsoleModel, WebIn
spector.ConsoleModel.Events.MessageAdded, this._consoleMessageAdded, this); | 592 WebInspector.targetManager.addModelListener(WebInspector.ConsoleModel, WebIn
spector.ConsoleModel.Events.MessageAdded, this._consoleMessageAdded, this); |
| 593 WebInspector.targetManager.addModelListener(WebInspector.ConsoleModel, WebIn
spector.ConsoleModel.Events.MessageUpdated, this._consoleMessageUpdated, this); | 593 WebInspector.targetManager.addModelListener(WebInspector.ConsoleModel, WebIn
spector.ConsoleModel.Events.MessageUpdated, this._consoleMessageUpdated, this); |
| 594 WebInspector.targetManager.addModelListener(WebInspector.ConsoleModel, WebIn
spector.ConsoleModel.Events.CommandEvaluated, this._commandEvaluated, this); | 594 WebInspector.targetManager.addModelListener(WebInspector.ConsoleModel, WebIn
spector.ConsoleModel.Events.CommandEvaluated, this._commandEvaluated, this); |
| 595 } | 595 }; |
| 596 | 596 |
| 597 WebInspector.MultitargetConsoleModel.prototype = { | 597 WebInspector.MultitargetConsoleModel.prototype = { |
| 598 /** | 598 /** |
| 599 * @override | 599 * @override |
| 600 * @param {!WebInspector.Target} target | 600 * @param {!WebInspector.Target} target |
| 601 */ | 601 */ |
| 602 targetAdded: function(target) | 602 targetAdded: function(target) |
| 603 { | 603 { |
| 604 if (!this._mainTarget) { | 604 if (!this._mainTarget) { |
| 605 this._mainTarget = target; | 605 this._mainTarget = target; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 | 654 |
| 655 /** | 655 /** |
| 656 * @param {!WebInspector.Event} event | 656 * @param {!WebInspector.Event} event |
| 657 */ | 657 */ |
| 658 _commandEvaluated: function(event) | 658 _commandEvaluated: function(event) |
| 659 { | 659 { |
| 660 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.CommandEv
aluated, event.data); | 660 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.CommandEv
aluated, event.data); |
| 661 }, | 661 }, |
| 662 | 662 |
| 663 __proto__: WebInspector.Object.prototype | 663 __proto__: WebInspector.Object.prototype |
| 664 } | 664 }; |
| 665 | 665 |
| 666 /** | 666 /** |
| 667 * @type {!WebInspector.MultitargetConsoleModel} | 667 * @type {!WebInspector.MultitargetConsoleModel} |
| 668 */ | 668 */ |
| 669 WebInspector.multitargetConsoleModel; | 669 WebInspector.multitargetConsoleModel; |
| OLD | NEW |