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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 __proto__: WebInspector.SDKModel.prototype | 182 __proto__: WebInspector.SDKModel.prototype |
183 } | 183 } |
184 | 184 |
185 /** | 185 /** |
186 * @param {!WebInspector.ExecutionContext} executionContext | 186 * @param {!WebInspector.ExecutionContext} executionContext |
187 * @param {string} text | 187 * @param {string} text |
188 * @param {boolean=} useCommandLineAPI | 188 * @param {boolean=} useCommandLineAPI |
189 */ | 189 */ |
190 WebInspector.ConsoleModel.evaluateCommandInConsole = function(executionContext,
text, useCommandLineAPI) | 190 WebInspector.ConsoleModel.evaluateCommandInConsole = function(executionContext,
text, useCommandLineAPI) |
191 { | 191 { |
192 useCommandLineAPI = !!useCommandLineAPI; | |
193 var target = executionContext.target(); | 192 var target = executionContext.target(); |
194 | 193 |
195 var commandMessage = new WebInspector.ConsoleMessage(target, WebInspector.Co
nsoleMessage.MessageSource.JS, null, text, WebInspector.ConsoleMessage.MessageTy
pe.Command); | 194 var commandMessage = new WebInspector.ConsoleMessage(target, WebInspector.Co
nsoleMessage.MessageSource.JS, null, text, WebInspector.ConsoleMessage.MessageTy
pe.Command); |
196 commandMessage.setExecutionContextId(executionContext.id); | 195 commandMessage.setExecutionContextId(executionContext.id); |
197 target.consoleModel.addMessage(commandMessage); | 196 target.consoleModel.addMessage(commandMessage); |
198 | 197 |
199 /** | 198 /** |
200 * @param {?WebInspector.RemoteObject} result | 199 * @param {?WebInspector.RemoteObject} result |
201 * @param {boolean} wasThrown | 200 * @param {boolean} wasThrown |
202 * @param {?RuntimeAgent.RemoteObject=} valueResult | 201 * @param {?RuntimeAgent.RemoteObject=} valueResult |
203 * @param {?DebuggerAgent.ExceptionDetails=} exceptionDetails | 202 * @param {?DebuggerAgent.ExceptionDetails=} exceptionDetails |
204 */ | 203 */ |
205 function printResult(result, wasThrown, valueResult, exceptionDetails) | 204 function printResult(result, wasThrown, valueResult, exceptionDetails) |
206 { | 205 { |
207 if (!result) | 206 if (!result) |
208 return; | 207 return; |
209 | 208 |
210 WebInspector.console.showPromise().then(reportUponEvaluation); | 209 WebInspector.console.showPromise().then(reportUponEvaluation); |
211 function reportUponEvaluation() | 210 function reportUponEvaluation() |
212 { | 211 { |
213 target.consoleModel.dispatchEventToListeners(WebInspector.ConsoleMod
el.Events.CommandEvaluated, {result: result, wasThrown: wasThrown, text: text, c
ommandMessage: commandMessage, exceptionDetails: exceptionDetails}); | 212 target.consoleModel.dispatchEventToListeners(WebInspector.ConsoleMod
el.Events.CommandEvaluated, {result: result, wasThrown: wasThrown, text: text, c
ommandMessage: commandMessage, exceptionDetails: exceptionDetails}); |
214 } | 213 } |
215 } | 214 } |
216 | 215 if (/^\s*\{/.test(text) && /\}\s*$/.test(text)) |
217 executionContext.evaluate(text, "console", useCommandLineAPI, false, false,
true, printResult); | 216 text = '(' + text + ')'; |
| 217 executionContext.evaluate(text, "console", !!useCommandLineAPI, false, false
, true, printResult); |
218 | 218 |
219 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.Console
Evaluated); | 219 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.Console
Evaluated); |
220 } | 220 } |
221 | 221 |
222 WebInspector.ConsoleModel.clearConsole = function() | 222 WebInspector.ConsoleModel.clearConsole = function() |
223 { | 223 { |
224 var targets = WebInspector.targetManager.targets(); | 224 var targets = WebInspector.targetManager.targets(); |
225 for (var i = 0; i < targets.length; ++i) | 225 for (var i = 0; i < targets.length; ++i) |
226 targets[i].consoleModel.requestClearMessages(); | 226 targets[i].consoleModel.requestClearMessages(); |
227 } | 227 } |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.CommandEv
aluated, event.data); | 616 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.CommandEv
aluated, event.data); |
617 }, | 617 }, |
618 | 618 |
619 __proto__: WebInspector.Object.prototype | 619 __proto__: WebInspector.Object.prototype |
620 } | 620 } |
621 | 621 |
622 /** | 622 /** |
623 * @type {!WebInspector.MultitargetConsoleModel} | 623 * @type {!WebInspector.MultitargetConsoleModel} |
624 */ | 624 */ |
625 WebInspector.multitargetConsoleModel; | 625 WebInspector.multitargetConsoleModel; |
OLD | NEW |