| Index: Source/devtools/front_end/sdk/ConsoleModel.js
|
| diff --git a/Source/devtools/front_end/sdk/ConsoleModel.js b/Source/devtools/front_end/sdk/ConsoleModel.js
|
| index f658ef6a7a89bb76a3c65478049fba2ed88a3156..66dec2279101e10e41486cbbebaedaf41671f608 100644
|
| --- a/Source/devtools/front_end/sdk/ConsoleModel.js
|
| +++ b/Source/devtools/front_end/sdk/ConsoleModel.js
|
| @@ -39,8 +39,11 @@ WebInspector.ConsoleModel = function(target)
|
|
|
| /** @type {!Array.<!WebInspector.ConsoleMessage>} */
|
| this._messages = [];
|
| - this.warnings = 0;
|
| - this.errors = 0;
|
| + /** @type {!Map<number, !WebInspector.ConsoleMessage>} */
|
| + this._messageById = new Map();
|
| + this._warnings = 0;
|
| + this._errors = 0;
|
| + this._revokedErrors = 0;
|
| this._consoleAgent = target.consoleAgent();
|
| target.registerConsoleDispatcher(new WebInspector.ConsoleDispatcher(this));
|
| this._enableAgent();
|
| @@ -49,6 +52,7 @@ WebInspector.ConsoleModel = function(target)
|
| WebInspector.ConsoleModel.Events = {
|
| ConsoleCleared: "ConsoleCleared",
|
| MessageAdded: "MessageAdded",
|
| + MessageUpdated: "MessageUpdated",
|
| CommandEvaluated: "CommandEvaluated",
|
| }
|
|
|
| @@ -72,10 +76,21 @@ WebInspector.ConsoleModel.prototype = {
|
| */
|
| addMessage: function(msg)
|
| {
|
| - msg.index = this._messages.length;
|
| + if (msg.level === WebInspector.ConsoleMessage.MessageLevel.RevokedError && msg._relatedMessageId) {
|
| + var relatedMessage = this._messageById.get(msg._relatedMessageId);
|
| + if (!relatedMessage)
|
| + return;
|
| + this._errors--;
|
| + this._revokedErrors++;
|
| + relatedMessage.level = WebInspector.ConsoleMessage.MessageLevel.RevokedError;
|
| + this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.MessageUpdated, relatedMessage);
|
| + return;
|
| + }
|
| +
|
| this._messages.push(msg);
|
| + if (msg._messageId)
|
| + this._messageById.set(msg._messageId, msg);
|
| this._incrementErrorWarningCount(msg);
|
| -
|
| this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.MessageAdded, msg);
|
| },
|
|
|
| @@ -86,10 +101,13 @@ WebInspector.ConsoleModel.prototype = {
|
| {
|
| switch (msg.level) {
|
| case WebInspector.ConsoleMessage.MessageLevel.Warning:
|
| - this.warnings++;
|
| + this._warnings++;
|
| break;
|
| case WebInspector.ConsoleMessage.MessageLevel.Error:
|
| - this.errors++;
|
| + this._errors++;
|
| + break;
|
| + case WebInspector.ConsoleMessage.MessageLevel.RevokedError:
|
| + this._revokedErrors++;
|
| break;
|
| }
|
| },
|
| @@ -111,11 +129,37 @@ WebInspector.ConsoleModel.prototype = {
|
| _messagesCleared: function()
|
| {
|
| this._messages = [];
|
| - this.errors = 0;
|
| - this.warnings = 0;
|
| + this._messageById.clear();
|
| + this._errors = 0;
|
| + this._revokedErrors = 0;
|
| + this._warnings = 0;
|
| this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.ConsoleCleared);
|
| },
|
|
|
| + /**
|
| + * @return {number}
|
| + */
|
| + errors: function()
|
| + {
|
| + return this._errors;
|
| + },
|
| +
|
| + /**
|
| + * @return {number}
|
| + */
|
| + revokedErrors: function()
|
| + {
|
| + return this._revokedErrors;
|
| + },
|
| +
|
| + /**
|
| + * @return {number}
|
| + */
|
| + warnings: function()
|
| + {
|
| + return this._warnings;
|
| + },
|
| +
|
| __proto__: WebInspector.SDKModel.prototype
|
| }
|
|
|
| @@ -174,8 +218,10 @@ WebInspector.ConsoleModel.evaluateCommandInConsole = function(executionContext,
|
| * @param {!RuntimeAgent.ExecutionContextId=} executionContextId
|
| * @param {!ConsoleAgent.AsyncStackTrace=} asyncStackTrace
|
| * @param {?string=} scriptId
|
| + * @param {number=} messageId
|
| + * @param {number=} relatedMessageId
|
| */
|
| -WebInspector.ConsoleMessage = function(target, source, level, messageText, type, url, line, column, requestId, parameters, stackTrace, timestamp, executionContextId, asyncStackTrace, scriptId)
|
| +WebInspector.ConsoleMessage = function(target, source, level, messageText, type, url, line, column, requestId, parameters, stackTrace, timestamp, executionContextId, asyncStackTrace, scriptId, messageId, relatedMessageId)
|
| {
|
| this._target = target;
|
| this.source = source;
|
| @@ -195,6 +241,8 @@ WebInspector.ConsoleMessage = function(target, source, level, messageText, type,
|
| this.executionContextId = executionContextId || 0;
|
| this.asyncStackTrace = asyncStackTrace;
|
| this.scriptId = scriptId || null;
|
| + this._messageId = messageId || 0;
|
| + this._relatedMessageId = relatedMessageId || 0;
|
|
|
| this.request = requestId ? target.networkLog.requestForId(requestId) : null;
|
|
|
| @@ -273,29 +321,6 @@ WebInspector.ConsoleMessage.prototype = {
|
| },
|
|
|
| /**
|
| - * @return {!WebInspector.ConsoleMessage}
|
| - */
|
| - clone: function()
|
| - {
|
| - return new WebInspector.ConsoleMessage(
|
| - this.target(),
|
| - this.source,
|
| - this.level,
|
| - this.messageText,
|
| - this.type,
|
| - this.url,
|
| - this.line,
|
| - this.column,
|
| - this.request ? this.request.requestId : undefined,
|
| - this.parameters,
|
| - this.stackTrace,
|
| - this.timestamp,
|
| - this.executionContextId,
|
| - this.asyncStackTrace,
|
| - this.scriptId);
|
| - },
|
| -
|
| - /**
|
| * @param {?WebInspector.ConsoleMessage} msg
|
| * @return {boolean}
|
| */
|
| @@ -304,6 +329,11 @@ WebInspector.ConsoleMessage.prototype = {
|
| if (!msg)
|
| return false;
|
|
|
| + if (this._messageId || msg._messageId)
|
| + return false;
|
| + if (this._relatedMessageId || msg._relatedMessageId)
|
| + return false;
|
| +
|
| if (!this._isEqualStackTraces(this.stackTrace, msg.stackTrace))
|
| return false;
|
|
|
| @@ -411,7 +441,8 @@ WebInspector.ConsoleMessage.MessageLevel = {
|
| Info: "info",
|
| Warning: "warning",
|
| Error: "error",
|
| - Debug: "debug"
|
| + Debug: "debug",
|
| + RevokedError: "revokedError"
|
| };
|
|
|
| /**
|
| @@ -456,7 +487,9 @@ WebInspector.ConsoleDispatcher.prototype = {
|
| payload.timestamp * 1000, // Convert to ms.
|
| payload.executionContextId,
|
| payload.asyncStackTrace,
|
| - payload.scriptId);
|
| + payload.scriptId,
|
| + payload.messageId,
|
| + payload.relatedMessageId);
|
| this._console.addMessage(consoleMessage);
|
| },
|
|
|
| @@ -487,6 +520,7 @@ WebInspector.MultitargetConsoleModel = function()
|
| {
|
| WebInspector.targetManager.observeTargets(this);
|
| WebInspector.targetManager.addModelListener(WebInspector.ConsoleModel, WebInspector.ConsoleModel.Events.MessageAdded, this._consoleMessageAdded, this);
|
| + WebInspector.targetManager.addModelListener(WebInspector.ConsoleModel, WebInspector.ConsoleModel.Events.MessageUpdated, this._consoleMessageUpdated, this);
|
| WebInspector.targetManager.addModelListener(WebInspector.ConsoleModel, WebInspector.ConsoleModel.Events.CommandEvaluated, this._commandEvaluated, this);
|
| }
|
|
|
| @@ -543,6 +577,14 @@ WebInspector.MultitargetConsoleModel.prototype = {
|
| /**
|
| * @param {!WebInspector.Event} event
|
| */
|
| + _consoleMessageUpdated: function(event)
|
| + {
|
| + this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.MessageUpdated, event.data);
|
| + },
|
| +
|
| + /**
|
| + * @param {!WebInspector.Event} event
|
| + */
|
| _commandEvaluated: function(event)
|
| {
|
| this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.CommandEvaluated, event.data);
|
|
|