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

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

Issue 1666563005: DevTools: merge ScriptCallStack and ScriptAsyncCallStack, move CallStacks from console to Runtime. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: testts Created 4 years, 10 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 * @param {?WebInspector.Target} target 232 * @param {?WebInspector.Target} target
233 * @param {string} source 233 * @param {string} source
234 * @param {?string} level 234 * @param {?string} level
235 * @param {string} messageText 235 * @param {string} messageText
236 * @param {string=} type 236 * @param {string=} type
237 * @param {?string=} url 237 * @param {?string=} url
238 * @param {number=} line 238 * @param {number=} line
239 * @param {number=} column 239 * @param {number=} column
240 * @param {!NetworkAgent.RequestId=} requestId 240 * @param {!NetworkAgent.RequestId=} requestId
241 * @param {!Array.<!RuntimeAgent.RemoteObject>=} parameters 241 * @param {!Array.<!RuntimeAgent.RemoteObject>=} parameters
242 * @param {!Array.<!ConsoleAgent.CallFrame>=} stackTrace 242 * @param {!RuntimeAgent.StackTrace=} stackTrace
243 * @param {number=} timestamp 243 * @param {number=} timestamp
244 * @param {!RuntimeAgent.ExecutionContextId=} executionContextId 244 * @param {!RuntimeAgent.ExecutionContextId=} executionContextId
245 * @param {!ConsoleAgent.AsyncStackTrace=} asyncStackTrace
246 * @param {?string=} scriptId 245 * @param {?string=} scriptId
247 * @param {number=} messageId 246 * @param {number=} messageId
248 * @param {number=} relatedMessageId 247 * @param {number=} relatedMessageId
249 */ 248 */
250 WebInspector.ConsoleMessage = function(target, source, level, messageText, type, url, line, column, requestId, parameters, stackTrace, timestamp, executionConte xtId, asyncStackTrace, scriptId, messageId, relatedMessageId) 249 WebInspector.ConsoleMessage = function(target, source, level, messageText, type, url, line, column, requestId, parameters, stackTrace, timestamp, executionConte xtId, scriptId, messageId, relatedMessageId)
251 { 250 {
252 this._target = target; 251 this._target = target;
253 this.source = source; 252 this.source = source;
254 this.level = level; 253 this.level = level;
255 this.messageText = messageText; 254 this.messageText = messageText;
256 this.type = type || WebInspector.ConsoleMessage.MessageType.Log; 255 this.type = type || WebInspector.ConsoleMessage.MessageType.Log;
257 /** @type {string|undefined} */ 256 /** @type {string|undefined} */
258 this.url = url || undefined; 257 this.url = url || undefined;
259 /** @type {number} */ 258 /** @type {number} */
260 this.line = line || 0; 259 this.line = line || 0;
261 /** @type {number} */ 260 /** @type {number} */
262 this.column = column || 0; 261 this.column = column || 0;
263 this.parameters = parameters; 262 this.parameters = parameters;
264 /** @type {!Array.<!ConsoleAgent.CallFrame>|undefined} */ 263 /** @type {!RuntimeAgent.StackTrace|undefined} */
265 this.stackTrace = stackTrace; 264 this.stackTrace = stackTrace;
266 this.timestamp = timestamp || Date.now(); 265 this.timestamp = timestamp || Date.now();
267 this.executionContextId = executionContextId || 0; 266 this.executionContextId = executionContextId || 0;
268 this.asyncStackTrace = asyncStackTrace;
269 this.scriptId = scriptId || null; 267 this.scriptId = scriptId || null;
270 this._messageId = messageId || 0; 268 this._messageId = messageId || 0;
271 this._relatedMessageId = relatedMessageId || 0; 269 this._relatedMessageId = relatedMessageId || 0;
272 270
273 this.request = requestId ? target.networkLog.requestForId(requestId) : null; 271 this.request = requestId ? target.networkLog.requestForId(requestId) : null;
274 272
275 if (this.request) { 273 if (this.request) {
276 var initiator = this.request.initiator(); 274 var initiator = this.request.initiator();
277 if (initiator) { 275 if (initiator) {
278 this.stackTrace = initiator.stackTrace || undefined; 276 this.stackTrace = initiator.stack || undefined;
279 this.asyncStackTrace = initiator.asyncStackTrace;
280 if (initiator.url) { 277 if (initiator.url) {
281 this.url = initiator.url; 278 this.url = initiator.url;
282 this.line = initiator.lineNumber || 0; 279 this.line = initiator.lineNumber || 0;
283 } 280 }
284 } 281 }
285 } 282 }
286 } 283 }
287 284
288 WebInspector.ConsoleMessage.prototype = { 285 WebInspector.ConsoleMessage.prototype = {
289 /** 286 /**
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 return false; 353 return false;
357 354
358 if (this._messageId || msg._messageId) 355 if (this._messageId || msg._messageId)
359 return false; 356 return false;
360 if (this._relatedMessageId || msg._relatedMessageId) 357 if (this._relatedMessageId || msg._relatedMessageId)
361 return false; 358 return false;
362 359
363 if (!this._isEqualStackTraces(this.stackTrace, msg.stackTrace)) 360 if (!this._isEqualStackTraces(this.stackTrace, msg.stackTrace))
364 return false; 361 return false;
365 362
366 var asyncTrace1 = this.asyncStackTrace;
367 var asyncTrace2 = msg.asyncStackTrace;
368 while (asyncTrace1 || asyncTrace2) {
369 if (!asyncTrace1 || !asyncTrace2)
370 return false;
371 if (asyncTrace1.description !== asyncTrace2.description)
372 return false;
373 if (!this._isEqualStackTraces(asyncTrace1.callFrames, asyncTrace2.ca llFrames))
374 return false;
375 asyncTrace1 = asyncTrace1.asyncStackTrace;
376 asyncTrace2 = asyncTrace2.asyncStackTrace;
377 }
378
379 if (this.parameters) { 363 if (this.parameters) {
380 if (!msg.parameters || this.parameters.length !== msg.parameters.len gth) 364 if (!msg.parameters || this.parameters.length !== msg.parameters.len gth)
381 return false; 365 return false;
382 366
383 for (var i = 0; i < msg.parameters.length; ++i) { 367 for (var i = 0; i < msg.parameters.length; ++i) {
384 // Never treat objects as equal - their properties might change over time. 368 // Never treat objects as equal - their properties might change over time.
385 if (this.parameters[i].type !== msg.parameters[i].type || msg.pa rameters[i].type === "object" || this.parameters[i].value !== msg.parameters[i]. value) 369 if (this.parameters[i].type !== msg.parameters[i].type || msg.pa rameters[i].type === "object" || this.parameters[i].value !== msg.parameters[i]. value)
386 return false; 370 return false;
387 } 371 }
388 } 372 }
389 373
390 return (this.target() === msg.target()) 374 return (this.target() === msg.target())
391 && (this.source === msg.source) 375 && (this.source === msg.source)
392 && (this.type === msg.type) 376 && (this.type === msg.type)
393 && (this.level === msg.level) 377 && (this.level === msg.level)
394 && (this.line === msg.line) 378 && (this.line === msg.line)
395 && (this.url === msg.url) 379 && (this.url === msg.url)
396 && (this.messageText === msg.messageText) 380 && (this.messageText === msg.messageText)
397 && (this.request === msg.request) 381 && (this.request === msg.request)
398 && (this.executionContextId === msg.executionContextId) 382 && (this.executionContextId === msg.executionContextId)
399 && (this.scriptId === msg.scriptId); 383 && (this.scriptId === msg.scriptId);
400 }, 384 },
401 385
402 /** 386 /**
403 * @param {!Array.<!ConsoleAgent.CallFrame>|undefined} stackTrace1 387 * @param {!RuntimeAgent.StackTrace|undefined} stackTrace1
404 * @param {!Array.<!ConsoleAgent.CallFrame>|undefined} stackTrace2 388 * @param {!RuntimeAgent.StackTrace|undefined} stackTrace2
405 * @return {boolean} 389 * @return {boolean}
406 */ 390 */
407 _isEqualStackTraces: function(stackTrace1, stackTrace2) 391 _isEqualStackTraces: function(stackTrace1, stackTrace2)
408 { 392 {
409 stackTrace1 = stackTrace1 || []; 393 if (!stackTrace1 !== !stackTrace2)
410 stackTrace2 = stackTrace2 || [];
411 if (stackTrace1.length !== stackTrace2.length)
412 return false; 394 return false;
413 for (var i = 0, n = stackTrace1.length; i < n; ++i) { 395 if (!stackTrace1)
414 if (stackTrace1[i].url !== stackTrace2[i].url || 396 return true;
415 stackTrace1[i].functionName !== stackTrace2[i].functionName || 397 var callFrames1 = stackTrace1.callFrames;
416 stackTrace1[i].lineNumber !== stackTrace2[i].lineNumber || 398 var callFrames2 = stackTrace2.callFrames;
417 stackTrace1[i].columnNumber !== stackTrace2[i].columnNumber) 399 if (callFrames1.length !== callFrames2.length)
400 return false;
401 for (var i = 0, n = callFrames1.length; i < n; ++i) {
402 if (callFrames1[i].url !== callFrames2[i].url ||
403 callFrames1[i].functionName !== callFrames2[i].functionName ||
404 callFrames1[i].lineNumber !== callFrames2[i].lineNumber ||
405 callFrames1[i].columnNumber !== callFrames2[i].columnNumber)
418 return false; 406 return false;
419 } 407 }
420 return true; 408 return this._isEqualStackTraces(stackTrace1.parent, stackTrace2.parent);
421 } 409 }
422 } 410 }
423 411
424 // Note: Keep these constants in sync with the ones in Console.h 412 // Note: Keep these constants in sync with the ones in Console.h
425 /** 413 /**
426 * @enum {string} 414 * @enum {string}
427 */ 415 */
428 WebInspector.ConsoleMessage.MessageSource = { 416 WebInspector.ConsoleMessage.MessageSource = {
429 XML: "xml", 417 XML: "xml",
430 JS: "javascript", 418 JS: "javascript",
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 this._console.target(), 490 this._console.target(),
503 payload.source, 491 payload.source,
504 payload.level, 492 payload.level,
505 payload.text, 493 payload.text,
506 payload.type, 494 payload.type,
507 payload.url, 495 payload.url,
508 payload.line, 496 payload.line,
509 payload.column, 497 payload.column,
510 payload.networkRequestId, 498 payload.networkRequestId,
511 payload.parameters, 499 payload.parameters,
512 payload.stackTrace, 500 payload.stack,
513 payload.timestamp * 1000, // Convert to ms. 501 payload.timestamp * 1000, // Convert to ms.
514 payload.executionContextId, 502 payload.executionContextId,
515 payload.asyncStackTrace,
516 payload.scriptId, 503 payload.scriptId,
517 payload.messageId, 504 payload.messageId,
518 payload.relatedMessageId); 505 payload.relatedMessageId);
519 this._console.addMessage(consoleMessage); 506 this._console.addMessage(consoleMessage);
520 }, 507 },
521 508
522 /** 509 /**
523 * @override 510 * @override
524 * @param {number} count 511 * @param {number} count
525 */ 512 */
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.CommandEv aluated, event.data); 603 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.CommandEv aluated, event.data);
617 }, 604 },
618 605
619 __proto__: WebInspector.Object.prototype 606 __proto__: WebInspector.Object.prototype
620 } 607 }
621 608
622 /** 609 /**
623 * @type {!WebInspector.MultitargetConsoleModel} 610 * @type {!WebInspector.MultitargetConsoleModel}
624 */ 611 */
625 WebInspector.multitargetConsoleModel; 612 WebInspector.multitargetConsoleModel;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698