Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/ConsoleModel.js

Issue 2116563003: [DevTools] Report unhandled exceptions and promise rejections through Runtime. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after ExceptionDetails change Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 22 matching lines...) Expand all
33 * @extends {WebInspector.SDKModel} 33 * @extends {WebInspector.SDKModel}
34 * @param {!WebInspector.Target} target 34 * @param {!WebInspector.Target} target
35 */ 35 */
36 WebInspector.ConsoleModel = function(target) 36 WebInspector.ConsoleModel = function(target)
37 { 37 {
38 WebInspector.SDKModel.call(this, WebInspector.ConsoleModel, target); 38 WebInspector.SDKModel.call(this, WebInspector.ConsoleModel, target);
39 39
40 /** @type {!Array.<!WebInspector.ConsoleMessage>} */ 40 /** @type {!Array.<!WebInspector.ConsoleMessage>} */
41 this._messages = []; 41 this._messages = [];
42 /** @type {!Map<number, !WebInspector.ConsoleMessage>} */ 42 /** @type {!Map<number, !WebInspector.ConsoleMessage>} */
43 this._messageById = new Map(); 43 this._messageByExceptionId = new Map();
44 this._warnings = 0; 44 this._warnings = 0;
45 this._errors = 0; 45 this._errors = 0;
46 this._revokedErrors = 0; 46 this._revokedErrors = 0;
47 this._consoleAgent = target.consoleAgent(); 47 this._consoleAgent = target.consoleAgent();
48 target.registerConsoleDispatcher(new WebInspector.ConsoleDispatcher(this)); 48 target.registerConsoleDispatcher(new WebInspector.ConsoleDispatcher(this));
49 this._enableAgent(); 49 this._enableAgent();
50 } 50 }
51 51
52 WebInspector.ConsoleModel.Events = { 52 WebInspector.ConsoleModel.Events = {
53 ConsoleCleared: "ConsoleCleared", 53 ConsoleCleared: "ConsoleCleared",
(...skipping 18 matching lines...) Expand all
72 }, 72 },
73 73
74 /** 74 /**
75 * @param {!WebInspector.ConsoleMessage} msg 75 * @param {!WebInspector.ConsoleMessage} msg
76 */ 76 */
77 addMessage: function(msg) 77 addMessage: function(msg)
78 { 78 {
79 if (this._isBlacklisted(msg)) 79 if (this._isBlacklisted(msg))
80 return; 80 return;
81 81
82 if (msg.level === WebInspector.ConsoleMessage.MessageLevel.RevokedError && msg._relatedMessageId) { 82 if (msg.level === WebInspector.ConsoleMessage.MessageLevel.RevokedError && msg._revokedExceptionId) {
83 var relatedMessage = this._messageById.get(msg._relatedMessageId); 83 var exceptionMessage = this._messageByExceptionId.get(msg._revokedEx ceptionId);
84 if (!relatedMessage) 84 if (!exceptionMessage)
85 return; 85 return;
86 this._errors--; 86 this._errors--;
87 this._revokedErrors++; 87 this._revokedErrors++;
88 relatedMessage.level = WebInspector.ConsoleMessage.MessageLevel.Revo kedError; 88 exceptionMessage.level = WebInspector.ConsoleMessage.MessageLevel.Re vokedError;
89 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.Messa geUpdated, relatedMessage); 89 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.Messa geUpdated, exceptionMessage);
90 return; 90 return;
91 } 91 }
92 92
93 this._messages.push(msg); 93 this._messages.push(msg);
94 if (msg._messageId) 94 if (msg._exceptionId)
95 this._messageById.set(msg._messageId, msg); 95 this._messageByExceptionId.set(msg._exceptionId, msg);
96 this._incrementErrorWarningCount(msg); 96 this._incrementErrorWarningCount(msg);
97 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.MessageAd ded, msg); 97 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.MessageAd ded, msg);
98 }, 98 },
99 99
100 /** 100 /**
101 * @param {!WebInspector.ConsoleMessage} msg 101 * @param {!WebInspector.ConsoleMessage} msg
102 */ 102 */
103 _incrementErrorWarningCount: function(msg) 103 _incrementErrorWarningCount: function(msg)
104 { 104 {
105 switch (msg.level) { 105 switch (msg.level) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 requestClearMessages: function() 142 requestClearMessages: function()
143 { 143 {
144 this._consoleAgent.clearMessages(); 144 this._consoleAgent.clearMessages();
145 this._messagesCleared(); 145 this._messagesCleared();
146 }, 146 },
147 147
148 _messagesCleared: function() 148 _messagesCleared: function()
149 { 149 {
150 this._messages = []; 150 this._messages = [];
151 this._messageById.clear(); 151 this._messageByExceptionId.clear();
152 this._errors = 0; 152 this._errors = 0;
153 this._revokedErrors = 0; 153 this._revokedErrors = 0;
154 this._warnings = 0; 154 this._warnings = 0;
155 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.ConsoleCl eared); 155 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.ConsoleCl eared);
156 }, 156 },
157 157
158 /** 158 /**
159 * @return {number} 159 * @return {number}
160 */ 160 */
161 errors: function() 161 errors: function()
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 * @param {string=} type 237 * @param {string=} type
238 * @param {?string=} url 238 * @param {?string=} url
239 * @param {number=} line 239 * @param {number=} line
240 * @param {number=} column 240 * @param {number=} column
241 * @param {!NetworkAgent.RequestId=} requestId 241 * @param {!NetworkAgent.RequestId=} requestId
242 * @param {!Array.<!RuntimeAgent.RemoteObject>=} parameters 242 * @param {!Array.<!RuntimeAgent.RemoteObject>=} parameters
243 * @param {!RuntimeAgent.StackTrace=} stackTrace 243 * @param {!RuntimeAgent.StackTrace=} stackTrace
244 * @param {number=} timestamp 244 * @param {number=} timestamp
245 * @param {!RuntimeAgent.ExecutionContextId=} executionContextId 245 * @param {!RuntimeAgent.ExecutionContextId=} executionContextId
246 * @param {?string=} scriptId 246 * @param {?string=} scriptId
247 * @param {number=} messageId
248 * @param {number=} relatedMessageId
249 */ 247 */
250 WebInspector.ConsoleMessage = function(target, source, level, messageText, type, url, line, column, requestId, parameters, stackTrace, timestamp, executionConte xtId, scriptId, messageId, relatedMessageId) 248 WebInspector.ConsoleMessage = function(target, source, level, messageText, type, url, line, column, requestId, parameters, stackTrace, timestamp, executionConte xtId, scriptId)
251 { 249 {
252 this._target = target; 250 this._target = target;
253 this.source = source; 251 this.source = source;
254 this.level = level; 252 this.level = level;
255 this.messageText = messageText; 253 this.messageText = messageText;
256 this.type = type || WebInspector.ConsoleMessage.MessageType.Log; 254 this.type = type || WebInspector.ConsoleMessage.MessageType.Log;
257 /** @type {string|undefined} */ 255 /** @type {string|undefined} */
258 this.url = url || undefined; 256 this.url = url || undefined;
259 /** @type {number} */ 257 /** @type {number} */
260 this.line = line || 0; 258 this.line = line || 0;
261 /** @type {number} */ 259 /** @type {number} */
262 this.column = column || 0; 260 this.column = column || 0;
263 this.parameters = parameters; 261 this.parameters = parameters;
264 /** @type {!RuntimeAgent.StackTrace|undefined} */ 262 /** @type {!RuntimeAgent.StackTrace|undefined} */
265 this.stackTrace = stackTrace; 263 this.stackTrace = stackTrace;
266 this.timestamp = timestamp || Date.now(); 264 this.timestamp = timestamp || Date.now();
267 this.executionContextId = executionContextId || 0; 265 this.executionContextId = executionContextId || 0;
268 this.scriptId = scriptId || null; 266 this.scriptId = scriptId || null;
269 this._messageId = messageId || 0;
270 this._relatedMessageId = relatedMessageId || 0;
271 267
272 var networkLog = target && WebInspector.NetworkLog.fromTarget(target); 268 var networkLog = target && WebInspector.NetworkLog.fromTarget(target);
273 this.request = (requestId && networkLog) ? networkLog.requestForId(requestId ) : null; 269 this.request = (requestId && networkLog) ? networkLog.requestForId(requestId ) : null;
274 270
275 if (this.request) { 271 if (this.request) {
276 var initiator = this.request.initiator(); 272 var initiator = this.request.initiator();
277 if (initiator) { 273 if (initiator) {
278 this.stackTrace = initiator.stack || undefined; 274 this.stackTrace = initiator.stack || undefined;
279 if (initiator.url) { 275 if (initiator.url) {
280 this.url = initiator.url; 276 this.url = initiator.url;
(...skipping 23 matching lines...) Expand all
304 300
305 /** 301 /**
306 * @param {!RuntimeAgent.ExecutionContextId} executionContextId 302 * @param {!RuntimeAgent.ExecutionContextId} executionContextId
307 */ 303 */
308 setExecutionContextId: function(executionContextId) 304 setExecutionContextId: function(executionContextId)
309 { 305 {
310 this.executionContextId = executionContextId; 306 this.executionContextId = executionContextId;
311 }, 307 },
312 308
313 /** 309 /**
310 * @param {number} exceptionId
311 */
312 setExceptionId: function(exceptionId)
313 {
314 this._exceptionId = exceptionId;
315 },
316
317 /**
318 * @param {number} revokedExceptionId
319 */
320 setRevokedExceptionId: function(revokedExceptionId)
321 {
322 this._revokedExceptionId = revokedExceptionId;
323 },
324
325 /**
314 * @return {?WebInspector.ConsoleMessage} 326 * @return {?WebInspector.ConsoleMessage}
315 */ 327 */
316 originatingMessage: function() 328 originatingMessage: function()
317 { 329 {
318 return this._originatingConsoleMessage; 330 return this._originatingConsoleMessage;
319 }, 331 },
320 332
321 /** 333 /**
322 * @return {boolean} 334 * @return {boolean}
323 */ 335 */
(...skipping 23 matching lines...) Expand all
347 359
348 /** 360 /**
349 * @param {?WebInspector.ConsoleMessage} msg 361 * @param {?WebInspector.ConsoleMessage} msg
350 * @return {boolean} 362 * @return {boolean}
351 */ 363 */
352 isEqual: function(msg) 364 isEqual: function(msg)
353 { 365 {
354 if (!msg) 366 if (!msg)
355 return false; 367 return false;
356 368
357 if (this._messageId || msg._messageId) 369 if (this._exceptionId || msg._exceptionId)
358 return false; 370 return false;
359 if (this._relatedMessageId || msg._relatedMessageId) 371 if (this._revokedExceptionId || msg._revokedExceptionId)
360 return false; 372 return false;
361 373
362 if (!this._isEqualStackTraces(this.stackTrace, msg.stackTrace)) 374 if (!this._isEqualStackTraces(this.stackTrace, msg.stackTrace))
363 return false; 375 return false;
364 376
365 if (this.parameters) { 377 if (this.parameters) {
366 if (!msg.parameters || this.parameters.length !== msg.parameters.len gth) 378 if (!msg.parameters || this.parameters.length !== msg.parameters.len gth)
367 return false; 379 return false;
368 380
369 for (var i = 0; i < msg.parameters.length; ++i) { 381 for (var i = 0; i < msg.parameters.length; ++i) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 463
452 /** 464 /**
453 * @enum {string} 465 * @enum {string}
454 */ 466 */
455 WebInspector.ConsoleMessage.MessageLevel = { 467 WebInspector.ConsoleMessage.MessageLevel = {
456 Log: "log", 468 Log: "log",
457 Info: "info", 469 Info: "info",
458 Warning: "warning", 470 Warning: "warning",
459 Error: "error", 471 Error: "error",
460 Debug: "debug", 472 Debug: "debug",
461 RevokedError: "revokedError" 473 RevokedError: "revokedError" // This is frontend-only level, used to put ex ceptions to console.
462 }; 474 };
463 475
464 /** 476 /**
465 * @param {!WebInspector.ConsoleMessage} a 477 * @param {!WebInspector.ConsoleMessage} a
466 * @param {!WebInspector.ConsoleMessage} b 478 * @param {!WebInspector.ConsoleMessage} b
467 * @return {number} 479 * @return {number}
468 */ 480 */
469 WebInspector.ConsoleMessage.timestampComparator = function(a, b) 481 WebInspector.ConsoleMessage.timestampComparator = function(a, b)
470 { 482 {
471 return a.timestamp - b.timestamp; 483 return a.timestamp - b.timestamp;
(...skipping 23 matching lines...) Expand all
495 payload.text, 507 payload.text,
496 payload.type, 508 payload.type,
497 payload.url, 509 payload.url,
498 payload.line, 510 payload.line,
499 payload.column, 511 payload.column,
500 payload.networkRequestId, 512 payload.networkRequestId,
501 payload.parameters, 513 payload.parameters,
502 payload.stack, 514 payload.stack,
503 payload.timestamp * 1000, // Convert to ms. 515 payload.timestamp * 1000, // Convert to ms.
504 payload.executionContextId, 516 payload.executionContextId,
505 payload.scriptId, 517 payload.scriptId);
506 payload.messageId,
507 payload.relatedMessageId);
508 this._console.addMessage(consoleMessage); 518 this._console.addMessage(consoleMessage);
509 }, 519 },
510 520
511 /** 521 /**
512 * @override 522 * @override
513 * @param {number} count 523 * @param {number} count
514 */ 524 */
515 messageRepeatCountUpdated: function(count) 525 messageRepeatCountUpdated: function(count)
516 { 526 {
517 }, 527 },
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.CommandEv aluated, event.data); 615 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.CommandEv aluated, event.data);
606 }, 616 },
607 617
608 __proto__: WebInspector.Object.prototype 618 __proto__: WebInspector.Object.prototype
609 } 619 }
610 620
611 /** 621 /**
612 * @type {!WebInspector.MultitargetConsoleModel} 622 * @type {!WebInspector.MultitargetConsoleModel}
613 */ 623 */
614 WebInspector.multitargetConsoleModel; 624 WebInspector.multitargetConsoleModel;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698