OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 var evaluationUrl = this._evaluationSourceURL(uiSourceCode); | 214 var evaluationUrl = this._evaluationSourceURL(uiSourceCode); |
215 var expression = uiSourceCode.workingCopy(); | 215 var expression = uiSourceCode.workingCopy(); |
216 | 216 |
217 WebInspector.console.show(); | 217 WebInspector.console.show(); |
218 var target = executionContext.target(); | 218 var target = executionContext.target(); |
219 target.debuggerAgent().compileScript(expression, evaluationUrl, executio nContext.id, compileCallback.bind(this, target)); | 219 target.debuggerAgent().compileScript(expression, evaluationUrl, executio nContext.id, compileCallback.bind(this, target)); |
220 | 220 |
221 /** | 221 /** |
222 * @param {!WebInspector.Target} target | 222 * @param {!WebInspector.Target} target |
223 * @param {?string} error | 223 * @param {?string} error |
224 * @param {string=} scriptId | 224 * @param {!DebuggerAgent.ScriptId=} scriptId |
225 * @param {string=} syntaxErrorMessage | 225 * @param {?DebuggerAgent.ExceptionMessage=} exceptionMessage |
226 * @this {WebInspector.ScriptSnippetModel} | 226 * @this {WebInspector.ScriptSnippetModel} |
227 */ | 227 */ |
228 function compileCallback(target, error, scriptId, syntaxErrorMessage) | 228 function compileCallback(target, error, scriptId, exceptionMessage) |
229 { | 229 { |
230 if (!uiSourceCode || uiSourceCode._evaluationIndex !== evaluationInd ex) | 230 if (!uiSourceCode || uiSourceCode._evaluationIndex !== evaluationInd ex) |
231 return; | 231 return; |
232 | 232 |
233 if (error) { | 233 if (error) { |
234 console.error(error); | 234 console.error(error); |
235 return; | 235 return; |
236 } | 236 } |
237 | 237 |
238 if (!scriptId) { | 238 if (!scriptId) { |
239 var consoleMessage = new WebInspector.ConsoleMessage( | 239 var consoleMessage = new WebInspector.ConsoleMessage( |
240 target, | 240 target, |
241 WebInspector.ConsoleMessage.MessageSource.JS, | 241 exceptionMessage.source, |
242 WebInspector.ConsoleMessage.MessageLevel.Error, | 242 WebInspector.ConsoleMessage.MessageLevel.Error, |
243 syntaxErrorMessage || ""); | 243 exceptionMessage.text || "", |
244 undefined, | |
245 evaluationUrl, | |
246 exceptionMessage.line, | |
247 exceptionMessage.column, | |
248 undefined, | |
249 undefined, | |
250 exceptionMessage.stackTrace); | |
244 target.consoleModel.addMessage(consoleMessage); | 251 target.consoleModel.addMessage(consoleMessage); |
245 return; | 252 return; |
246 } | 253 } |
247 | 254 |
248 var breakpointLocations = this._removeBreakpoints(uiSourceCode); | 255 var breakpointLocations = this._removeBreakpoints(uiSourceCode); |
249 this._restoreBreakpoints(uiSourceCode, breakpointLocations); | 256 this._restoreBreakpoints(uiSourceCode, breakpointLocations); |
250 | 257 |
251 this._runScript(scriptId, executionContext); | 258 this._runScript(scriptId, executionContext, evaluationUrl); |
252 } | 259 } |
253 }, | 260 }, |
254 | 261 |
255 /** | 262 /** |
256 * @param {!DebuggerAgent.ScriptId} scriptId | 263 * @param {!DebuggerAgent.ScriptId} scriptId |
257 * @param {!WebInspector.ExecutionContext} executionContext | 264 * @param {!WebInspector.ExecutionContext} executionContext |
258 */ | 265 */ |
259 _runScript: function(scriptId, executionContext) | 266 _runScript: function(scriptId, executionContext, sourceURL) |
260 { | 267 { |
261 var target = executionContext.target(); | 268 var target = executionContext.target(); |
262 target.debuggerAgent().runScript(scriptId, executionContext.id, "console ", false, runCallback.bind(this, target)); | 269 target.debuggerAgent().runScript(scriptId, executionContext.id, "console ", false, runCallback.bind(this, target)); |
263 | 270 |
264 /** | 271 /** |
265 * @param {!WebInspector.Target} target | 272 * @param {!WebInspector.Target} target |
266 * @param {?string} error | 273 * @param {?string} error |
267 * @param {?RuntimeAgent.RemoteObject} result | 274 * @param {?RuntimeAgent.RemoteObject} result |
268 * @param {boolean=} wasThrown | 275 * @param {?DebuggerAgent.ExceptionMessage=} exceptionMessage |
269 * @this {WebInspector.ScriptSnippetModel} | 276 * @this {WebInspector.ScriptSnippetModel} |
270 */ | 277 */ |
271 function runCallback(target, error, result, wasThrown) | 278 function runCallback(target, error, result, exceptionMessage) |
272 { | 279 { |
273 if (error) { | 280 if (error) { |
274 console.error(error); | 281 console.error(error); |
275 return; | 282 return; |
276 } | 283 } |
277 | 284 |
278 this._printRunScriptResult(target, result, wasThrown); | 285 this._printRunScriptResult(target, result, sourceURL, exceptionMessa ge); |
279 } | 286 } |
280 }, | 287 }, |
281 | 288 |
282 /** | 289 /** |
283 * @param {!WebInspector.Target} target | 290 * @param {!WebInspector.Target} target |
284 * @param {?RuntimeAgent.RemoteObject} result | 291 * @param {?RuntimeAgent.RemoteObject} result |
285 * @param {boolean=} wasThrown | 292 * @param {?string=} sourceURL |
293 * @param {?DebuggerAgent.ExceptionMessage=} exceptionMessage | |
286 */ | 294 */ |
287 _printRunScriptResult: function(target, result, wasThrown) | 295 _printRunScriptResult: function(target, result, sourceURL, exceptionMessage) |
288 { | 296 { |
297 var wasThrown = !!exceptionMessage; | |
289 var level = (wasThrown ? WebInspector.ConsoleMessage.MessageLevel.Error : WebInspector.ConsoleMessage.MessageLevel.Log); | 298 var level = (wasThrown ? WebInspector.ConsoleMessage.MessageLevel.Error : WebInspector.ConsoleMessage.MessageLevel.Log); |
290 var message = new WebInspector.ConsoleMessage(target, | 299 var consoleMessage = new WebInspector.ConsoleMessage( |
vsevik
2014/05/19 12:40:23
This is hard to read.
Let's split this into two if
| |
300 target, | |
291 WebInspector.ConsoleMessage.MessageSource.JS, | 301 WebInspector.ConsoleMessage.MessageSource.JS, |
292 level, | 302 level, |
293 "", | 303 (wasThrown ? exceptionMessage.text : ""), |
294 undefined, | 304 undefined, |
305 sourceURL, | |
306 (wasThrown ? exceptionMessage.line : undefined), | |
307 (wasThrown ? exceptionMessage.column : undefined), | |
295 undefined, | 308 undefined, |
296 undefined, | 309 (wasThrown ? undefined : [result]), |
297 undefined, | 310 (wasThrown ? exceptionMessage.stackTrace : undefined)); |
298 undefined, | 311 target.consoleModel.addMessage(consoleMessage); |
299 [result]); | |
300 target.consoleModel.addMessage(message); | |
301 }, | 312 }, |
302 | 313 |
303 /** | 314 /** |
304 * @param {!WebInspector.DebuggerModel.Location} rawLocation | 315 * @param {!WebInspector.DebuggerModel.Location} rawLocation |
305 * @return {?WebInspector.UILocation} | 316 * @return {?WebInspector.UILocation} |
306 */ | 317 */ |
307 _rawLocationToUILocation: function(rawLocation) | 318 _rawLocationToUILocation: function(rawLocation) |
308 { | 319 { |
309 var uiSourceCode = this._uiSourceCodeForScriptId[rawLocation.scriptId]; | 320 var uiSourceCode = this._uiSourceCodeForScriptId[rawLocation.scriptId]; |
310 if (!uiSourceCode) | 321 if (!uiSourceCode) |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
628 this._model.deleteScriptSnippet(path); | 639 this._model.deleteScriptSnippet(path); |
629 }, | 640 }, |
630 | 641 |
631 __proto__: WebInspector.ContentProviderBasedProjectDelegate.prototype | 642 __proto__: WebInspector.ContentProviderBasedProjectDelegate.prototype |
632 } | 643 } |
633 | 644 |
634 /** | 645 /** |
635 * @type {!WebInspector.ScriptSnippetModel} | 646 * @type {!WebInspector.ScriptSnippetModel} |
636 */ | 647 */ |
637 WebInspector.scriptSnippetModel; | 648 WebInspector.scriptSnippetModel; |
OLD | NEW |