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

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

Issue 1511043002: [DevTools] Evaluate expression like { ... } as Object Literal (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/console/console-eval-object-literal-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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;
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/console/console-eval-object-literal-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698