| 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @unrestricted | 32 * @unrestricted |
| 33 */ | 33 */ |
| 34 WebInspector.ConsoleModel = class extends WebInspector.SDKModel { | 34 SDK.ConsoleModel = class extends SDK.SDKModel { |
| 35 /** | 35 /** |
| 36 * @param {!WebInspector.Target} target | 36 * @param {!SDK.Target} target |
| 37 * @param {?Protocol.LogAgent} logAgent | 37 * @param {?Protocol.LogAgent} logAgent |
| 38 */ | 38 */ |
| 39 constructor(target, logAgent) { | 39 constructor(target, logAgent) { |
| 40 super(WebInspector.ConsoleModel, target); | 40 super(SDK.ConsoleModel, target); |
| 41 | 41 |
| 42 /** @type {!Array.<!WebInspector.ConsoleMessage>} */ | 42 /** @type {!Array.<!SDK.ConsoleMessage>} */ |
| 43 this._messages = []; | 43 this._messages = []; |
| 44 /** @type {!Map<number, !WebInspector.ConsoleMessage>} */ | 44 /** @type {!Map<number, !SDK.ConsoleMessage>} */ |
| 45 this._messageByExceptionId = new Map(); | 45 this._messageByExceptionId = new Map(); |
| 46 this._warnings = 0; | 46 this._warnings = 0; |
| 47 this._errors = 0; | 47 this._errors = 0; |
| 48 this._revokedErrors = 0; | 48 this._revokedErrors = 0; |
| 49 this._logAgent = logAgent; | 49 this._logAgent = logAgent; |
| 50 if (this._logAgent) { | 50 if (this._logAgent) { |
| 51 target.registerLogDispatcher(new WebInspector.LogDispatcher(this)); | 51 target.registerLogDispatcher(new SDK.LogDispatcher(this)); |
| 52 this._logAgent.enable(); | 52 this._logAgent.enable(); |
| 53 if (!InspectorFrontendHost.isUnderTest()) { | 53 if (!InspectorFrontendHost.isUnderTest()) { |
| 54 this._logAgent.startViolationsReport([ | 54 this._logAgent.startViolationsReport([ |
| 55 {name: 'longTask', threshold: 50 }, | 55 {name: 'longTask', threshold: 50 }, |
| 56 {name: 'longLayout', threshold: 30}, | 56 {name: 'longLayout', threshold: 30}, |
| 57 {name: 'blockedEvent', threshold: 100}]); | 57 {name: 'blockedEvent', threshold: 100}]); |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * @param {!WebInspector.ExecutionContext} executionContext | 63 * @param {!SDK.ExecutionContext} executionContext |
| 64 * @param {string} text | 64 * @param {string} text |
| 65 * @param {boolean=} useCommandLineAPI | 65 * @param {boolean=} useCommandLineAPI |
| 66 */ | 66 */ |
| 67 static evaluateCommandInConsole(executionContext, text, useCommandLineAPI) { | 67 static evaluateCommandInConsole(executionContext, text, useCommandLineAPI) { |
| 68 var target = executionContext.target(); | 68 var target = executionContext.target(); |
| 69 var requestedText = text; | 69 var requestedText = text; |
| 70 | 70 |
| 71 var commandMessage = new WebInspector.ConsoleMessage( | 71 var commandMessage = new SDK.ConsoleMessage( |
| 72 target, WebInspector.ConsoleMessage.MessageSource.JS, null, text, | 72 target, SDK.ConsoleMessage.MessageSource.JS, null, text, |
| 73 WebInspector.ConsoleMessage.MessageType.Command); | 73 SDK.ConsoleMessage.MessageType.Command); |
| 74 commandMessage.setExecutionContextId(executionContext.id); | 74 commandMessage.setExecutionContextId(executionContext.id); |
| 75 target.consoleModel.addMessage(commandMessage); | 75 target.consoleModel.addMessage(commandMessage); |
| 76 | 76 |
| 77 /** | 77 /** |
| 78 * @param {?WebInspector.RemoteObject} result | 78 * @param {?SDK.RemoteObject} result |
| 79 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails | 79 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails |
| 80 */ | 80 */ |
| 81 function printResult(result, exceptionDetails) { | 81 function printResult(result, exceptionDetails) { |
| 82 if (!result) | 82 if (!result) |
| 83 return; | 83 return; |
| 84 | 84 |
| 85 WebInspector.console.showPromise().then(reportUponEvaluation); | 85 Common.console.showPromise().then(reportUponEvaluation); |
| 86 function reportUponEvaluation() { | 86 function reportUponEvaluation() { |
| 87 target.consoleModel.dispatchEventToListeners( | 87 target.consoleModel.dispatchEventToListeners( |
| 88 WebInspector.ConsoleModel.Events.CommandEvaluated, | 88 SDK.ConsoleModel.Events.CommandEvaluated, |
| 89 {result: result, text: requestedText, commandMessage: commandMessage
, exceptionDetails: exceptionDetails}); | 89 {result: result, text: requestedText, commandMessage: commandMessage
, exceptionDetails: exceptionDetails}); |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 /** | 93 /** |
| 94 * @param {string} code | 94 * @param {string} code |
| 95 * @suppress {uselessCode} | 95 * @suppress {uselessCode} |
| 96 * @return {boolean} | 96 * @return {boolean} |
| 97 */ | 97 */ |
| 98 function looksLikeAnObjectLiteral(code) { | 98 function looksLikeAnObjectLiteral(code) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 110 return true; | 110 return true; |
| 111 } catch (e) { | 111 } catch (e) { |
| 112 return false; | 112 return false; |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 | 115 |
| 116 if (looksLikeAnObjectLiteral(text)) | 116 if (looksLikeAnObjectLiteral(text)) |
| 117 text = '(' + text + ')'; | 117 text = '(' + text + ')'; |
| 118 | 118 |
| 119 executionContext.evaluate(text, 'console', !!useCommandLineAPI, false, false
, true, true, printResult); | 119 executionContext.evaluate(text, 'console', !!useCommandLineAPI, false, false
, true, true, printResult); |
| 120 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.Console
Evaluated); | 120 Host.userMetrics.actionTaken(Host.UserMetrics.Action.ConsoleEvaluated); |
| 121 } | 121 } |
| 122 | 122 |
| 123 /** | 123 /** |
| 124 * @param {!WebInspector.ConsoleMessage} msg | 124 * @param {!SDK.ConsoleMessage} msg |
| 125 */ | 125 */ |
| 126 addMessage(msg) { | 126 addMessage(msg) { |
| 127 if (this._isBlacklisted(msg)) | 127 if (this._isBlacklisted(msg)) |
| 128 return; | 128 return; |
| 129 | 129 |
| 130 if (msg.source === WebInspector.ConsoleMessage.MessageSource.Worker && msg.t
arget().subTargetsManager && | 130 if (msg.source === SDK.ConsoleMessage.MessageSource.Worker && msg.target().s
ubTargetsManager && |
| 131 msg.target().subTargetsManager.targetForId(msg.workerId)) | 131 msg.target().subTargetsManager.targetForId(msg.workerId)) |
| 132 return; | 132 return; |
| 133 | 133 |
| 134 if (msg.source === WebInspector.ConsoleMessage.MessageSource.ConsoleAPI && | 134 if (msg.source === SDK.ConsoleMessage.MessageSource.ConsoleAPI && |
| 135 msg.type === WebInspector.ConsoleMessage.MessageType.Clear) | 135 msg.type === SDK.ConsoleMessage.MessageType.Clear) |
| 136 this.clear(); | 136 this.clear(); |
| 137 | 137 |
| 138 if (msg.level === WebInspector.ConsoleMessage.MessageLevel.RevokedError && m
sg._revokedExceptionId) { | 138 if (msg.level === SDK.ConsoleMessage.MessageLevel.RevokedError && msg._revok
edExceptionId) { |
| 139 var exceptionMessage = this._messageByExceptionId.get(msg._revokedExceptio
nId); | 139 var exceptionMessage = this._messageByExceptionId.get(msg._revokedExceptio
nId); |
| 140 if (!exceptionMessage) | 140 if (!exceptionMessage) |
| 141 return; | 141 return; |
| 142 this._errors--; | 142 this._errors--; |
| 143 this._revokedErrors++; | 143 this._revokedErrors++; |
| 144 exceptionMessage.level = WebInspector.ConsoleMessage.MessageLevel.RevokedE
rror; | 144 exceptionMessage.level = SDK.ConsoleMessage.MessageLevel.RevokedError; |
| 145 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.MessageUpda
ted, exceptionMessage); | 145 this.dispatchEventToListeners(SDK.ConsoleModel.Events.MessageUpdated, exce
ptionMessage); |
| 146 return; | 146 return; |
| 147 } | 147 } |
| 148 | 148 |
| 149 this._messages.push(msg); | 149 this._messages.push(msg); |
| 150 if (msg._exceptionId) | 150 if (msg._exceptionId) |
| 151 this._messageByExceptionId.set(msg._exceptionId, msg); | 151 this._messageByExceptionId.set(msg._exceptionId, msg); |
| 152 this._incrementErrorWarningCount(msg); | 152 this._incrementErrorWarningCount(msg); |
| 153 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.MessageAdded,
msg); | 153 this.dispatchEventToListeners(SDK.ConsoleModel.Events.MessageAdded, msg); |
| 154 } | 154 } |
| 155 | 155 |
| 156 /** | 156 /** |
| 157 * @param {!WebInspector.ConsoleMessage} msg | 157 * @param {!SDK.ConsoleMessage} msg |
| 158 */ | 158 */ |
| 159 _incrementErrorWarningCount(msg) { | 159 _incrementErrorWarningCount(msg) { |
| 160 switch (msg.level) { | 160 switch (msg.level) { |
| 161 case WebInspector.ConsoleMessage.MessageLevel.Warning: | 161 case SDK.ConsoleMessage.MessageLevel.Warning: |
| 162 this._warnings++; | 162 this._warnings++; |
| 163 break; | 163 break; |
| 164 case WebInspector.ConsoleMessage.MessageLevel.Error: | 164 case SDK.ConsoleMessage.MessageLevel.Error: |
| 165 this._errors++; | 165 this._errors++; |
| 166 break; | 166 break; |
| 167 case WebInspector.ConsoleMessage.MessageLevel.RevokedError: | 167 case SDK.ConsoleMessage.MessageLevel.RevokedError: |
| 168 this._revokedErrors++; | 168 this._revokedErrors++; |
| 169 break; | 169 break; |
| 170 } | 170 } |
| 171 } | 171 } |
| 172 | 172 |
| 173 /** | 173 /** |
| 174 * @param {!WebInspector.ConsoleMessage} msg | 174 * @param {!SDK.ConsoleMessage} msg |
| 175 * @return {boolean} | 175 * @return {boolean} |
| 176 */ | 176 */ |
| 177 _isBlacklisted(msg) { | 177 _isBlacklisted(msg) { |
| 178 if (msg.source !== WebInspector.ConsoleMessage.MessageSource.Network || | 178 if (msg.source !== SDK.ConsoleMessage.MessageSource.Network || |
| 179 msg.level !== WebInspector.ConsoleMessage.MessageLevel.Error || !msg.url
|| | 179 msg.level !== SDK.ConsoleMessage.MessageLevel.Error || !msg.url || |
| 180 !msg.url.startsWith('chrome-extension')) | 180 !msg.url.startsWith('chrome-extension')) |
| 181 return false; | 181 return false; |
| 182 | 182 |
| 183 // ignore Chromecast's cast_sender spam | 183 // ignore Chromecast's cast_sender spam |
| 184 if (msg.url.includes('://boadgeojelhgndaghljhdicfkmllpafd') || | 184 if (msg.url.includes('://boadgeojelhgndaghljhdicfkmllpafd') || |
| 185 msg.url.includes('://dliochdbjfkdbacpmhlcpmleaejidimm') || | 185 msg.url.includes('://dliochdbjfkdbacpmhlcpmleaejidimm') || |
| 186 msg.url.includes('://pkedcjkdefgpdelpbcmbmeomcjbeemfm') || | 186 msg.url.includes('://pkedcjkdefgpdelpbcmbmeomcjbeemfm') || |
| 187 msg.url.includes('://fjhoaacokmgbjemoflkofnenfaiekifl') || | 187 msg.url.includes('://fjhoaacokmgbjemoflkofnenfaiekifl') || |
| 188 msg.url.includes('://fmfcbgogabcbclcofgocippekhfcmgfj') || | 188 msg.url.includes('://fmfcbgogabcbclcofgocippekhfcmgfj') || |
| 189 msg.url.includes('://enhhojjnijigcajfphajepfemndkmdlo') || | 189 msg.url.includes('://enhhojjnijigcajfphajepfemndkmdlo') || |
| 190 msg.url.includes('://ekpaaapppgpmolpcldedioblbkmijaca')) | 190 msg.url.includes('://ekpaaapppgpmolpcldedioblbkmijaca')) |
| 191 return true; | 191 return true; |
| 192 | 192 |
| 193 return false; | 193 return false; |
| 194 } | 194 } |
| 195 | 195 |
| 196 /** | 196 /** |
| 197 * @return {!Array.<!WebInspector.ConsoleMessage>} | 197 * @return {!Array.<!SDK.ConsoleMessage>} |
| 198 */ | 198 */ |
| 199 messages() { | 199 messages() { |
| 200 return this._messages; | 200 return this._messages; |
| 201 } | 201 } |
| 202 | 202 |
| 203 requestClearMessages() { | 203 requestClearMessages() { |
| 204 this._logAgent && this._logAgent.clear(); | 204 this._logAgent && this._logAgent.clear(); |
| 205 this.clear(); | 205 this.clear(); |
| 206 } | 206 } |
| 207 | 207 |
| 208 clear() { | 208 clear() { |
| 209 this._messages = []; | 209 this._messages = []; |
| 210 this._messageByExceptionId.clear(); | 210 this._messageByExceptionId.clear(); |
| 211 this._errors = 0; | 211 this._errors = 0; |
| 212 this._revokedErrors = 0; | 212 this._revokedErrors = 0; |
| 213 this._warnings = 0; | 213 this._warnings = 0; |
| 214 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.ConsoleCleare
d); | 214 this.dispatchEventToListeners(SDK.ConsoleModel.Events.ConsoleCleared); |
| 215 } | 215 } |
| 216 | 216 |
| 217 /** | 217 /** |
| 218 * @return {number} | 218 * @return {number} |
| 219 */ | 219 */ |
| 220 errors() { | 220 errors() { |
| 221 return this._errors; | 221 return this._errors; |
| 222 } | 222 } |
| 223 | 223 |
| 224 /** | 224 /** |
| 225 * @return {number} | 225 * @return {number} |
| 226 */ | 226 */ |
| 227 revokedErrors() { | 227 revokedErrors() { |
| 228 return this._revokedErrors; | 228 return this._revokedErrors; |
| 229 } | 229 } |
| 230 | 230 |
| 231 /** | 231 /** |
| 232 * @return {number} | 232 * @return {number} |
| 233 */ | 233 */ |
| 234 warnings() { | 234 warnings() { |
| 235 return this._warnings; | 235 return this._warnings; |
| 236 } | 236 } |
| 237 }; | 237 }; |
| 238 | 238 |
| 239 /** @enum {symbol} */ | 239 /** @enum {symbol} */ |
| 240 WebInspector.ConsoleModel.Events = { | 240 SDK.ConsoleModel.Events = { |
| 241 ConsoleCleared: Symbol('ConsoleCleared'), | 241 ConsoleCleared: Symbol('ConsoleCleared'), |
| 242 MessageAdded: Symbol('MessageAdded'), | 242 MessageAdded: Symbol('MessageAdded'), |
| 243 MessageUpdated: Symbol('MessageUpdated'), | 243 MessageUpdated: Symbol('MessageUpdated'), |
| 244 CommandEvaluated: Symbol('CommandEvaluated') | 244 CommandEvaluated: Symbol('CommandEvaluated') |
| 245 }; | 245 }; |
| 246 | 246 |
| 247 | 247 |
| 248 /** | 248 /** |
| 249 * @unrestricted | 249 * @unrestricted |
| 250 */ | 250 */ |
| 251 WebInspector.ConsoleMessage = class { | 251 SDK.ConsoleMessage = class { |
| 252 /** | 252 /** |
| 253 * @param {?WebInspector.Target} target | 253 * @param {?SDK.Target} target |
| 254 * @param {string} source | 254 * @param {string} source |
| 255 * @param {?string} level | 255 * @param {?string} level |
| 256 * @param {string} messageText | 256 * @param {string} messageText |
| 257 * @param {string=} type | 257 * @param {string=} type |
| 258 * @param {?string=} url | 258 * @param {?string=} url |
| 259 * @param {number=} line | 259 * @param {number=} line |
| 260 * @param {number=} column | 260 * @param {number=} column |
| 261 * @param {!Protocol.Network.RequestId=} requestId | 261 * @param {!Protocol.Network.RequestId=} requestId |
| 262 * @param {!Array.<!Protocol.Runtime.RemoteObject>=} parameters | 262 * @param {!Array.<!Protocol.Runtime.RemoteObject>=} parameters |
| 263 * @param {!Protocol.Runtime.StackTrace=} stackTrace | 263 * @param {!Protocol.Runtime.StackTrace=} stackTrace |
| (...skipping 15 matching lines...) Expand all Loading... |
| 279 parameters, | 279 parameters, |
| 280 stackTrace, | 280 stackTrace, |
| 281 timestamp, | 281 timestamp, |
| 282 executionContextId, | 282 executionContextId, |
| 283 scriptId, | 283 scriptId, |
| 284 workerId) { | 284 workerId) { |
| 285 this._target = target; | 285 this._target = target; |
| 286 this.source = source; | 286 this.source = source; |
| 287 this.level = level; | 287 this.level = level; |
| 288 this.messageText = messageText; | 288 this.messageText = messageText; |
| 289 this.type = type || WebInspector.ConsoleMessage.MessageType.Log; | 289 this.type = type || SDK.ConsoleMessage.MessageType.Log; |
| 290 /** @type {string|undefined} */ | 290 /** @type {string|undefined} */ |
| 291 this.url = url || undefined; | 291 this.url = url || undefined; |
| 292 /** @type {number} */ | 292 /** @type {number} */ |
| 293 this.line = line || 0; | 293 this.line = line || 0; |
| 294 /** @type {number} */ | 294 /** @type {number} */ |
| 295 this.column = column || 0; | 295 this.column = column || 0; |
| 296 this.parameters = parameters; | 296 this.parameters = parameters; |
| 297 /** @type {!Protocol.Runtime.StackTrace|undefined} */ | 297 /** @type {!Protocol.Runtime.StackTrace|undefined} */ |
| 298 this.stackTrace = stackTrace; | 298 this.stackTrace = stackTrace; |
| 299 this.timestamp = timestamp || Date.now(); | 299 this.timestamp = timestamp || Date.now(); |
| 300 this.executionContextId = executionContextId || 0; | 300 this.executionContextId = executionContextId || 0; |
| 301 this.scriptId = scriptId || null; | 301 this.scriptId = scriptId || null; |
| 302 this.workerId = workerId || null; | 302 this.workerId = workerId || null; |
| 303 | 303 |
| 304 var networkLog = target && WebInspector.NetworkLog.fromTarget(target); | 304 var networkLog = target && SDK.NetworkLog.fromTarget(target); |
| 305 this.request = (requestId && networkLog) ? networkLog.requestForId(requestId
) : null; | 305 this.request = (requestId && networkLog) ? networkLog.requestForId(requestId
) : null; |
| 306 | 306 |
| 307 if (this.request) { | 307 if (this.request) { |
| 308 var initiator = this.request.initiator(); | 308 var initiator = this.request.initiator(); |
| 309 if (initiator) { | 309 if (initiator) { |
| 310 this.stackTrace = initiator.stack || undefined; | 310 this.stackTrace = initiator.stack || undefined; |
| 311 if (initiator.url) { | 311 if (initiator.url) { |
| 312 this.url = initiator.url; | 312 this.url = initiator.url; |
| 313 this.line = initiator.lineNumber || 0; | 313 this.line = initiator.lineNumber || 0; |
| 314 } | 314 } |
| 315 } | 315 } |
| 316 } | 316 } |
| 317 } | 317 } |
| 318 | 318 |
| 319 /** | 319 /** |
| 320 * @param {!WebInspector.ConsoleMessage} a | 320 * @param {!SDK.ConsoleMessage} a |
| 321 * @param {!WebInspector.ConsoleMessage} b | 321 * @param {!SDK.ConsoleMessage} b |
| 322 * @return {number} | 322 * @return {number} |
| 323 */ | 323 */ |
| 324 static timestampComparator(a, b) { | 324 static timestampComparator(a, b) { |
| 325 return a.timestamp - b.timestamp; | 325 return a.timestamp - b.timestamp; |
| 326 } | 326 } |
| 327 | 327 |
| 328 /** | 328 /** |
| 329 * @param {!Protocol.Runtime.ExceptionDetails} exceptionDetails | 329 * @param {!Protocol.Runtime.ExceptionDetails} exceptionDetails |
| 330 * @return {string} | 330 * @return {string} |
| 331 */ | 331 */ |
| 332 static simpleTextFromException(exceptionDetails) { | 332 static simpleTextFromException(exceptionDetails) { |
| 333 var text = exceptionDetails.text; | 333 var text = exceptionDetails.text; |
| 334 if (exceptionDetails.exception && exceptionDetails.exception.description) { | 334 if (exceptionDetails.exception && exceptionDetails.exception.description) { |
| 335 var description = exceptionDetails.exception.description; | 335 var description = exceptionDetails.exception.description; |
| 336 if (description.indexOf('\n') !== -1) | 336 if (description.indexOf('\n') !== -1) |
| 337 description = description.substring(0, description.indexOf('\n')); | 337 description = description.substring(0, description.indexOf('\n')); |
| 338 text += ' ' + description; | 338 text += ' ' + description; |
| 339 } | 339 } |
| 340 return text; | 340 return text; |
| 341 } | 341 } |
| 342 | 342 |
| 343 /** | 343 /** |
| 344 * @param {!WebInspector.Target} target | 344 * @param {!SDK.Target} target |
| 345 * @param {!Protocol.Runtime.ExceptionDetails} exceptionDetails | 345 * @param {!Protocol.Runtime.ExceptionDetails} exceptionDetails |
| 346 * @param {string=} messageType | 346 * @param {string=} messageType |
| 347 * @param {number=} timestamp | 347 * @param {number=} timestamp |
| 348 * @param {string=} forceUrl | 348 * @param {string=} forceUrl |
| 349 * @return {!WebInspector.ConsoleMessage} | 349 * @return {!SDK.ConsoleMessage} |
| 350 */ | 350 */ |
| 351 static fromException(target, exceptionDetails, messageType, timestamp, forceUr
l) { | 351 static fromException(target, exceptionDetails, messageType, timestamp, forceUr
l) { |
| 352 return new WebInspector.ConsoleMessage( | 352 return new SDK.ConsoleMessage( |
| 353 target, WebInspector.ConsoleMessage.MessageSource.JS, WebInspector.Conso
leMessage.MessageLevel.Error, | 353 target, SDK.ConsoleMessage.MessageSource.JS, SDK.ConsoleMessage.MessageL
evel.Error, |
| 354 WebInspector.ConsoleMessage.simpleTextFromException(exceptionDetails), m
essageType, | 354 SDK.ConsoleMessage.simpleTextFromException(exceptionDetails), messageTyp
e, |
| 355 forceUrl || exceptionDetails.url, exceptionDetails.lineNumber, exception
Details.columnNumber, undefined, | 355 forceUrl || exceptionDetails.url, exceptionDetails.lineNumber, exception
Details.columnNumber, undefined, |
| 356 exceptionDetails.exception ? | 356 exceptionDetails.exception ? |
| 357 [WebInspector.RemoteObject.fromLocalObject(exceptionDetails.text), e
xceptionDetails.exception] : | 357 [SDK.RemoteObject.fromLocalObject(exceptionDetails.text), exceptionD
etails.exception] : |
| 358 undefined, | 358 undefined, |
| 359 exceptionDetails.stackTrace, timestamp, exceptionDetails.executionContex
tId, exceptionDetails.scriptId); | 359 exceptionDetails.stackTrace, timestamp, exceptionDetails.executionContex
tId, exceptionDetails.scriptId); |
| 360 } | 360 } |
| 361 | 361 |
| 362 /** | 362 /** |
| 363 * @return {?WebInspector.Target} | 363 * @return {?SDK.Target} |
| 364 */ | 364 */ |
| 365 target() { | 365 target() { |
| 366 return this._target; | 366 return this._target; |
| 367 } | 367 } |
| 368 | 368 |
| 369 /** | 369 /** |
| 370 * @param {!WebInspector.ConsoleMessage} originatingMessage | 370 * @param {!SDK.ConsoleMessage} originatingMessage |
| 371 */ | 371 */ |
| 372 setOriginatingMessage(originatingMessage) { | 372 setOriginatingMessage(originatingMessage) { |
| 373 this._originatingConsoleMessage = originatingMessage; | 373 this._originatingConsoleMessage = originatingMessage; |
| 374 this.executionContextId = originatingMessage.executionContextId; | 374 this.executionContextId = originatingMessage.executionContextId; |
| 375 } | 375 } |
| 376 | 376 |
| 377 /** | 377 /** |
| 378 * @param {!Protocol.Runtime.ExecutionContextId} executionContextId | 378 * @param {!Protocol.Runtime.ExecutionContextId} executionContextId |
| 379 */ | 379 */ |
| 380 setExecutionContextId(executionContextId) { | 380 setExecutionContextId(executionContextId) { |
| 381 this.executionContextId = executionContextId; | 381 this.executionContextId = executionContextId; |
| 382 } | 382 } |
| 383 | 383 |
| 384 /** | 384 /** |
| 385 * @param {number} exceptionId | 385 * @param {number} exceptionId |
| 386 */ | 386 */ |
| 387 setExceptionId(exceptionId) { | 387 setExceptionId(exceptionId) { |
| 388 this._exceptionId = exceptionId; | 388 this._exceptionId = exceptionId; |
| 389 } | 389 } |
| 390 | 390 |
| 391 /** | 391 /** |
| 392 * @param {number} revokedExceptionId | 392 * @param {number} revokedExceptionId |
| 393 */ | 393 */ |
| 394 setRevokedExceptionId(revokedExceptionId) { | 394 setRevokedExceptionId(revokedExceptionId) { |
| 395 this._revokedExceptionId = revokedExceptionId; | 395 this._revokedExceptionId = revokedExceptionId; |
| 396 } | 396 } |
| 397 | 397 |
| 398 /** | 398 /** |
| 399 * @return {?WebInspector.ConsoleMessage} | 399 * @return {?SDK.ConsoleMessage} |
| 400 */ | 400 */ |
| 401 originatingMessage() { | 401 originatingMessage() { |
| 402 return this._originatingConsoleMessage; | 402 return this._originatingConsoleMessage; |
| 403 } | 403 } |
| 404 | 404 |
| 405 /** | 405 /** |
| 406 * @return {boolean} | 406 * @return {boolean} |
| 407 */ | 407 */ |
| 408 isGroupMessage() { | 408 isGroupMessage() { |
| 409 return this.type === WebInspector.ConsoleMessage.MessageType.StartGroup || | 409 return this.type === SDK.ConsoleMessage.MessageType.StartGroup || |
| 410 this.type === WebInspector.ConsoleMessage.MessageType.StartGroupCollapse
d || | 410 this.type === SDK.ConsoleMessage.MessageType.StartGroupCollapsed || |
| 411 this.type === WebInspector.ConsoleMessage.MessageType.EndGroup; | 411 this.type === SDK.ConsoleMessage.MessageType.EndGroup; |
| 412 } | 412 } |
| 413 | 413 |
| 414 /** | 414 /** |
| 415 * @return {boolean} | 415 * @return {boolean} |
| 416 */ | 416 */ |
| 417 isGroupStartMessage() { | 417 isGroupStartMessage() { |
| 418 return this.type === WebInspector.ConsoleMessage.MessageType.StartGroup || | 418 return this.type === SDK.ConsoleMessage.MessageType.StartGroup || |
| 419 this.type === WebInspector.ConsoleMessage.MessageType.StartGroupCollapse
d; | 419 this.type === SDK.ConsoleMessage.MessageType.StartGroupCollapsed; |
| 420 } | 420 } |
| 421 | 421 |
| 422 /** | 422 /** |
| 423 * @return {boolean} | 423 * @return {boolean} |
| 424 */ | 424 */ |
| 425 isErrorOrWarning() { | 425 isErrorOrWarning() { |
| 426 return ( | 426 return ( |
| 427 this.level === WebInspector.ConsoleMessage.MessageLevel.Warning || | 427 this.level === SDK.ConsoleMessage.MessageLevel.Warning || |
| 428 this.level === WebInspector.ConsoleMessage.MessageLevel.Error); | 428 this.level === SDK.ConsoleMessage.MessageLevel.Error); |
| 429 } | 429 } |
| 430 | 430 |
| 431 /** | 431 /** |
| 432 * @param {?WebInspector.ConsoleMessage} msg | 432 * @param {?SDK.ConsoleMessage} msg |
| 433 * @return {boolean} | 433 * @return {boolean} |
| 434 */ | 434 */ |
| 435 isEqual(msg) { | 435 isEqual(msg) { |
| 436 if (!msg) | 436 if (!msg) |
| 437 return false; | 437 return false; |
| 438 | 438 |
| 439 if (this._exceptionId || msg._exceptionId) | 439 if (this._exceptionId || msg._exceptionId) |
| 440 return false; | 440 return false; |
| 441 if (this._revokedExceptionId || msg._revokedExceptionId) | 441 if (this._revokedExceptionId || msg._revokedExceptionId) |
| 442 return false; | 442 return false; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 return false; | 483 return false; |
| 484 } | 484 } |
| 485 return this._isEqualStackTraces(stackTrace1.parent, stackTrace2.parent); | 485 return this._isEqualStackTraces(stackTrace1.parent, stackTrace2.parent); |
| 486 } | 486 } |
| 487 }; | 487 }; |
| 488 | 488 |
| 489 // Note: Keep these constants in sync with the ones in Console.h | 489 // Note: Keep these constants in sync with the ones in Console.h |
| 490 /** | 490 /** |
| 491 * @enum {string} | 491 * @enum {string} |
| 492 */ | 492 */ |
| 493 WebInspector.ConsoleMessage.MessageSource = { | 493 SDK.ConsoleMessage.MessageSource = { |
| 494 XML: 'xml', | 494 XML: 'xml', |
| 495 JS: 'javascript', | 495 JS: 'javascript', |
| 496 Network: 'network', | 496 Network: 'network', |
| 497 ConsoleAPI: 'console-api', | 497 ConsoleAPI: 'console-api', |
| 498 Storage: 'storage', | 498 Storage: 'storage', |
| 499 AppCache: 'appcache', | 499 AppCache: 'appcache', |
| 500 Rendering: 'rendering', | 500 Rendering: 'rendering', |
| 501 CSS: 'css', | 501 CSS: 'css', |
| 502 Security: 'security', | 502 Security: 'security', |
| 503 Violation: 'violation', | 503 Violation: 'violation', |
| 504 Other: 'other', | 504 Other: 'other', |
| 505 Deprecation: 'deprecation', | 505 Deprecation: 'deprecation', |
| 506 Worker: 'worker' | 506 Worker: 'worker' |
| 507 }; | 507 }; |
| 508 | 508 |
| 509 /** | 509 /** |
| 510 * @enum {string} | 510 * @enum {string} |
| 511 */ | 511 */ |
| 512 WebInspector.ConsoleMessage.MessageType = { | 512 SDK.ConsoleMessage.MessageType = { |
| 513 Log: 'log', | 513 Log: 'log', |
| 514 Debug: 'debug', | 514 Debug: 'debug', |
| 515 Info: 'info', | 515 Info: 'info', |
| 516 Error: 'error', | 516 Error: 'error', |
| 517 Warning: 'warning', | 517 Warning: 'warning', |
| 518 Dir: 'dir', | 518 Dir: 'dir', |
| 519 DirXML: 'dirxml', | 519 DirXML: 'dirxml', |
| 520 Table: 'table', | 520 Table: 'table', |
| 521 Trace: 'trace', | 521 Trace: 'trace', |
| 522 Clear: 'clear', | 522 Clear: 'clear', |
| 523 StartGroup: 'startGroup', | 523 StartGroup: 'startGroup', |
| 524 StartGroupCollapsed: 'startGroupCollapsed', | 524 StartGroupCollapsed: 'startGroupCollapsed', |
| 525 EndGroup: 'endGroup', | 525 EndGroup: 'endGroup', |
| 526 Assert: 'assert', | 526 Assert: 'assert', |
| 527 Result: 'result', | 527 Result: 'result', |
| 528 Profile: 'profile', | 528 Profile: 'profile', |
| 529 ProfileEnd: 'profileEnd', | 529 ProfileEnd: 'profileEnd', |
| 530 Command: 'command' | 530 Command: 'command' |
| 531 }; | 531 }; |
| 532 | 532 |
| 533 /** | 533 /** |
| 534 * @enum {string} | 534 * @enum {string} |
| 535 */ | 535 */ |
| 536 WebInspector.ConsoleMessage.MessageLevel = { | 536 SDK.ConsoleMessage.MessageLevel = { |
| 537 Log: 'log', | 537 Log: 'log', |
| 538 Info: 'info', | 538 Info: 'info', |
| 539 Warning: 'warning', | 539 Warning: 'warning', |
| 540 Error: 'error', | 540 Error: 'error', |
| 541 Debug: 'debug', | 541 Debug: 'debug', |
| 542 RevokedError: 'revokedError' // This is frontend-only level, used to put exce
ptions to console. | 542 RevokedError: 'revokedError' // This is frontend-only level, used to put exce
ptions to console. |
| 543 }; | 543 }; |
| 544 | 544 |
| 545 | 545 |
| 546 /** | 546 /** |
| 547 * @implements {Protocol.LogDispatcher} | 547 * @implements {Protocol.LogDispatcher} |
| 548 * @unrestricted | 548 * @unrestricted |
| 549 */ | 549 */ |
| 550 WebInspector.LogDispatcher = class { | 550 SDK.LogDispatcher = class { |
| 551 /** | 551 /** |
| 552 * @param {!WebInspector.ConsoleModel} console | 552 * @param {!SDK.ConsoleModel} console |
| 553 */ | 553 */ |
| 554 constructor(console) { | 554 constructor(console) { |
| 555 this._console = console; | 555 this._console = console; |
| 556 } | 556 } |
| 557 | 557 |
| 558 /** | 558 /** |
| 559 * @override | 559 * @override |
| 560 * @param {!Protocol.Log.LogEntry} payload | 560 * @param {!Protocol.Log.LogEntry} payload |
| 561 */ | 561 */ |
| 562 entryAdded(payload) { | 562 entryAdded(payload) { |
| 563 var consoleMessage = new WebInspector.ConsoleMessage( | 563 var consoleMessage = new SDK.ConsoleMessage( |
| 564 this._console.target(), payload.source, payload.level, payload.text, und
efined, payload.url, payload.lineNumber, | 564 this._console.target(), payload.source, payload.level, payload.text, und
efined, payload.url, payload.lineNumber, |
| 565 undefined, payload.networkRequestId, undefined, payload.stackTrace, payl
oad.timestamp, undefined, undefined, | 565 undefined, payload.networkRequestId, undefined, payload.stackTrace, payl
oad.timestamp, undefined, undefined, |
| 566 payload.workerId); | 566 payload.workerId); |
| 567 this._console.addMessage(consoleMessage); | 567 this._console.addMessage(consoleMessage); |
| 568 } | 568 } |
| 569 }; | 569 }; |
| 570 | 570 |
| 571 /** | 571 /** |
| 572 * @implements {WebInspector.TargetManager.Observer} | 572 * @implements {SDK.TargetManager.Observer} |
| 573 * @unrestricted | 573 * @unrestricted |
| 574 */ | 574 */ |
| 575 WebInspector.MultitargetConsoleModel = class extends WebInspector.Object { | 575 SDK.MultitargetConsoleModel = class extends Common.Object { |
| 576 constructor() { | 576 constructor() { |
| 577 super(); | 577 super(); |
| 578 WebInspector.targetManager.observeTargets(this); | 578 SDK.targetManager.observeTargets(this); |
| 579 WebInspector.targetManager.addModelListener( | 579 SDK.targetManager.addModelListener( |
| 580 WebInspector.ConsoleModel, WebInspector.ConsoleModel.Events.MessageAdded
, this._consoleMessageAdded, this); | 580 SDK.ConsoleModel, SDK.ConsoleModel.Events.MessageAdded, this._consoleMes
sageAdded, this); |
| 581 WebInspector.targetManager.addModelListener( | 581 SDK.targetManager.addModelListener( |
| 582 WebInspector.ConsoleModel, WebInspector.ConsoleModel.Events.MessageUpdat
ed, this._consoleMessageUpdated, this); | 582 SDK.ConsoleModel, SDK.ConsoleModel.Events.MessageUpdated, this._consoleM
essageUpdated, this); |
| 583 WebInspector.targetManager.addModelListener( | 583 SDK.targetManager.addModelListener( |
| 584 WebInspector.ConsoleModel, WebInspector.ConsoleModel.Events.CommandEvalu
ated, this._commandEvaluated, this); | 584 SDK.ConsoleModel, SDK.ConsoleModel.Events.CommandEvaluated, this._comman
dEvaluated, this); |
| 585 } | 585 } |
| 586 | 586 |
| 587 /** | 587 /** |
| 588 * @override | 588 * @override |
| 589 * @param {!WebInspector.Target} target | 589 * @param {!SDK.Target} target |
| 590 */ | 590 */ |
| 591 targetAdded(target) { | 591 targetAdded(target) { |
| 592 if (!this._mainTarget) { | 592 if (!this._mainTarget) { |
| 593 this._mainTarget = target; | 593 this._mainTarget = target; |
| 594 target.consoleModel.addEventListener(WebInspector.ConsoleModel.Events.Cons
oleCleared, this._consoleCleared, this); | 594 target.consoleModel.addEventListener(SDK.ConsoleModel.Events.ConsoleCleare
d, this._consoleCleared, this); |
| 595 } | 595 } |
| 596 } | 596 } |
| 597 | 597 |
| 598 /** | 598 /** |
| 599 * @override | 599 * @override |
| 600 * @param {!WebInspector.Target} target | 600 * @param {!SDK.Target} target |
| 601 */ | 601 */ |
| 602 targetRemoved(target) { | 602 targetRemoved(target) { |
| 603 if (this._mainTarget === target) { | 603 if (this._mainTarget === target) { |
| 604 delete this._mainTarget; | 604 delete this._mainTarget; |
| 605 target.consoleModel.removeEventListener( | 605 target.consoleModel.removeEventListener( |
| 606 WebInspector.ConsoleModel.Events.ConsoleCleared, this._consoleCleared,
this); | 606 SDK.ConsoleModel.Events.ConsoleCleared, this._consoleCleared, this); |
| 607 } | 607 } |
| 608 } | 608 } |
| 609 | 609 |
| 610 /** | 610 /** |
| 611 * @return {!Array.<!WebInspector.ConsoleMessage>} | 611 * @return {!Array.<!SDK.ConsoleMessage>} |
| 612 */ | 612 */ |
| 613 messages() { | 613 messages() { |
| 614 var targets = WebInspector.targetManager.targets(); | 614 var targets = SDK.targetManager.targets(); |
| 615 var result = []; | 615 var result = []; |
| 616 for (var i = 0; i < targets.length; ++i) | 616 for (var i = 0; i < targets.length; ++i) |
| 617 result = result.concat(targets[i].consoleModel.messages()); | 617 result = result.concat(targets[i].consoleModel.messages()); |
| 618 return result; | 618 return result; |
| 619 } | 619 } |
| 620 | 620 |
| 621 _consoleCleared() { | 621 _consoleCleared() { |
| 622 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.ConsoleCleare
d); | 622 this.dispatchEventToListeners(SDK.ConsoleModel.Events.ConsoleCleared); |
| 623 } | 623 } |
| 624 | 624 |
| 625 /** | 625 /** |
| 626 * @param {!WebInspector.Event} event | 626 * @param {!Common.Event} event |
| 627 */ | 627 */ |
| 628 _consoleMessageAdded(event) { | 628 _consoleMessageAdded(event) { |
| 629 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.MessageAdded,
event.data); | 629 this.dispatchEventToListeners(SDK.ConsoleModel.Events.MessageAdded, event.da
ta); |
| 630 } | 630 } |
| 631 | 631 |
| 632 /** | 632 /** |
| 633 * @param {!WebInspector.Event} event | 633 * @param {!Common.Event} event |
| 634 */ | 634 */ |
| 635 _consoleMessageUpdated(event) { | 635 _consoleMessageUpdated(event) { |
| 636 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.MessageUpdate
d, event.data); | 636 this.dispatchEventToListeners(SDK.ConsoleModel.Events.MessageUpdated, event.
data); |
| 637 } | 637 } |
| 638 | 638 |
| 639 /** | 639 /** |
| 640 * @param {!WebInspector.Event} event | 640 * @param {!Common.Event} event |
| 641 */ | 641 */ |
| 642 _commandEvaluated(event) { | 642 _commandEvaluated(event) { |
| 643 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.CommandEvalua
ted, event.data); | 643 this.dispatchEventToListeners(SDK.ConsoleModel.Events.CommandEvaluated, even
t.data); |
| 644 } | 644 } |
| 645 }; | 645 }; |
| 646 | 646 |
| 647 /** | 647 /** |
| 648 * @type {!WebInspector.MultitargetConsoleModel} | 648 * @type {!SDK.MultitargetConsoleModel} |
| 649 */ | 649 */ |
| 650 WebInspector.multitargetConsoleModel; | 650 SDK.multitargetConsoleModel; |
| OLD | NEW |